[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 14:58:27 PST 2024


================
@@ -22156,3 +22156,25 @@ namespace llvm::RISCVVIntrinsicsTable {
 #include "RISCVGenSearchableTables.inc"
 
 } // namespace llvm::RISCVVIntrinsicsTable
+
+bool RISCVTargetLowering::hasInlineStackProbe(const MachineFunction &MF) const {
+
+  // If the function specifically requests inline stack probes, emit them.
+  if (MF.getFunction().hasFnAttribute("probe-stack"))
+    return MF.getFunction().getFnAttribute("probe-stack").getValueAsString() ==
+           "inline-asm";
+
+  return false;
+}
+
+unsigned RISCVTargetLowering::getStackProbeSize(const MachineFunction &MF,
+                                                unsigned StackAlign) const {
----------------
topperc wrote:

Use `Align StackAlign`.

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


More information about the cfe-commits mailing list