]> granicus.if.org Git - llvm/commit
IR: Support parsing numeric block ids, and emit them in textual output.
authorJames Y Knight <jyknight@google.com>
Fri, 22 Mar 2019 18:27:13 +0000 (18:27 +0000)
committerJames Y Knight <jyknight@google.com>
Fri, 22 Mar 2019 18:27:13 +0000 (18:27 +0000)
commit6df50f4718cb47dcd669eabe425917263e4a10f1
treeca278d987cc3b22eb299d3c607a4509af072d90f
parent556dfff610c1b1cfd5b7dfaeaf9ff3ccb90429c0
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"
  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
tests.)

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

  4:
    ret i32 %3
  }

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

Differential Revision: https://reviews.llvm.org/D58548

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356789 91177308-0d34-0410-b5e6-96231b3b80d8
36 files changed:
docs/LangRef.rst
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLParser.h
lib/AsmParser/LLToken.h
lib/IR/AsmWriter.cpp
test/Analysis/DominanceFrontier/new_pm_test.ll
test/Analysis/RegionInfo/cond_loop.ll
test/Analysis/RegionInfo/condition_forward_edge.ll
test/Analysis/RegionInfo/condition_same_exit.ll
test/Analysis/RegionInfo/condition_simple.ll
test/Analysis/RegionInfo/infinite_loop.ll
test/Analysis/RegionInfo/infinite_loop_2.ll
test/Analysis/RegionInfo/infinite_loop_3.ll
test/Analysis/RegionInfo/infinite_loop_4.ll
test/Analysis/RegionInfo/infinite_loop_5_a.ll
test/Analysis/RegionInfo/infinite_loop_5_b.ll
test/Analysis/RegionInfo/infinite_loop_5_c.ll
test/Analysis/RegionInfo/loop_with_condition.ll
test/Analysis/RegionInfo/mix_1.ll
test/Analysis/RegionInfo/paper.ll
test/Assembler/block-labels.ll [new file with mode: 0644]
test/Assembler/invalid-block-label-num.ll [new file with mode: 0644]
test/CodeGen/X86/atomic-pointer.ll
test/Instrumentation/AddressSanitizer/asan-masked-load-store.ll
test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll
test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime.ll
test/Instrumentation/AddressSanitizer/stack_dynamic_alloca.ll
test/Instrumentation/MemorySanitizer/check_access_address.ll
test/Instrumentation/MemorySanitizer/msan_basic.ll
test/Instrumentation/MemorySanitizer/msan_kernel_basic.ll
test/Instrumentation/MemorySanitizer/msan_x86_bts_asm.ll
test/Instrumentation/MemorySanitizer/store-origin.ll
test/Instrumentation/SanitizerCoverage/stack-depth.ll
test/Transforms/GVNHoist/pr36787.ll
test/Transforms/LowerSwitch/2014-06-23-PHIlowering.ll