BB labels are implicitly assigned based on their position in the function.
This has come up before <
http://thread.gmane.org/gmane.comp.compilers.llvm.devel/62194/>, <
http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/145768/>, r182332.
IIRC the only reason the label is in comments is that syntactically it's
not possible to put a numeric label name there. Otherwise just change
AssemblyWriter::printBasicBlock (in lib/IR/AsmWriter.cpp) to print out a
proper numeric label name instead of putting it in a comment.
-- Sean Silva
On Fri, Nov 1, 2013 at 3:39 PM, Preston Briggs <preston.briggs at
gmail.com>wrote:
> I happened to try building LLVM without assertions today,
> and it changed the form of the LLVM IR that gets generated.
> Typically, I do something like
>
> clang -O -emit-llvm -S Test.c
>
> For source like
>
> typedef struct node {
> struct node *left;
> struct node *right;
> int key;
> } Tree;
>
> int sum(Tree *p) {
> int s = 0;
> if (p) {
> s += sum(p->left);
> s += sum(p->right);
> s += p->key;
> }
> return s;
> }
>
> The resulting Test.s looks like
>
> define i32 @sum(%struct.node* %p) #0 {
> %1 = icmp eq %struct.node* %p, null
> br i1 %1, label %13, label %2
>
> ; <label>:2 ; preds = %0
> %3 = getelementptr inbounds %struct.node* %p, i64 0, i32 0
> %4 = load %struct.node** %3, align 8, !tbaa !0
> %5 = tail call i32 @sum(%struct.node* %4)
> %6 = getelementptr inbounds %struct.node* %p, i64 0, i32 1
> %7 = load %struct.node** %6, align 8, !tbaa !0
> %8 = tail call i32 @sum(%struct.node* %7)
> %9 = add nsw i32 %8, %5
> %10 = getelementptr inbounds %struct.node* %p, i64 0, i32 2
> %11 = load i32* %10, align 4, !tbaa !3
> %12 = add nsw i32 %9, %11
> ret i32 %12
>
> ; <label>:13 ; preds = %0
> ret i32 0
> }
>
>
> Note that labels %2 and %13 are not actually defined, though they're
both
> referred to by the first branch and in comments.
>
> What's the deal?
>
> Thanks,
> Preston
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20131102/ca8dcdd1/attachment.html>