[LLVMdev] A basicblock iterator bug in llvm
Gabor Greif
ggreif at gmail.com
Sat Sep 26 23:15:13 PDT 2009
On 27 Sep., 05:45, hc2... at columbia.edu wrote:
> Dear developers:
> When I am doing basicblock pass, I meet a bug: there is an
> iterator "I" in a basicblock, and it is not pointing to the first
> instruction in this basicblock. However, "I--;" will fail by an
> assertion.
Hi hc!
are you on SVN trunk?
Cheers,
Gabor
>
> The basic block ("I" is pointing to the second instruction) in test.ll:
> bb: ; preds = %bb1
> %1 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr ([42 x
> i8]* @.str1, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
> %2 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr ([40 x
> i8]* @.str2, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
> %3 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr ([40 x
> i8]* @.str3, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
> %4 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr ([42 x
> i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
> br label %bb1
>
> The code slice in verify-fixrace.cpp in attachment:
>
> cerr << "IsFirst Current Inst: " << *I;
> cerr << "IsFirst First Inst: " << *BB->begin();
> I--;
>
> Output is:
> Inst: %2 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr
> ([40 x i8]* @.str2, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
> Backward Visit BB: bb
> IsFirst Current Inst: %2 = call i32 (i8*, ...)* @printf(i8* noalias
> getelementptr ([40 x i8]* @.str2, i32 0, i32 0)) nounwind ; <i32>
> [#uses=0]
> IsFirst First Inst: %1 = call i32 (i8*, ...)* @printf(i8* noalias
> getelementptr ([42 x i8]* @.str1, i32 0, i32 0)) nounwind ; <i32>
> [#uses=0]
> opt: /home/heming/defens/llvm-2.5/include/llvm/ADT/ilist.h:173:
> llvm::ilist_iterator<NodeTy>&
> llvm::ilist_iterator<NodeTy>::operator--() [with NodeTy =
> llvm::Instruction]: Assertion `Traits::getNext(NodePtr) && "--'d off
> the beginning of an ilist!"' failed.
> 0 opt 0x08642be4
> 1 opt 0x08642f26
> 2 0xb7f7f420 __kernel_sigreturn + 0
> 3 libc.so.6 0xb7d0ca01 abort + 257
> 4 libc.so.6 0xb7d0410e __assert_fail + 238
> 5 opt 0x08357997
> llvm::ilist_iterator<llvm::Instruction>::operator--() + 87
> 6 opt 0x08367104
> llvm::ilist_iterator<llvm::Instruction>::operator--(int) + 28
> 7 verify-fixrace-stub.so 0xb7f781be
> defens::verify_fixrace_stub::DFSBackward(llvm::Instruction*,
> std::string&, int, bool) + 826
> 8 verify-fixrace-stub.so 0xb7f78311
> defens::verify_fixrace_stub::runOnBasicBlock(llvm::BasicBlock&) + 261
> 9 opt 0x085cdaf4
> 10 opt 0x085cee1c
> llvm::FPPassManager::runOnFunction(llvm::Function&) + 250
> 11 opt 0x085cefb8
> llvm::FPPassManager::runOnModule(llvm::Module&) + 98
> 12 opt 0x085cd8a3
> llvm::MPPassManager::runOnModule(llvm::Module&) + 197
> 13 opt 0x085cf256
> llvm::PassManagerImpl::run(llvm::Module&) + 116
> 14 opt 0x085cf2af
> llvm::PassManager::run(llvm::Module&) + 27
> 15 opt 0x082f91d0 main + 4452
> 16 libc.so.6 0xb7cf6450 __libc_start_main + 224
> 17 opt 0x082e9c11 __gxx_personality_v0 + 849
>
> _______________________________________________
> LLVM Developers mailing list
> LLVM... at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list