bool runOnFunction(Function &F) override {
outs() << "Inside Function: "<<F.getName()<<"\n";
int i = 0;
map<int, Instruction*> work;
for(BasicBlock &BB : F)
for(Instruction &I : BB){
if(i == 15)
work.insert({i, &I});
i++;
}
std::map<int, Instruction*>::iterator it = work.begin();
it->second->eraseFromParent();
return true;
}
以上是我的代码片段。在这里,在上面的代码中,我想随机删除一条指令..只是为了知道如何使用这个api。但是,无论我尝试什么,它都会以分段错误告终!需要一些指导,请在这里
Inside Function: change_g
While deleting: i32 %
Use still stuck around after Def is destroyed: %add = add nsw i32 <badref>, %l
opt: /home/user/llvm-project/llvm/lib/IR/Value.cpp:103: llvm::Value::~Value(): Assertion `materialized_use_empty() && "Uses remain when a value is destroyed!"' failed.