CFG leaf node

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CFG leaf node

Seung Jae Lee
Hi, guys.
Is there any easy way to know the leaf BB node in the CFG  which is not terminated by such a 'br' instruction?

E.g., for the following LLVM assembly:
-----------------------------------------------------------
int %foo2(int %k) {
entry:
        br label %bb

bb:             ; preds = %bb, %entry
        %indvar = phi uint [ 0, %entry ], [ %indvar.next, %bb ]         ; <uint> [#uses=2]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=2]
        %exitcond = seteq uint %indvar.next, 25         ; <bool> [#uses=1]
        br bool %exitcond, label %bb6, label %bb

bb6:            ; preds = %bb
        %n.0.0 = cast uint %indvar to int               ; <int> [#uses=1]
        %k_addr.0.0 = add int %n.0.0, %k                ; <int> [#uses=1]
        %tmp1 = add int %k_addr.0.0, 1          ; <int> [#uses=1]
        ret int %tmp1
}
-----------------------------------------------------------

Is there any way to figure out very quickly that 'bb6' basic block has no child in CFG without any checking process the last terminating instruction is not 'br'?

Thanks,
Seung J Lee
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: CFG leaf node

Devang Patel

On Aug 8, 2007, at 9:44 AM, Seung Jae Lee wrote:

Is there any way to figure out very quickly that 'bb6' basic block has no child in CFG without any checking process the last terminating instruction is not 'br'?


Check successor iterator.  

if (succ_begin(BB) == succ_end(BB))
BB has no successor in CFG.

See include/llvm/Support/CFG.h for more info.

-
Devang

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev