pyt*_*nic 4 c++ compiler-construction llvm
在下面的代码中,我尝试替换 LLVM 指令的操作数。然而它不起作用并且没有任何改变。知道如何解决这个问题吗?
for (OI = insn->op_begin(), OE = insn->op_end(); OI != OE; ++OI)
{
Value *val = *OI;
iter = mapClonedAndOrg.find( val );
if( iter != mapClonedAndOrg.end( ) )
{
// Here I try to replace the operand, to no effect!
val = (Value*)iter->second.PN;
}
}
Run Code Online (Sandbox Code Playgroud)
您应该使用迭代器OI来替换它,而不是本地指针val。所以应该是这样的。
for (OI = insn->op_begin(), OE = insn->op_end(); OI != OE; ++OI)
{
Value *val = *OI;
iter = mapClonedAndOrg.find( val );
if( iter != mapClonedAndOrg.end( ) )
{
*OI = (Value*)iter->second.PN;
}
}
Run Code Online (Sandbox Code Playgroud)