[llvm] 262cf39 - [MC] Increase asm-macro-max-nesting-depth default to 100 (#218455)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 21:50:49 PDT 2026


Author: Matt Turner
Date: 2026-09-15T21:50:44-07:00
New Revision: 262cf39197f4748693ea7bae7b788208bcb21621

URL: https://github.com/llvm/llvm-project/commit/262cf39197f4748693ea7bae7b788208bcb21621
DIFF: https://github.com/llvm/llvm-project/commit/262cf39197f4748693ea7bae7b788208bcb21621.diff

LOG: [MC] Increase asm-macro-max-nesting-depth default to 100 (#218455)

GNU as accepts assembly we reject at the current default of 20, e.g.
glibc's
`sysdeps/unix/sysv/linux/alpha/rt_sigaction.S`, which nests 31 deep.
Raise the
default to 100, matching GNU as.

Assisted-by: Claude Code

Added: 
    

Modified: 
    llvm/lib/MC/MCParser/MCAsmParser.cpp
    llvm/test/MC/AsmParser/macro-max-depth.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/MCAsmParser.cpp b/llvm/lib/MC/MCParser/MCAsmParser.cpp
index 68bd0e4453d04..7a88f2d50d36e 100644
--- a/llvm/lib/MC/MCParser/MCAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/MCAsmParser.cpp
@@ -24,7 +24,7 @@ using namespace llvm;
 
 namespace llvm {
 cl::opt<unsigned> AsmMacroMaxNestingDepth(
-    "asm-macro-max-nesting-depth", cl::init(20), cl::Hidden,
+    "asm-macro-max-nesting-depth", cl::init(100), cl::Hidden,
     cl::desc("The maximum nesting depth allowed for assembly macros."));
 }
 

diff  --git a/llvm/test/MC/AsmParser/macro-max-depth.s b/llvm/test/MC/AsmParser/macro-max-depth.s
index 47fbf9a1930ba..16064134bb287 100644
--- a/llvm/test/MC/AsmParser/macro-max-depth.s
+++ b/llvm/test/MC/AsmParser/macro-max-depth.s
@@ -1,20 +1,20 @@
-// RUN: llvm-mc -triple x86_64-unknown-unknown -asm-macro-max-nesting-depth=42 %s | FileCheck %s -check-prefix=CHECK_PASS
-// RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK_FAIL < %t %s
+// RUN: llvm-mc -triple x86_64 -defsym DEPTH=30 %s | FileCheck %s --check-prefix=PASS
+// RUN: llvm-mc -triple x86_64 -defsym DEPTH=99 %s | FileCheck %s --check-prefix=PASS
+// RUN: not llvm-mc -triple x86_64 -defsym DEPTH=100 %s 2>&1 | FileCheck %s --check-prefix=TOODEEP-DEFAULT
 
-.macro rec head, tail:vararg
- .ifnb \tail
- rec \tail
+// RUN: llvm-mc -triple x86_64 -asm-macro-max-nesting-depth=42 -defsym DEPTH=41 %s | FileCheck %s --check-prefix=PASS
+// RUN: not llvm-mc -triple x86_64 -asm-macro-max-nesting-depth=42 -defsym DEPTH=42 %s 2>&1 | FileCheck %s --check-prefix=TOODEEP-FLAG
+
+.macro rec n
+ .if \n > 0
+ rec "(\n - 1)"
  .else
  .long 42
  .endif
 .endm
 
-.macro amplify macro, args:vararg
- \macro  \args \args \args \args
-.endm
-
-amplify rec 0 0 0 0 0 0 0 0 0 0
+rec DEPTH
 
-// CHECK_PASS: .long 42
-// CHECK_FAIL: error: macros cannot be nested more than {{[0-9]+}} levels deep. Use -asm-macro-max-nesting-depth to increase this limit.
+// PASS: .long 42
+// TOODEEP-DEFAULT: error: macros cannot be nested more than 100 levels deep. Use -asm-macro-max-nesting-depth to increase this limit.
+// TOODEEP-FLAG: error: macros cannot be nested more than 42 levels deep. Use -asm-macro-max-nesting-depth to increase this limit.


        


More information about the llvm-commits mailing list