[LLVMdev] Why shouldn't function entry blocks have predecessors?
Alistair Lynn
arplynn at gmail.com
Wed Jul 7 23:27:03 PDT 2010
Hello Félix-
Consider the following snippet of IR:
define i32 @foo(i32 %n) nounwind {
entry:
br label %loop
loop:
%loop.n = phi i32 [0, %entry], [%tmp, %loop]
call void @bar() nounwind
%tmp = sub nsw i32 %loop.n, 1
%cmp = icmp eq i32 %tmp, 0
br i1 %cmp, label %exit, label %loop
exit:
ret i32 0
}
declare void @bar() nounwind
Try to merge the blocks "entry" and "loop" and all becomes clear when you hit the phi node.
Alistair
On 8 Jul 2010, at 07:16, Félix Cloutier wrote:
> The title says it all. verifyFunction checks it (Verifier.cpp, line 728).
>
> Why can't BasicBlocks that serve as a function's entry point also have predecessors? What keeps a function from looping back to its beginning?
>
> Félix
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list