[llvm] [RISCV] Stack clash protection for dynamic alloca (PR #122508)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 11:17:36 PST 2025


================
@@ -545,6 +545,16 @@ void RISCVFrameLowering::allocateAndProbeStackForRVV(
       .addReg(SPReg)
       .addReg(TargetReg)
       .setMIFlag(Flag);
+
+  // If we have a dynamic allocation later we need to probe any residuals.
+  MachineBasicBlock *NextMBB = MBBI->getParent()->getSingleSuccessor();
+  if (NextMBB && NextMBB->begin()->getFlag(MachineInstr::FrameSetup)) {
----------------
topperc wrote:

If understand correctly, this is trying to find the expansion of the `RISCV::PROBED_STACKALLOC_DYN`? What guarantees that would be the first BB after the prologue. Couldn't there be other control flow before it?

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


More information about the llvm-commits mailing list