我試圖用常量替換地址的所有實例。LLVM:用常量替換地址的所有實例
我得到&以下測試商店的地址(i是指令)
//already know it's a store instruction at this point
llvm::Value *addy = i->getOperand(0);
if(llvm::ConstantInt* c = dyn_cast<llvm:::ConstantInt>(addy)){
//replace all uses of the address with the constant
//operand(1) will be the address the const would be stored at
i->getOperand(1)->replaceAllUsesWith(c);
}
我認爲這會工作,但我得到的錯誤是
"Assertion: New->getType()== getType() && replaceAllUses of value with new value of different type!" failed
,我不知道爲什麼......我replaceAllUses的理解是,它會替換地址的使用(I-> getOperand(1)用恆定的?