summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/merge-sp-update-lea.ll
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-02-02 20:11:17 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-02-02 20:11:17 +0000
commitb8fb2ba1bb3116d7cf84c3e317968377a690d35a (patch)
treeababc9be7a0728f6b9a65196ced3cf866dbe3838 /llvm/test/CodeGen/X86/merge-sp-update-lea.ll
parent1377fd6781744d5acab9f060c87c22824153cf32 (diff)
downloadbcm5719-llvm-b8fb2ba1bb3116d7cf84c3e317968377a690d35a.tar.gz
bcm5719-llvm-b8fb2ba1bb3116d7cf84c3e317968377a690d35a.zip
[X86] Fix the merging of SP updates in prologue/epilogue insertions.
When the merging was involving LEAs, we were taking the wrong immediate from the list of operands. rdar://problem/24446069 llvm-svn: 259553
Diffstat (limited to 'llvm/test/CodeGen/X86/merge-sp-update-lea.ll')
-rw-r--r--llvm/test/CodeGen/X86/merge-sp-update-lea.ll32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/merge-sp-update-lea.ll b/llvm/test/CodeGen/X86/merge-sp-update-lea.ll
new file mode 100644
index 00000000000..cd2be44e1c0
--- /dev/null
+++ b/llvm/test/CodeGen/X86/merge-sp-update-lea.ll
@@ -0,0 +1,32 @@
+; RUN: llc %s -o - | FileCheck %s
+target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
+target triple = "i386-apple-macosx"
+
+; Check that the merging of SP updates, when LEAs are involved, happen
+; correctly.
+; CHECK-LABEL: useLEA:
+; CHECK: calll L_realloc
+; Make sure that the offset we get here is 8 + 16.
+; We used to have 8 + 1 because we were not reading the right immediate form
+; the LEA instruction.
+; CHECK-NEXT: leal 24(%esp), %esp
+define noalias i8* @useLEA(i8* nocapture %p, i32 %nbytes) #0 {
+entry:
+ %cmp = icmp slt i32 %nbytes, 0
+ br i1 %cmp, label %cond.end.3, label %cond.false
+
+cond.false: ; preds = %entry
+ %tobool = icmp ne i32 %nbytes, 0
+ %cond = select i1 %tobool, i32 %nbytes, i32 1
+ %call = tail call i8* @realloc(i8* %p, i32 %cond)
+ br label %cond.end.3
+
+cond.end.3: ; preds = %entry, %cond.false
+ %cond4 = phi i8* [ %call, %cond.false ], [ null, %entry ]
+ ret i8* %cond4
+}
+
+; Function Attrs: nounwind optsize
+declare noalias i8* @realloc(i8* nocapture, i32)
+
+attributes #0 = { nounwind optsize ssp "disable-tail-calls"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-features"="+lea-sp" }
OpenPOWER on IntegriCloud