[LLVMdev] labels commented out

Preston Briggs preston.briggs at gmail.com
Fri Nov 1 12:39:01 PDT 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131101/a3fb5467/attachment.html>


More information about the llvm-dev mailing list