summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/MIR
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-05-05 21:09:30 +0000
committerMatthias Braun <matze@braunis.de>2017-05-05 21:09:30 +0000
commit8940114f61e345ae65e7be9c43a8ed1cfb7f60b8 (patch)
tree41648110b3685e3936320b1f361a07015553a990 /llvm/test/CodeGen/MIR
parentf7ca8fcd6a177c1143591d6b459ff0933f4fb8b6 (diff)
downloadbcm5719-llvm-8940114f61e345ae65e7be9c43a8ed1cfb7f60b8.tar.gz
bcm5719-llvm-8940114f61e345ae65e7be9c43a8ed1cfb7f60b8.zip
MIParser/MIRPrinter: Compute block successors if not explicitely specified
- MIParser: If the successor list is not specified successors will be added based on basic block operands in the block and possible fallthrough. - MIRPrinter: Adds a new `simplify-mir` option, with that option set: Skip printing of block successor lists in cases where the parser is guaranteed to reconstruct it. This means we still print the list if some successor cannot be determined (happens for example for jump tables), if the successor order changes or branch probabilities being unequal. Differential Revision: https://reviews.llvm.org/D31262 llvm-svn: 302289
Diffstat (limited to 'llvm/test/CodeGen/MIR')
-rw-r--r--llvm/test/CodeGen/MIR/Generic/branch-probabilities.ll28
-rw-r--r--llvm/test/CodeGen/MIR/X86/auto-successor.mir61
-rw-r--r--llvm/test/CodeGen/MIR/X86/branch-probabilities.mir18
-rw-r--r--llvm/test/CodeGen/MIR/X86/successor-basic-blocks.mir1
4 files changed, 79 insertions, 29 deletions
diff --git a/llvm/test/CodeGen/MIR/Generic/branch-probabilities.ll b/llvm/test/CodeGen/MIR/Generic/branch-probabilities.ll
deleted file mode 100644
index 8d119316b13..00000000000
--- a/llvm/test/CodeGen/MIR/Generic/branch-probabilities.ll
+++ /dev/null
@@ -1,28 +0,0 @@
-; RUN: llc -stop-after machine-sink %s -o %t.mir
-; RUN: FileCheck %s < %t.mir
-; RUN: llc %t.mir -run-pass machine-sink
-; Check that branch probabilities are printed in a format that can then be parsed.
-; This test fails on powerpc because of an undefined physical register use in the MIR. See PR31062.
-; XFAIL: powerpc
-
-declare void @foo()
-declare void @bar()
-
-define void @test(i1 %c) {
-; CHECK-LABEL: name: test
-entry:
- br i1 %c, label %then, label %else
-
-then:
- call void @foo()
- br label %end
-; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}}), %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
-
-else:
- call void @bar()
- br label %end
-; CHECK: successors: %{{[a-z0-9\-\.]+}}({{0x[0-9a-f]+}})
-
-end:
- ret void
-}
diff --git a/llvm/test/CodeGen/MIR/X86/auto-successor.mir b/llvm/test/CodeGen/MIR/X86/auto-successor.mir
new file mode 100644
index 00000000000..d1b59c35f1e
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/X86/auto-successor.mir
@@ -0,0 +1,61 @@
+# RUN: llc -o - %s -run-pass=none -verify-machineinstrs -simplify-mir | FileCheck %s
+---
+# We shouldn't need any explicit successor lists in these examples
+# CHECK-LABEL: name: func0
+# CHECK: bb.0:
+# CHECK-NOT: successors
+# CHECK: JE_1 %bb.1, implicit undef %eflags
+# CHECK: JMP_1 %bb.3
+# CHECK: bb.1:
+# CHECK-NOT: successors
+# CHECK: bb.2:
+# CHECK-NOT: successors
+# CHECK: JE_1 %bb.1, implicit undef %eflags
+# CHECK: bb.3:
+# CHECK: RETQ undef %eax
+name: func0
+body: |
+ bb.0:
+ JE_1 %bb.1, implicit undef %eflags
+ JMP_1 %bb.3
+
+ bb.1:
+
+ bb.2:
+ JE_1 %bb.1, implicit undef %eflags
+
+ bb.3:
+ JE_1 %bb.4, implicit undef %eflags ; condjump+fallthrough to same block
+
+ bb.4:
+ RETQ undef %eax
+...
+---
+# Some cases that need explicit successors:
+# CHECK-LABEL: name: func1
+name: func1
+body: |
+ bb.0:
+ ; CHECK: bb.0:
+ ; CHECK: successors: %bb.3, %bb.1
+ successors: %bb.3, %bb.1 ; different order than operands
+ JE_1 %bb.1, implicit undef %eflags
+ JMP_1 %bb.3
+
+ bb.1:
+ ; CHECK: bb.1:
+ ; CHECK: successors: %bb.2, %bb.1
+ successors: %bb.2, %bb.1 ; different order (fallthrough variant)
+ JE_1 %bb.1, implicit undef %eflags
+
+ bb.2:
+ ; CHECK: bb.2:
+ ; CHECK: successors: %bb.1(0x60000000), %bb.3(0x20000000)
+ successors: %bb.1(3), %bb.3(1) ; branch probabilities not normalized
+ JE_1 %bb.1, implicit undef %eflags
+
+ bb.3:
+ ; CHECK: bb.3:
+ ; CHECK: RETQ undef %eax
+ RETQ undef %eax
+...
diff --git a/llvm/test/CodeGen/MIR/X86/branch-probabilities.mir b/llvm/test/CodeGen/MIR/X86/branch-probabilities.mir
new file mode 100644
index 00000000000..4aacd2d5cef
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/X86/branch-probabilities.mir
@@ -0,0 +1,18 @@
+# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=none | FileCheck %s
+---
+# Check that branch probabilities are printed correctly as hex numbers.
+# CHECK-LABEL: name: test
+# CHECK: bb.0:
+# CHECK-NEXT: successors: %bb.1(0x66666666), %bb.2(0x1999999a)
+name: test
+body: |
+ bb.0:
+ successors: %bb.1(4), %bb.2(1)
+ JE_1 %bb.2, implicit undef %eflags
+
+ bb.1:
+ NOOP
+
+ bb.2:
+ RETQ undef %eax
+...
diff --git a/llvm/test/CodeGen/MIR/X86/successor-basic-blocks.mir b/llvm/test/CodeGen/MIR/X86/successor-basic-blocks.mir
index 395272bb23c..ffeb04af9e4 100644
--- a/llvm/test/CodeGen/MIR/X86/successor-basic-blocks.mir
+++ b/llvm/test/CodeGen/MIR/X86/successor-basic-blocks.mir
@@ -32,7 +32,6 @@
name: foo
body: |
; CHECK-LABEL: bb.0.entry:
- ; CHECK: successors: %bb.1.less(0x40000000), %bb.2.exit(0x40000000)
; CHECK-LABEL: bb.1.less:
bb.0.entry:
successors: %bb.1.less, %bb.2.exit
OpenPOWER on IntegriCloud