llvm.org GIT mirror llvm / d0505d6
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@236302 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 4 years ago
4 changed file(s) with 35 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
374374 return false;
375375 }
376376
377 void X86FrameLowering::getStackProbeFunction(const X86Subtarget &STI,
377 void X86FrameLowering::getStackProbeFunction(const MachineFunction &MF,
378 const X86Subtarget &STI,
378379 unsigned &CallOp,
379380 const char *&Symbol) {
380 CallOp = STI.is64Bit() ? X86::W64ALLOCA : X86::CALLpcrel32;
381 if (STI.is64Bit())
382 CallOp = MF.getTarget().getCodeModel() == CodeModel::Large
383 ? X86::CALL64r
384 : X86::W64ALLOCA;
385 else
386 CallOp = X86::CALLpcrel32;
381387
382388 if (STI.is64Bit()) {
383389 if (STI.isTargetCygMing()) {
724730 const char *StackProbeSymbol;
725731 unsigned CallOp;
726732
727 getStackProbeFunction(STI, CallOp, StackProbeSymbol);
733 getStackProbeFunction(MF, STI, CallOp, StackProbeSymbol);
728734
729735 // Check whether EAX is livein for this function.
730736 bool isEAXAlive = isEAXLiveIn(MF);
754760 .setMIFlag(MachineInstr::FrameSetup);
755761 }
756762
757 BuildMI(MBB, MBBI, DL,
758 TII.get(CallOp))
759 .addExternalSymbol(StackProbeSymbol)
760 .addReg(StackPtr, RegState::Define | RegState::Implicit)
761 .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
762 .setMIFlag(MachineInstr::FrameSetup);
763 if (Is64Bit && MF.getTarget().getCodeModel() == CodeModel::Large) {
764 // For the large code model, we have to call through a register. Use R11,
765 // as it is unused and clobbered by all probe functions.
766 BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::R11)
767 .addExternalSymbol(StackProbeSymbol);
768 BuildMI(MBB, MBBI, DL, TII.get(CallOp))
769 .addReg(X86::R11)
770 .addReg(StackPtr, RegState::Define | RegState::Implicit)
771 .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
772 .setMIFlag(MachineInstr::FrameSetup);
773 } else {
774 BuildMI(MBB, MBBI, DL, TII.get(CallOp))
775 .addExternalSymbol(StackProbeSymbol)
776 .addReg(StackPtr, RegState::Define | RegState::Implicit)
777 .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
778 .setMIFlag(MachineInstr::FrameSetup);
779 }
763780
764781 if (Is64Bit) {
765782 // MSVC x64's __chkstk and cygwin/mingw's ___chkstk_ms do not adjust %rsp
2626 explicit X86FrameLowering(StackDirection D, unsigned StackAl, int LAO)
2727 : TargetFrameLowering(StackGrowsDown, StackAl, LAO) {}
2828
29 static void getStackProbeFunction(const X86Subtarget &STI,
30 unsigned &CallOp,
29 static void getStackProbeFunction(const MachineFunction &MF,
30 const X86Subtarget &STI, unsigned &CallOp,
3131 const char *&Symbol);
3232
3333 void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
278278 }
279279
280280 let isCall = 1, isCodeGenOnly = 1 in
281 // __chkstk(MSVC): clobber R10, R11 and EFLAGS.
281 // __chkstk(MSVC): clobber R10, R11 and EFLAGS
282 // ___chkstk_ms(Mingw64): clobber R10, R11 and EFLAGS
282283 // ___chkstk(Mingw64): clobber R10, R11, RAX and EFLAGS, and update RSP.
283284 let Defs = [RAX, R10, R11, RSP, EFLAGS],
284285 Uses = [RSP] in {
0 ; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=WIN_X32
11 ; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=WIN_X64
2 ; RUN: llc < %s -mtriple=x86_64-pc-win32 -code-model=large | FileCheck %s -check-prefix=WIN64_LARGE
23 ; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X32
34 ; RUN: llc < %s -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X64
45 ; RUN: llc < %s -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX
1516 entry:
1617 ; WIN_X32: calll __chkstk
1718 ; WIN_X64: callq __chkstk
19 ; WIN64_LARGE: movabsq $__chkstk, %r11
20 ; WIN64_LARGE: callq *%r11
1821 ; MINGW_X32: calll __alloca
1922 ; MINGW_X64: callq ___chkstk_ms
2023 ; LINUX-NOT: call __chkstk
5154 entry:
5255 ; WIN_X32: calll __chkstk
5356 ; WIN_X64: callq __chkstk
57 ; WIN64_LARGE: movabsq $__chkstk, %r11
58 ; WIN64_LARGE: callq *%r11
5459 ; MINGW_X32: calll __alloca
5560 ; MINGW_X64: callq ___chkstk_ms
5661 ; LINUX-NOT: call __chkstk