[LLVMdev] Segmentation fault on using get parent of a PHINode
Duncan Sands
baldrick at free.fr
Sat Feb 5 10:09:07 PST 2011
Hi Surinder, I don't see anything obviously wrong with your code. I suggest
that (1) you build LLVM with assertions enabled, (2) you run the verifier on
your bitcode, and (3) run your program under valgrind.
Ciao, Duncan.
> I am getting a segmentation fault as soon as I touch the Basic block
> *b value defined as :
>
> std::string getPHIAssigns(const PHINode *PH)
> { const BasicBlock *b = PH->getParent();
> errs()<< b->size();
>
>
> where as getPHIAssigns is being called from
>
> for (BasicBlock::iterator ins=b->begin(), e3=b->end();
> ins!=e3; ++ins, ++l) // get instructions
> { if (const PHINode *PH = dyn_cast<PHINode>(&ins)) // Phi
> ers()<< getPHIAssigns(PH);
>
> Can you see what is wrong here?
>
> The dump is :
>
> 0 opt 0x0000000000bc9cfa
> 1 opt 0x0000000000bca288
> 2 libpthread.so.0 0x00000037ef20e540
> 3 opt 0x0000000000910849 llvm::iplist<llvm::Instruction,
> llvm::ilist_traits<llvm::Instruction> >::size() const + 17
> 4 opt 0x00000000009108a5 llvm::BasicBlock::size() const + 25
> 5 dfl.so 0x00002aaaaaaf101d
> 6 dfl.so 0x00002aaaaaaf2965
> 7 dfl.so 0x00002aaaaaaf308a
> 8 opt 0x0000000000b467fa
> llvm::FPPassManager::runOnFunction(llvm::Function&) + 348
> 9 opt 0x0000000000b469cf
> llvm::FPPassManager::runOnModule(llvm::Module&) + 81
> 10 opt 0x0000000000b464bd
> llvm::MPPassManager::runOnModule(llvm::Module&) + 381
> 11 opt 0x0000000000b478f7
> llvm::PassManagerImpl::run(llvm::Module&) + 111
> 12 opt 0x0000000000b47959 llvm::PassManager::run(llvm::Module&) + 33
> 13 opt 0x00000000007a14a6 main + 3438
> 14 libc.so.6 0x00000037ee61e074 __libc_start_main + 244
> 15 opt 0x00000000007929a9
> Stack dump:
> 0. Program arguments: opt -load
> /u1/suri/llvm-local/build/x86-64/Debug/llvm/Debug/lib/dfl.so -dfl
> /u1/suri/suri/testing/cfgs/test99foo.c.bc
> 1. Running pass 'Function Pass Manager' on module
> '/u1/suri/suri/testing/cfgs/test99foo.c.bc'.
> 2. Running pass 'emit cfg in dfl format' on function '@main'
>
> Surinder
>>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list