[LLVMdev] CFG leaf node

Seung Jae Lee lee225 at uiuc.edu
Wed Aug 8 09:44:03 PDT 2007


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



More information about the llvm-dev mailing list