[LLVMdev] CFG entry and exit blocks

Trevor Harmon Trevor.W.Harmon at nasa.gov
Tue Mar 30 18:00:31 PDT 2010


Hi,

I'm confused about the entry and exit blocks of an LLVM CFG. I  
understand that every CFG has one and only one entry block, and this  
is confirmed by the existence of the getEntryBlock function in the  
Function class.

But what about exit (a.k.a. return) blocks? At first I assumed that  
LLVM CFGs have one and only one exit block, too, but the following  
code is a counter-example:

int simple(int j) {
     try {
         if (j > 50) throw 100;
     } catch (int status) {
         j++;
     }

     return j;
}

This produces the CFG shown in the attachment, which appears to have 3  
exit blocks. At least, there are 3 blocks with no successors. (I don't  
yet understand the semantics of the "invcont" and "Unwind" blocks, so  
perhaps I'm misunderstanding something here.)

Anyway, given this code, how would one identify the "real" exit block  
(the one labeled "return")? Obviously I can't just search for the  
block without successors because there are 3 of them.

Thanks,

Trevor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg._Z6simplei.dot
Type: application/octet-stream
Size: 4665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100330/9a780a4f/attachment.obj>
-------------- next part --------------



More information about the llvm-dev mailing list