summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/Thumb/stack-access.ll
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2015-03-20 17:20:07 +0000
committerJohn Brawn <john.brawn@arm.com>2015-03-20 17:20:07 +0000
commit1f26a47630b190056716b0a3ba062f230d255bcf (patch)
tree2f82b305f0a989ea7a1293659f668f21990b1e5b /llvm/test/CodeGen/Thumb/stack-access.ll
parentc403a1ce323b9a20fcfd928152da8c59321d2a75 (diff)
downloadbcm5719-llvm-1f26a47630b190056716b0a3ba062f230d255bcf.tar.gz
bcm5719-llvm-1f26a47630b190056716b0a3ba062f230d255bcf.zip
[ARM] Fix handling of thumb1 out-of-range frame offsets
LocalStackSlotPass assumes that isFrameOffsetLegal doesn't change its answer when the base register changes. Unfortunately this isn't true in thumb1, where SP-based loads allow a larger offset than non-SP-based loads, and this causes the base register reuse code to generate instructions that are unencodable, causing an assertion failure. Solve this by adding a BaseReg parameter to isFrameOffsetLegal, which ARMBaseRegisterInfo can then make use of to give the correct answer. Differential Revision: http://reviews.llvm.org/D8419 llvm-svn: 232825
Diffstat (limited to 'llvm/test/CodeGen/Thumb/stack-access.ll')
-rw-r--r--llvm/test/CodeGen/Thumb/stack-access.ll37
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/Thumb/stack-access.ll b/llvm/test/CodeGen/Thumb/stack-access.ll
index bc5ecc10b4d..fded4104207 100644
--- a/llvm/test/CodeGen/Thumb/stack-access.ll
+++ b/llvm/test/CodeGen/Thumb/stack-access.ll
@@ -88,3 +88,40 @@ define void @test7() {
ret void
}
+
+; Check that loads/stores with out-of-range offsets are handled correctly
+define void @test8() {
+ %arr3 = alloca [224 x i32], align 4
+ %arr2 = alloca [224 x i32], align 4
+ %arr1 = alloca [224 x i32], align 4
+
+; CHECK: movs [[REG:r[0-9]+]], #1
+; CHECK: str [[REG]], [sp]
+ %arr1idx1 = getelementptr inbounds [224 x i32], [224 x i32]* %arr1, i32 0, i32 0
+ store i32 1, i32* %arr1idx1, align 4
+
+; Offset in range for sp-based store, but not for non-sp-based store
+; CHECK: str [[REG]], [sp, #128]
+ %arr1idx2 = getelementptr inbounds [224 x i32], [224 x i32]* %arr1, i32 0, i32 32
+ store i32 1, i32* %arr1idx2, align 4
+
+; CHECK: str [[REG]], [sp, #896]
+ %arr2idx1 = getelementptr inbounds [224 x i32], [224 x i32]* %arr2, i32 0, i32 0
+ store i32 1, i32* %arr2idx1, align 4
+
+; %arr2 is in range, but this element of it is not
+; CHECK: str [[REG]], [{{r[0-9]+}}]
+ %arr2idx2 = getelementptr inbounds [224 x i32], [224 x i32]* %arr2, i32 0, i32 32
+ store i32 1, i32* %arr2idx2, align 4
+
+; %arr3 is not in range
+; CHECK: str [[REG]], [{{r[0-9]+}}]
+ %arr3idx1 = getelementptr inbounds [224 x i32], [224 x i32]* %arr3, i32 0, i32 0
+ store i32 1, i32* %arr3idx1, align 4
+
+; CHECK: str [[REG]], [{{r[0-9]+}}]
+ %arr3idx2 = getelementptr inbounds [224 x i32], [224 x i32]* %arr3, i32 0, i32 32
+ store i32 1, i32* %arr3idx2, align 4
+
+ ret void
+}
OpenPOWER on IntegriCloud