[llvm] r351146 - [X86] Avoid clobbering ESP/RSP in the epilogue.
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 14 17:24:18 PST 2019
Author: rnk
Date: Mon Jan 14 17:24:18 2019
New Revision: 351146
URL: http://llvm.org/viewvc/llvm-project?rev=351146&view=rev
Log:
[X86] Avoid clobbering ESP/RSP in the epilogue.
Summary:
In r345197 ESP and RSP were added to GR32_TC/GR64_TC, allowing them to
be used for tail calls, but this also caused `findDeadCallerSavedReg` to
think they were acceptable targets for clobbering. Filter them out.
Fixes PR40289.
Patch by Geoffry Song!
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D56617
Added:
llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll
llvm/trunk/test/CodeGen/X86/pr40289.ll
Modified:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=351146&r1=351145&r2=351146&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Jan 14 17:24:18 2019
@@ -185,7 +185,8 @@ static unsigned findDeadCallerSavedReg(M
}
for (auto CS : AvailableRegs)
- if (!Uses.count(CS) && CS != X86::RIP)
+ if (!Uses.count(CS) && CS != X86::RIP && CS != X86::RSP &&
+ CS != X86::ESP)
return CS;
}
}
Added: llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll?rev=351146&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll Mon Jan 14 17:24:18 2019
@@ -0,0 +1,10 @@
+; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s
+
+define cc 92 < 9 x i64 > @clobber() {
+ %1 = alloca i64
+ %2 = load volatile i64, i64* %1
+ ret < 9 x i64 > undef
+ ; CHECK-LABEL: clobber:
+ ; CHECK-NOT: popq %rsp
+ ; CHECK: addq $8, %rsp
+}
Added: llvm/trunk/test/CodeGen/X86/pr40289.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr40289.ll?rev=351146&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr40289.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr40289.ll Mon Jan 14 17:24:18 2019
@@ -0,0 +1,10 @@
+; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s
+
+define < 3 x i32 > @clobber() {
+ %1 = alloca i32
+ %2 = load volatile i32, i32* %1
+ ret < 3 x i32 > undef
+ ; CHECK-LABEL: clobber:
+ ; CHECK-NOT: popl %esp
+ ; CHECK: addl $4, %esp
+}
More information about the llvm-commits
mailing list