[llvm] Aborted (core dumped) when using clone
Danna bib
danna1364 at gmail.com
Tue Mar 4 14:15:23 PST 2014
Hi all,
I have problem with working by Instruction class of LLVM. I wrote the
following pass in order to make a copy of binary instructions. But, when I
run mypass with opt I face with an aborted error. I also got the same error
when I used eraseFromParent() function. It would be a great help if you
tell my where is my problem.
for (Function::iterator b = F.begin(), be = F.end(); b != be; ++b) {
for (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie;
++i) {
if (i->isBinaryOp()) {
errs() << "This instruction is BinaryO, and I want to copy
it! " << '\n';
Instruction *copyinst= i;
Instruction *IA = &* copyinst->clone();
// i->eraseFromParent();
}
}
}
*The output:*
This instruction is BinaryO, and I want to copy it!
Instruction referencing instruction not embedded in a basic block!
%indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %.backedge ]
<badref> = add i64 %indvars.iv, 1
Broken module found, compilation aborted!
0 libLLVM-3.4.so.1 0x00007f5c1bc1fd82
llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1 libLLVM-3.4.so.1 0x00007f5c1bc1fb6c
2 libc.so.6 0x00007f5c1a69ffb0
3 libc.so.6 0x00007f5c1a69ff39 gsignal + 57
4 libc.so.6 0x00007f5c1a6a3348 abort + 328
5 libLLVM-3.4.so.1 0x00007f5c1b610871
6 libLLVM-3.4.so.1 0x00007f5c1b619933
7 libLLVM-3.4.so.1 0x00007f5c1b5f0d77
llvm::FPPassManager::runOnFunction(llvm::Function&) + 471
8 libLLVM-3.4.so.1 0x00007f5c1b5f0e0b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
9 libLLVM-3.4.so.1 0x00007f5c1b5f32c5
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 693
10 opt-3.4 0x0000000000412c8d main + 2461
11 libc.so.6 0x00007f5c1a68aed5 __libc_start_main + 245
12 opt-3.4 0x0000000000413b40
Stack dump:
0. Program arguments: opt-3.4 -load ../../../Debug+Asserts/lib/Mypass.so
-mypass
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'Module Verifier' on function '@main'
Aborted (core dumped)
Thank you,
Danna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140304/b8807506/attachment.html>
More information about the llvm-commits
mailing list