Skip to content

Commit 072c759

Browse files
committed
Support segmented stack on Win64
Identical to Win32 method except for 0x14 -> 0x28 and FS -> GS.
1 parent 0964c68 commit 072c759

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Target/X86/X86FrameLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
14251425
if (MF.getFunction()->isVarArg())
14261426
report_fatal_error("Segmented stacks do not support vararg functions.");
14271427
if (!STI.isTargetLinux() && !STI.isTargetDarwin() &&
1428-
!STI.isTargetWin32() && !STI.isTargetFreeBSD())
1428+
!STI.isTargetWin32() && !STI.isTargetWin64() && !STI.isTargetFreeBSD())
14291429
report_fatal_error("Segmented stacks not supported on this platform.");
14301430

14311431
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock();
@@ -1474,6 +1474,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
14741474
} else if (STI.isTargetDarwin()) {
14751475
TlsReg = X86::GS;
14761476
TlsOffset = 0x60 + 90*8; // See pthread_machdep.h. Steal TLS slot 90.
1477+
} else if (STI.isTargetWin64()) {
1478+
TlsReg = X86::GS;
1479+
TlsOffset = 0x28; // pvArbitrary, reserved for application use
14771480
} else if (STI.isTargetFreeBSD()) {
14781481
TlsReg = X86::FS;
14791482
TlsOffset = 0x18;
@@ -1511,7 +1514,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
15111514
BuildMI(checkMBB, DL, TII.get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
15121515
.addImm(1).addReg(0).addImm(-StackSize).addReg(0);
15131516

1514-
if (STI.isTargetLinux() || STI.isTargetWin32()) {
1517+
if (STI.isTargetLinux() || STI.isTargetWin32() || STI.isTargetWin64()) {
15151518
BuildMI(checkMBB, DL, TII.get(X86::CMP32rm)).addReg(ScratchReg)
15161519
.addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
15171520
} else if (STI.isTargetDarwin()) {

0 commit comments

Comments
 (0)