Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
IR: Support parsing numeric block ids, and emit them in textual output.
Just as as llvm IR supports explicitly specifying numeric value ids
for instructions, and emits them by default in textual output, now do
the same for blocks.

This is a slightly incompatible change in the textual IR format.

Previously, llvm would parse numeric labels as string names. E.g.
  define void @f() {
    br label %"55"
    ret void
defined a label *named* "55", even without needing to be quoted, while
the reference required quoting. Now, if you intend a block label which
looks like a value number to be a name, you must quote it in the
definition too (e.g. `"55":`).

Previously, llvm would print nameless blocks only as a comment, and
would omit it if there was no predecessor. This could cause confusion
for readers of the IR, just as unnamed instructions did prior to the
addition of "%5 = " syntax, back in 2008 (PR2480).

Now, it will always print a label for an unnamed block, with the
exception of the entry block. (IMO it may be better to print it for
the entry-block as well. However, that requires updating many more

Thus, the following is supported, and is the canonical printing:
  define i32 @f(i32, i32) {
    %3 = add i32 %0, %1
    br label %4

    ret i32 %3

New test cases covering this behavior are added, and other tests
updated as required.

Differential Revision:

git-svn-id: 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jyknight committed Mar 22, 2019
1 parent 4d96307 commit bf6f0a60fce176b4e2e0b7e186e0bc931110975f
Showing with 1 addition and 1 deletion.
  1. +1 −1 test/irgen/imports.go
@@ -13,7 +13,7 @@ var X interface{}
// CHECK-NEXT: %[[N:.*]] = load i1, i1* @"init$guard"
// CHECK-NEXT: br i1 %[[N]], label %{{.*}}, label %[[L:.*]]

// CHECK: ; <label>:[[L]]
// CHECK: [[L]]:
// CHECK-NEXT: call void @__go_register_gc_roots
// CHECK-NEXT: store i1 true, i1* @"init$guard"
// CHECK-NEXT: call void @fmt..import(i8* undef)

0 comments on commit bf6f0a6

Please sign in to comment.