summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-04-13 23:08:27 +0000
committerTim Northover <tnorthover@apple.com>2016-04-13 23:08:27 +0000
commit5c02f9ad28b02eccd04e10c5c1574b97bc9564fb (patch)
tree98b42b7e983290bee0005a611558888fec73b487 /llvm/test/Transforms
parent2a734db7d3418cae537c63337d77243a22b2db81 (diff)
downloadbcm5719-llvm-5c02f9ad28b02eccd04e10c5c1574b97bc9564fb.tar.gz
bcm5719-llvm-5c02f9ad28b02eccd04e10c5c1574b97bc9564fb.zip
ARM: override cost function to re-enable ConstantHoisting (& fix it).
At some point, ARM stopped getting any benefit from ConstantHoisting because the pass called a different variant of getIntImmCost. Reimplementing the correct variant revealed some problems, however: + ConstantHoisting was modifying switch statements. This is simply invalid, the cases must remain integer constants no matter the notional cost. + ConstantHoisting was mangling alloca instructions in the entry block. These should be handled by FrameLowering, so constants actually have a cost of 0. Worse, the resulting bitcasts meant they became dynamic allocas. rdar://25707382 llvm-svn: 266260
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll47
-rw-r--r--llvm/test/Transforms/ConstantHoisting/ARM/lit.local.cfg2
2 files changed, 49 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll
new file mode 100644
index 00000000000..3602eb9f3fd
--- /dev/null
+++ b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll
@@ -0,0 +1,47 @@
+; RUN: opt -consthoist -S < %s | FileCheck %s
+target triple = "thumbv6m-none-eabi"
+
+; Allocas in the entry block get handled (for free) by
+; prologue/epilogue. Elsewhere they're fair game though.
+define void @avoid_allocas() {
+; CHECK-LABEL: @avoid_allocas
+; CHECK: %addr1 = alloca i8, i32 1000
+; CHECK: %addr2 = alloca i8, i32 1020
+
+ %addr1 = alloca i8, i32 1000
+ %addr2 = alloca i8, i32 1020
+ br label %elsewhere
+
+elsewhere:
+; CHECK: [[BASE:%.*]] = bitcast i32 1000 to i32
+; CHECK: alloca i8, i32 [[BASE]]
+; CHECK: [[NEXT:%.*]] = add i32 [[BASE]], 20
+; CHECK: alloca i8, i32 [[NEXT]]
+
+ %addr3 = alloca i8, i32 1000
+ %addr4 = alloca i8, i32 1020
+
+ ret void
+}
+
+; The case values of switch instructions are required to be constants.
+define void @avoid_switch(i32 %in) {
+; CHECK-LABEL: @avoid_switch
+; CHECK: switch i32 %in, label %default [
+; CHECK: i32 1000, label %bb1
+; CHECK: i32 1020, label %bb2
+; CHECK: ]
+
+ switch i32 %in, label %default
+ [ i32 1000, label %bb1
+ i32 1020, label %bb2 ]
+
+bb1:
+ ret void
+
+bb2:
+ ret void
+
+default:
+ ret void
+}
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/lit.local.cfg b/llvm/test/Transforms/ConstantHoisting/ARM/lit.local.cfg
new file mode 100644
index 00000000000..236e1d34416
--- /dev/null
+++ b/llvm/test/Transforms/ConstantHoisting/ARM/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'ARM' in config.root.targets:
+ config.unsupported = True
OpenPOWER on IntegriCloud