Skip to content

Commit ebe22bd

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

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
@@ -1438,7 +1438,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
14381438
if (MF.getFunction()->isVarArg())
14391439
report_fatal_error("Segmented stacks do not support vararg functions.");
14401440
if (!STI.isTargetLinux() && !STI.isTargetDarwin() &&
1441-
!STI.isTargetWin32() && !STI.isTargetFreeBSD())
1441+
!STI.isTargetWin32() && !STI.isTargetWin64() && !STI.isTargetFreeBSD())
14421442
report_fatal_error("Segmented stacks not supported on this platform.");
14431443

14441444
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock();
@@ -1489,6 +1489,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
14891489
} else if (STI.isTargetDarwin()) {
14901490
TlsReg = X86::GS;
14911491
TlsOffset = 0x60 + 90*8; // See pthread_machdep.h. Steal TLS slot 90.
1492+
} else if (STI.isTargetWin64()) {
1493+
TlsReg = X86::GS;
1494+
TlsOffset = 0x28; // pvArbitrary, reserved for application use
14921495
} else if (STI.isTargetFreeBSD()) {
14931496
TlsReg = X86::FS;
14941497
TlsOffset = 0x18;
@@ -1526,7 +1529,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
15261529
BuildMI(checkMBB, DL, TII.get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
15271530
.addImm(1).addReg(0).addImm(-StackSize).addReg(0);
15281531

1529-
if (STI.isTargetLinux() || STI.isTargetWin32()) {
1532+
if (STI.isTargetLinux() || STI.isTargetWin32() || STI.isTargetWin64()) {
15301533
BuildMI(checkMBB, DL, TII.get(X86::CMP32rm)).addReg(ScratchReg)
15311534
.addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
15321535
} else if (STI.isTargetDarwin()) {

0 commit comments

Comments
 (0)