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

Commit 12d8851

Browse files
klutzyalexcrichton
authored andcommitted
Support segmented stack on Win64
Identical to Win32 method except for 0x14 -> 0x28 and FS -> GS.
1 parent b70c16c commit 12d8851

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: lib/Target/X86/X86FrameLowering.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
11661166
if (MF.getFunction()->isVarArg())
11671167
report_fatal_error("Segmented stacks do not support vararg functions.");
11681168
if (!STI.isTargetLinux() && !STI.isTargetDarwin() &&
1169-
!STI.isTargetWin32() && !STI.isTargetFreeBSD())
1169+
!STI.isTargetWin32() && !STI.isTargetWin64() && !STI.isTargetFreeBSD())
11701170
report_fatal_error("Segmented stacks not supported on this platform.");
11711171

11721172
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock();
@@ -1210,6 +1210,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
12101210
} else if (STI.isTargetDarwin()) {
12111211
TlsReg = X86::GS;
12121212
TlsOffset = 0x60 + 90*8; // See pthread_machdep.h. Steal TLS slot 90.
1213+
} else if (STI.isTargetWin64()) {
1214+
TlsReg = X86::GS;
1215+
TlsOffset = 0x28; // pvArbitrary, reserved for application use
12131216
} else if (STI.isTargetFreeBSD()) {
12141217
TlsReg = X86::FS;
12151218
TlsOffset = 0x18;
@@ -1247,7 +1250,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
12471250
BuildMI(checkMBB, DL, TII.get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
12481251
.addImm(1).addReg(0).addImm(-StackSize).addReg(0);
12491252

1250-
if (STI.isTargetLinux() || STI.isTargetWin32()) {
1253+
if (STI.isTargetLinux() || STI.isTargetWin32() || STI.isTargetWin64()) {
12511254
BuildMI(checkMBB, DL, TII.get(X86::CMP32rm)).addReg(ScratchReg)
12521255
.addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
12531256
} else if (STI.isTargetDarwin()) {

0 commit comments

Comments
 (0)