[LLVMdev] BasicBlock predecessors list

Cristianno Martins cristiannomartins at gmail.com
Wed Apr 4 12:33:38 PDT 2012


Hello Duncan,  

Thank you for the reply; I could now see what was wrong in my case: I'm cloning some instructions from the CFG to work with them, without risking to broke any blocks in the CFG. It appears that when some of these cloned instructions were branches, they still were referring to the original CFG's basic blocks (increasing their predecessors list), even though I added them to a different function in a different module.

Thanks again,  

--  
Cristianno Martins
PhD Student of Computer Science
University of Campinas
cmartins at ic.unicamp.br


On Wednesday, 4 de April de 2012 at 03:37, Duncan Sands wrote:

> Hi Cristianno,
>  
> > I'm trying to get a list of predecessors of a BasicBlock. I'm using a code
> > similar to that on here
> > <http://llvm.org/docs/ProgrammersManual.html#iterate_preds>, but it appears to
> > be more nodes been iterating that it should. Now, when I print out the llvm IR,
> > I get something like:
> > […]
> > while.body: ; preds = %7, %while.cond
> > […]
> > for a code that have only a while loop. Ok, I can recognize the %while.cond
> > block on the code, but the %7 block seems to be an extra BasicBlock (I mean, it
> > is not directly represented in the IR)
> >  
>  
>  
> what do you mean by "is not directly represented in the IR"? Do you mean that
> if you dump the IR for function then it is not there? If so, probably there is
> a basic block that wasn't properly added to the function (i.e. doesn't have the
> function as its parent), in which case most likely you have written your own
> pass and made a mistake in your basic block manipulation. If you mean that the
> basic block is there but is lacking a label like "while.cond" then that is
> normal: labels are entirely optional. The start of a basic block is not
> defined by a label, it is defined by the end of the previous basic block, which
> itself is defined by the presence of a terminator instruction.
>  
> Ciao, Duncan.
>  
> that holds only a copy of the branch
> > instruction that ends the %while.cond block.
> >  
> > Here is the question: is there any way that I could discard these blocks that
> > are not represented in the IR?
> >  
> > Thanks in advance,
> >  
> > --
> > Cristianno Martins
> > PhD Student of Computer Science
> > University of Campinas
> > cmartins at ic.unicamp.br (mailto:cmartins at ic.unicamp.br)
> >  
> >  
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >  
>  
>  
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>  
>  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120404/29dea93c/attachment.html>


More information about the llvm-dev mailing list