我正在尝试用常量替换地址的所有实例。
我正在使用以下内容获取并测试商店的地址(我是一条指令)
//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) 的使用?