Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 69b77f2

Browse files
klutzyluqmana
authored andcommitted
Support segmented stack on Win64
Identical to Win32 method except for 0x14 -> 0x28 and FS -> GS.
1 parent 6abe4fe commit 69b77f2

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
@@ -1161,7 +1161,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
11611161
if (MF.getFunction()->isVarArg())
11621162
report_fatal_error("Segmented stacks do not support vararg functions.");
11631163
if (!STI.isTargetLinux() && !STI.isTargetDarwin() &&
1164-
!STI.isTargetWin32() && !STI.isTargetFreeBSD())
1164+
!STI.isTargetWin32() && !STI.isTargetWin64() && !STI.isTargetFreeBSD())
11651165
report_fatal_error("Segmented stacks not supported on this platform.");
11661166

11671167
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock();
@@ -1205,6 +1205,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
12051205
} else if (STI.isTargetDarwin()) {
12061206
TlsReg = X86::GS;
12071207
TlsOffset = 0x60 + 90*8; // See pthread_machdep.h. Steal TLS slot 90.
1208+
} else if (STI.isTargetWin64()) {
1209+
TlsReg = X86::GS;
1210+
TlsOffset = 0x28; // pvArbitrary, reserved for application use
12081211
} else if (STI.isTargetFreeBSD()) {
12091212
TlsReg = X86::FS;
12101213
TlsOffset = 0x18;
@@ -1242,7 +1245,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
12421245
BuildMI(checkMBB, DL, TII.get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
12431246
.addImm(1).addReg(0).addImm(-StackSize).addReg(0);
12441247

1245-
if (STI.isTargetLinux() || STI.isTargetWin32()) {
1248+
if (STI.isTargetLinux() || STI.isTargetWin32() || STI.isTargetWin64()) {
12461249
BuildMI(checkMBB, DL, TII.get(X86::CMP32rm)).addReg(ScratchReg)
12471250
.addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
12481251
} else if (STI.isTargetDarwin()) {

0 commit comments

Comments
 (0)