[LLVMdev] eraseFromParent and stack dump

Vasileios Koutsoumpos bill_koutsoumpos at hotmail.com
Thu Jun 26 02:38:59 PDT 2014


Hello,

I am creating a new instruction and I want to replace the use of a 
specified instruction.
This is the code I have written

Instruction *new_instr = BinaryOperator::Create(Instruction::Sub, op1, 
op2, "");
b->getInstList().insertAfter(old_instr, new_instr);  //b is the BasicBlock
old_instr->replaceAllUsesWith(new_instr);
old_instr->eraseFromParent();

When I print the basic block, I see that my instruction was inserted  
and replaces the old instruction, however I get a stack dump, when I run 
the instrumented IR file.

0  opt             0x00000000014680df 
llvm::sys::PrintStackTrace(_IO_FILE*) + 38
1  opt             0x000000000146835c
2  opt             0x0000000001467dd8
3  libpthread.so.0 0x00007f8934eecbb0
4  llfi-passes.so  0x00007f89340a39b2 llvm::Value::getValueID() const + 12
5  llfi-passes.so  0x00007f89340a3aa4 llvm::Instruction::getOpcode() 
const + 24
6  llfi-passes.so  0x00007f89340a331c 
llfi::FaultInjectionPass::locate_instruction(llvm::Module&, 
llvm::Function*, llvm::LoopInfo&, int) + 282
7  llfi-passes.so  0x00007f89340a2e50 
llfi::FaultInjectionPass::finalize(llvm::Module&, int) + 506
8  llfi-passes.so  0x00007f89340a3509 
llfi::FaultInjectionPass::runOnModule(llvm::Module&) + 113
9  opt             0x0000000001362a1e 
llvm::MPPassManager::runOnModule(llvm::Module&) + 502
10 opt             0x0000000001362fee 
llvm::PassManagerImpl::run(llvm::Module&) + 244
11 opt             0x00000000013631f9 
llvm::PassManager::run(llvm::Module&) + 39
12 opt             0x00000000008719e8 main + 5698
13 libc.so.6       0x00007f8934318de5 __libc_start_main + 245
14 opt             0x0000000000863779
Stack dump:

I replace the uses of the old instruction, before deleting it. I am not 
sure why this is happening.
any suggestions?

Vasileios




More information about the llvm-dev mailing list