@@ -1438,7 +1438,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1438
1438
if (MF.getFunction ()->isVarArg ())
1439
1439
report_fatal_error (" Segmented stacks do not support vararg functions." );
1440
1440
if (!STI.isTargetLinux () && !STI.isTargetDarwin () &&
1441
- !STI.isTargetWin32 () && !STI.isTargetFreeBSD ())
1441
+ !STI.isTargetWin32 () && !STI.isTargetWin64 () && !STI. isTargetFreeBSD ())
1442
1442
report_fatal_error (" Segmented stacks not supported on this platform." );
1443
1443
1444
1444
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock ();
@@ -1489,6 +1489,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1489
1489
} else if (STI.isTargetDarwin ()) {
1490
1490
TlsReg = X86::GS;
1491
1491
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
1492
1495
} else if (STI.isTargetFreeBSD ()) {
1493
1496
TlsReg = X86::FS;
1494
1497
TlsOffset = 0x18 ;
@@ -1526,7 +1529,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1526
1529
BuildMI (checkMBB, DL, TII.get (X86::LEA32r), ScratchReg).addReg (X86::ESP)
1527
1530
.addImm (1 ).addReg (0 ).addImm (-StackSize).addReg (0 );
1528
1531
1529
- if (STI.isTargetLinux () || STI.isTargetWin32 ()) {
1532
+ if (STI.isTargetLinux () || STI.isTargetWin32 () || STI. isTargetWin64 () ) {
1530
1533
BuildMI (checkMBB, DL, TII.get (X86::CMP32rm)).addReg (ScratchReg)
1531
1534
.addReg (0 ).addImm (0 ).addReg (0 ).addImm (TlsOffset).addReg (TlsReg);
1532
1535
} else if (STI.isTargetDarwin ()) {
0 commit comments