[llvm-branch-commits] [llvm-branch] r236302 - Merging r227503:
Tom Stellard
thomas.stellard at amd.com
Thu Apr 30 19:43:11 PDT 2015
Author: tstellar
Date: Thu Apr 30 21:43:11 2015
New Revision: 236302
URL: http://llvm.org/viewvc/llvm-project?rev=236302&view=rev
Log:
Merging r227503:
------------------------------------------------------------------------
r227503 | reid | 2015-01-29 17:33:00 -0500 (Thu, 29 Jan 2015) | 11 lines
Update comments to use unreachable instead of llvm.trap, as implemented now
win64: Call __chkstk through a register with the large code model
Fixes half of PR18582. True dynamic allocas will still have a
CALL64pcrel32 which will fail.
Reviewers: majnemer
Differential Revision: http://reviews.llvm.org/D7267
------------------------------------------------------------------------
Modified:
llvm/branches/release_36/lib/Target/X86/X86FrameLowering.cpp
llvm/branches/release_36/lib/Target/X86/X86FrameLowering.h
llvm/branches/release_36/lib/Target/X86/X86InstrControl.td
llvm/branches/release_36/test/CodeGen/X86/win_chkstk.ll
Modified: llvm/branches/release_36/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/Target/X86/X86FrameLowering.cpp?rev=236302&r1=236301&r2=236302&view=diff
==============================================================================
--- llvm/branches/release_36/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/branches/release_36/lib/Target/X86/X86FrameLowering.cpp Thu Apr 30 21:43:11 2015
@@ -375,10 +375,16 @@ static bool usesTheStack(const MachineFu
return false;
}
-void X86FrameLowering::getStackProbeFunction(const X86Subtarget &STI,
+void X86FrameLowering::getStackProbeFunction(const MachineFunction &MF,
+ const X86Subtarget &STI,
unsigned &CallOp,
const char *&Symbol) {
- CallOp = STI.is64Bit() ? X86::W64ALLOCA : X86::CALLpcrel32;
+ if (STI.is64Bit())
+ CallOp = MF.getTarget().getCodeModel() == CodeModel::Large
+ ? X86::CALL64r
+ : X86::W64ALLOCA;
+ else
+ CallOp = X86::CALLpcrel32;
if (STI.is64Bit()) {
if (STI.isTargetCygMing()) {
@@ -725,7 +731,7 @@ void X86FrameLowering::emitPrologue(Mach
const char *StackProbeSymbol;
unsigned CallOp;
- getStackProbeFunction(STI, CallOp, StackProbeSymbol);
+ getStackProbeFunction(MF, STI, CallOp, StackProbeSymbol);
// Check whether EAX is livein for this function.
bool isEAXAlive = isEAXLiveIn(MF);
@@ -755,12 +761,23 @@ void X86FrameLowering::emitPrologue(Mach
.setMIFlag(MachineInstr::FrameSetup);
}
- BuildMI(MBB, MBBI, DL,
- TII.get(CallOp))
- .addExternalSymbol(StackProbeSymbol)
- .addReg(StackPtr, RegState::Define | RegState::Implicit)
- .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
- .setMIFlag(MachineInstr::FrameSetup);
+ if (Is64Bit && MF.getTarget().getCodeModel() == CodeModel::Large) {
+ // For the large code model, we have to call through a register. Use R11,
+ // as it is unused and clobbered by all probe functions.
+ BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::R11)
+ .addExternalSymbol(StackProbeSymbol);
+ BuildMI(MBB, MBBI, DL, TII.get(CallOp))
+ .addReg(X86::R11)
+ .addReg(StackPtr, RegState::Define | RegState::Implicit)
+ .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
+ .setMIFlag(MachineInstr::FrameSetup);
+ } else {
+ BuildMI(MBB, MBBI, DL, TII.get(CallOp))
+ .addExternalSymbol(StackProbeSymbol)
+ .addReg(StackPtr, RegState::Define | RegState::Implicit)
+ .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
+ .setMIFlag(MachineInstr::FrameSetup);
+ }
if (Is64Bit) {
// MSVC x64's __chkstk and cygwin/mingw's ___chkstk_ms do not adjust %rsp
Modified: llvm/branches/release_36/lib/Target/X86/X86FrameLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/Target/X86/X86FrameLowering.h?rev=236302&r1=236301&r2=236302&view=diff
==============================================================================
--- llvm/branches/release_36/lib/Target/X86/X86FrameLowering.h (original)
+++ llvm/branches/release_36/lib/Target/X86/X86FrameLowering.h Thu Apr 30 21:43:11 2015
@@ -27,8 +27,8 @@ public:
explicit X86FrameLowering(StackDirection D, unsigned StackAl, int LAO)
: TargetFrameLowering(StackGrowsDown, StackAl, LAO) {}
- static void getStackProbeFunction(const X86Subtarget &STI,
- unsigned &CallOp,
+ static void getStackProbeFunction(const MachineFunction &MF,
+ const X86Subtarget &STI, unsigned &CallOp,
const char *&Symbol);
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
Modified: llvm/branches/release_36/lib/Target/X86/X86InstrControl.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/Target/X86/X86InstrControl.td?rev=236302&r1=236301&r2=236302&view=diff
==============================================================================
--- llvm/branches/release_36/lib/Target/X86/X86InstrControl.td (original)
+++ llvm/branches/release_36/lib/Target/X86/X86InstrControl.td Thu Apr 30 21:43:11 2015
@@ -279,7 +279,8 @@ let isCall = 1, Uses = [RSP], SchedRW =
}
let isCall = 1, isCodeGenOnly = 1 in
- // __chkstk(MSVC): clobber R10, R11 and EFLAGS.
+ // __chkstk(MSVC): clobber R10, R11 and EFLAGS
+ // ___chkstk_ms(Mingw64): clobber R10, R11 and EFLAGS
// ___chkstk(Mingw64): clobber R10, R11, RAX and EFLAGS, and update RSP.
let Defs = [RAX, R10, R11, RSP, EFLAGS],
Uses = [RSP] in {
Modified: llvm/branches/release_36/test/CodeGen/X86/win_chkstk.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/CodeGen/X86/win_chkstk.ll?rev=236302&r1=236301&r2=236302&view=diff
==============================================================================
--- llvm/branches/release_36/test/CodeGen/X86/win_chkstk.ll (original)
+++ llvm/branches/release_36/test/CodeGen/X86/win_chkstk.ll Thu Apr 30 21:43:11 2015
@@ -1,5 +1,6 @@
; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=WIN_X32
; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=WIN_X64
+; RUN: llc < %s -mtriple=x86_64-pc-win32 -code-model=large | FileCheck %s -check-prefix=WIN64_LARGE
; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X32
; RUN: llc < %s -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X64
; RUN: llc < %s -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX
@@ -16,6 +17,8 @@ define i32 @main4k() nounwind {
entry:
; WIN_X32: calll __chkstk
; WIN_X64: callq __chkstk
+; WIN64_LARGE: movabsq $__chkstk, %r11
+; WIN64_LARGE: callq *%r11
; MINGW_X32: calll __alloca
; MINGW_X64: callq ___chkstk_ms
; LINUX-NOT: call __chkstk
@@ -52,6 +55,8 @@ define x86_64_win64cc i32 @main4k_win64(
entry:
; WIN_X32: calll __chkstk
; WIN_X64: callq __chkstk
+; WIN64_LARGE: movabsq $__chkstk, %r11
+; WIN64_LARGE: callq *%r11
; MINGW_X32: calll __alloca
; MINGW_X64: callq ___chkstk_ms
; LINUX-NOT: call __chkstk
More information about the llvm-branch-commits
mailing list