[LLVMdev] LLVM segmentation fault / need use Instruction instead of Instruction*
Óscar Fuentes
ofv at wanadoo.es
Thu Dec 20 03:10:57 PST 2012
Alexandru Ionut Diaconescu <alexandruionutdiaconescu at gmail.com> writes:
> I was following your procedures and I isolated the problem. The problem are
> represented by the basic blocks with only one element.
>
>
> for (Function::iterator II = F.begin(), EE = F.end(); II != EE; ++II, ++ii)
> {
> BasicBlock* BB=II;
>
>
> if (BB->getTerminator())
> {
> Instruction* current = BB->getTerminator();
>
> Instruction* previous;
>
> errs()<<"AAA\n";
> if(*current->getPrevNode()*)
> {
> errs()<<"BBB\n";
> previous = current->getPrevNode();
> ok=1;
> }
>
> if (ok){
> errs()<<"CCC\n";
> ........
>
>
> It does print AAA, but then I have the segfault. So when I am evaluating
> the *current->getPrevNode() *condition, I got the segfault.
> Do you know how can I solve this?
The documentation for BasickBlock::getTerminator says:
/// getTerminator() - If this is a well formed basic block, then this returns
/// a pointer to the terminator instruction. If it is not, then you get a
/// null pointer back.
Maybe BB is not well formed (it doesn't have proper terminator) and
BB->getTerminator returns NULL ?
More information about the llvm-dev
mailing list