<div dir="ltr">In LLVM, every block must explicitly specify how control flows out of that block, the order that blocks are printed to text / bitcode has no effect on the control flow whatsoever. <br>The label forces the creation of a second block, so the first one must end with a branch to it. Since there's only one code path, LLVM will later merge the two blocks together.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 6, 2014 at 11:32 PM, Rouxel Benjamin <span dir="ltr"><<a href="mailto:benjamin.rouxel@inria.fr" target="_blank">benjamin.rouxel@inria.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
So finally I found where the label was evicted. In case it's useful for someone, i needed to add: "Dest.getBlock()->setName(D->getName());" in CGStmt.cpp:360.<br>
<br>
About the creation of the BasicBlock, It's in the same method, but as expected it's removed with optimization (O1,O2,O3) and the label name is kept trough CFG optimizations.<br>
<br>
Cheers,<br>
Benjamin Rouxel<br>
<br>
Le Fri, 6 Jun 2014 10:23:21 +0200,<br>
Rouxel Benjamin <<a href="mailto:benjamin.rouxel@inria.fr">benjamin.rouxel@inria.fr</a>> a écrit :<br>
<div class="HOEnZb"><div class="h5"><br>
> Hi,<br>
><br>
> I have some troubles to figure out why clang is removing my label name. As the simple example below shows the label "MLB" is removed and replaced by an integer as an "unnamed value".<br>
> Plus, I can see that an unconditional jump is added, as the label seems to be interpreted as the beginning of a BasicBlock. I am compiling without any optimizations (for now), what leave the produced code slower than the input one.<br>

><br>
> Anyway, the important thinks to me is to keep label name, but I can't figure out where in the code this transformation is done. My guess is, it's done by Clang while parsing, or just after. Could someone gives me some clue about the class/method where this "feature" is ?<br>

><br>
> Input:<br>
> int main() {<br>
>     int i=0;<br>
> MLB:<br>
>     return i;<br>
> }<br>
><br>
> Result:<br>
> define i32 @main() #0 {<br>
>   %1 = alloca i32, align 4<br>
>   %i = alloca i32, align 4<br>
>   store i32 0, i32* %1<br>
>   store i32 0, i32* %i, align 4<br>
>   br label %2<br>
><br>
> ; <label>:2                                       ; preds = %0<br>
>   %3 = load i32* %i, align 4<br>
>   ret i32 %3<br>
> }<br>
><br>
> ---------------------------------------------------<br>
> % clang --version<br>
> clang version 3.4 (branches/release_34)<br>
> Target: x86_64-unknown-linux-gnu<br>
> Thread model: posix<br>
><br>
> % clang -O0 -emit-llvm -mllvm -debug-pass=Structure -S -c -o /dev/stdout main.c<br>
><br>
> Thanks for you help<br>
> Benjamin Rouxel<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>