[LLVMdev] A basicblock iterator bug in llvm

hc2428 at columbia.edu hc2428 at columbia.edu
Sat Sep 26 20:49:40 PDT 2009


Quoting hc2428 at columbia.edu:

I am using LLVM-2.5. Here is the attachment.

> 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.
>
> 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
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.tar.gz
Type: application/x-gzip-compressed
Size: 4842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090926/e8742696/attachment.bin>


More information about the llvm-dev mailing list