@@ -62,6 +62,7 @@ class X86WinAllocaExpander : public MachineFunctionPass {
62
62
unsigned StackPtr;
63
63
unsigned SlotSize;
64
64
int64_t StackProbeSize;
65
+ bool NoStackArgProbe;
65
66
66
67
StringRef getPassName () const override { return " X86 WinAlloca Expander" ; }
67
68
static char ID;
@@ -240,13 +241,21 @@ void X86WinAllocaExpander::lower(MachineInstr* MI, Lowering L) {
240
241
}
241
242
break ;
242
243
case Probe:
243
- // The probe lowering expects the amount in RAX/EAX.
244
- BuildMI (*MBB, MI, DL, TII->get (TargetOpcode::COPY), RegA)
245
- .addReg (MI->getOperand (0 ).getReg ());
246
-
247
- // Do the probe.
248
- STI->getFrameLowering ()->emitStackProbe (*MBB->getParent (), *MBB, MI, DL,
249
- /* InPrologue=*/ false );
244
+ if (!NoStackArgProbe) {
245
+ // The probe lowering expects the amount in RAX/EAX.
246
+ BuildMI (*MBB, MI, DL, TII->get (TargetOpcode::COPY), RegA)
247
+ .addReg (MI->getOperand (0 ).getReg ());
248
+
249
+ // Do the probe.
250
+ STI->getFrameLowering ()->emitStackProbe (*MBB->getParent (), *MBB, MI, DL,
251
+ /* InPrologue=*/ false );
252
+ } else {
253
+ // Sub
254
+ BuildMI (*MBB, I, DL, TII->get (Is64Bit ? X86::SUB64rr : X86::SUB32rr),
255
+ StackPtr)
256
+ .addReg (StackPtr)
257
+ .addReg (MI->getOperand (0 ).getReg ());
258
+ }
250
259
break ;
251
260
}
252
261
@@ -285,6 +294,9 @@ bool X86WinAllocaExpander::runOnMachineFunction(MachineFunction &MF) {
285
294
.getValueAsString ()
286
295
.getAsInteger (0 , StackProbeSize);
287
296
}
297
+ NoStackArgProbe = MF.getFunction ().hasFnAttribute (" no-stack-arg-probe" );
298
+ if (NoStackArgProbe)
299
+ StackProbeSize = INT64_MAX;
288
300
289
301
LoweringMap Lowerings;
290
302
computeLowerings (MF, Lowerings);
0 commit comments