@@ -1161,7 +1161,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1161
1161
if (MF.getFunction ()->isVarArg ())
1162
1162
report_fatal_error (" Segmented stacks do not support vararg functions." );
1163
1163
if (!STI.isTargetLinux () && !STI.isTargetDarwin () &&
1164
- !STI.isTargetWin32 () && !STI.isTargetFreeBSD ())
1164
+ !STI.isTargetWin32 () && !STI.isTargetWin64 () && !STI. isTargetFreeBSD ())
1165
1165
report_fatal_error (" Segmented stacks not supported on this platform." );
1166
1166
1167
1167
MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock ();
@@ -1205,6 +1205,9 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1205
1205
} else if (STI.isTargetDarwin ()) {
1206
1206
TlsReg = X86::GS;
1207
1207
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
1208
1211
} else if (STI.isTargetFreeBSD ()) {
1209
1212
TlsReg = X86::FS;
1210
1213
TlsOffset = 0x18 ;
@@ -1242,7 +1245,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
1242
1245
BuildMI (checkMBB, DL, TII.get (X86::LEA32r), ScratchReg).addReg (X86::ESP)
1243
1246
.addImm (1 ).addReg (0 ).addImm (-StackSize).addReg (0 );
1244
1247
1245
- if (STI.isTargetLinux () || STI.isTargetWin32 ()) {
1248
+ if (STI.isTargetLinux () || STI.isTargetWin32 () || STI. isTargetWin64 () ) {
1246
1249
BuildMI (checkMBB, DL, TII.get (X86::CMP32rm)).addReg (ScratchReg)
1247
1250
.addReg (0 ).addImm (0 ).addReg (0 ).addImm (TlsOffset).addReg (TlsReg);
1248
1251
} else if (STI.isTargetDarwin ()) {
0 commit comments