[LLVMdev] the pred_begin and pred_end of BasicBlock

Reid Spencer reid at x10sys.com
Wed Jan 12 22:59:00 PST 2005


Zhou,

I remember this issue biting me at first. It seemed logical that the
basic blocks would have an order and that there would be an implicit
branch between them, but that is not the case. In LLVM every BasicBlock
must be terminated with a terminating instruction (return, branch, etc.)

So, if your "A" never branches at the end it is invalid and will fail
the validator. A is not a predecessor of B unless you put in a "branch
to B" instruction. 

You might want to read this:

http://llvm.cs.uiuc.edu/docs/LangRef.html#functionstructure

then this:

http://llvm.cs.uiuc.edu/docs/LangRef.html#terminators

then this:

http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html#BasicBlock

Reid

On Wed, 2005-01-12 at 22:41, Zhou Feng wrote:
> Sorry, still a bit confused. Say we have two basic blocks: A and B. B 
> has a label. There is no branch/control flow instructions explicit uses 
> B. like this:
> A: code sequence does not contain br/other control flow instruction
> B:
>  lable_of_b:
>     code sequence
> Is A still a predecessor of B?
> Thanks.
> 
> Chris Lattner wrote:
> 
> > On Thu, 13 Jan 2005, Zhou Feng wrote:
> >
> >> hi,
> >> I'm a bit confused by the pred_begin/end of BasicBlock in CFG.h. I 
> >> cann't understand what is a **use** of a BasicBlock. Also, I have no 
> >> idea of when CFG would be constructed in LLVM.
> >
> >
> > The CFG is always implicit in LLVM.  The two things that "use" 
> > BasicBlocks are branch/control flow instructions and PHI nodes.
> >
> > -Chris
> >
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050112/bfee4369/attachment.sig>


More information about the llvm-dev mailing list