[clang] [llvm] [clang][ARM] Add -fstack-limit-variable to trap before stack overflow (PR #208076)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 02:33:29 PDT 2026


================
@@ -2316,6 +2316,12 @@ static void getTrivialDefaultFunctionAttributes(
       FuncAttrs.addAttribute("backchain");
     if (CodeGenOpts.EnableSegmentedStacks)
       FuncAttrs.addAttribute("split-stack");
+    if (!CodeGenOpts.StackLimitVariable.empty()) {
+      FuncAttrs.addAttribute("stack-limit-variable",
+                             CodeGenOpts.StackLimitVariable);
+      FuncAttrs.addAttribute("stack-limit-trap-number",
+                             llvm::utostr(CodeGenOpts.StackLimitTrapNumber));
----------------
nikic wrote:

New attributes must be specified in LangRef.

We should not have string references to globals though. This needs to be encoded in a way that actually references a proper GlobalVariable declaration. (I guess you could do function metadata for that?)

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


More information about the cfe-commits mailing list