summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2011-01-11 00:16:04 +0000
committerEric Christopher <echristo@apple.com>2011-01-11 00:16:04 +0000
commit3904343c68926f1ed8250e4a9b0863868f1ffb74 (patch)
tree28410e2017bbd22e8783d802c65349c55a42de20 /llvm/test/CodeGen
parentbd4520b53523634d20bb56bb40a40d56125260fe (diff)
downloadbcm5719-llvm-3904343c68926f1ed8250e4a9b0863868f1ffb74.tar.gz
bcm5719-llvm-3904343c68926f1ed8250e4a9b0863868f1ffb74.zip
Even if we don't have 7 bytes of stack space we may need to save and
restore the stack pointer from the frame pointer on thumbv6. Fixes rdar://8819685 llvm-svn: 123196
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/ARM/thumb1-varalloc.ll40
1 files changed, 40 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/thumb1-varalloc.ll b/llvm/test/CodeGen/ARM/thumb1-varalloc.ll
new file mode 100644
index 00000000000..25093fee225
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/thumb1-varalloc.ll
@@ -0,0 +1,40 @@
+; RUN: llc < %s -mtriple=thumbv6-apple-darwin | FileCheck %s
+; rdar://8819685
+
+@__bar = external hidden global i8*
+@__baz = external hidden global i8*
+
+define i8* @_foo() {
+entry:
+; CHECK: foo:
+
+ %size = alloca i32, align 4
+ %0 = load i8** @__bar, align 4
+ %1 = icmp eq i8* %0, null
+ br i1 %1, label %bb1, label %bb3
+
+bb1:
+ store i32 1026, i32* %size, align 4
+ %2 = alloca [1026 x i8], align 1
+; CHECK: mov r0, sp
+; CHECK: adds r4, r0, r4
+ %3 = getelementptr inbounds [1026 x i8]* %2, i32 0, i32 0
+ %4 = call i32 @_called_func(i8* %3, i32* %size) nounwind
+ %5 = icmp eq i32 %4, 0
+ br i1 %5, label %bb2, label %bb3
+
+bb2:
+ %6 = call i8* @strdup(i8* %3) nounwind
+ store i8* %6, i8** @__baz, align 4
+ br label %bb3
+
+bb3:
+ %.0 = phi i8* [ %0, %entry ], [ %6, %bb2 ], [ %3, %bb1 ]
+; CHECK: subs r4, #5
+; CHECK-NEXT: mov sp, r4
+; CHECK-NEXT: pop {r4, r5, r6, r7, pc}
+ ret i8* %.0
+}
+
+declare noalias i8* @strdup(i8* nocapture) nounwind
+declare i32 @_called_func(i8*, i32*) nounwind \ No newline at end of file
OpenPOWER on IntegriCloud