[llvm] [PrologEpilogInserter] Scan all blocks for inline stack probe insertion (PR #195456)

Rong Mantle Bao via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 06:49:22 PDT 2026


================
@@ -1181,8 +1181,14 @@ void PEIImpl::insertPrologEpilogCode(MachineFunction &MF) {
   // Zero call used registers before restoring callee-saved registers.
   insertZeroCallUsedRegs(MF);
 
-  for (MachineBasicBlock *SaveBlock : SaveBlocks)
-    TFI.inlineStackProbe(MF, *SaveBlock);
+  {
+    SmallVector<MachineBasicBlock *> Blocks;
+    for (MachineBasicBlock &MBB : MF)
+      Blocks.push_back(&MBB);
+
+    for (MachineBasicBlock *MBB : Blocks)
+      TFI.inlineStackProbe(MF, *MBB);
+  }
----------------
CSharperMantle wrote:

> I don't think this is the best place to fix it, this `inlineStackProbe` call is intended to expand the PROBED_STACKALLOC added by `emitPrologue` which is also called only for the SaveBlocks. Also, this is run by other targets like PowerPC which doesn't need all blocks to be searched here.

Ooh, sorry, I didn't know about that. This was the only call site to `TargetFrameLowering::inlineStackProbe()`, so I thought it was the place to fix...

> I would prefer to add a `inlineStackProbe` call after `allocateStack` in `RISCVFrameLowering::eliminateCallFramePseudoInstr`.

Thanks, I'll fix this in v2.

https://github.com/llvm/llvm-project/pull/195456


More information about the llvm-commits mailing list