[llvm] draft: inline asm mode (PR #146215)
Amanieu d'Antras via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 28 10:35:55 PDT 2025
================
@@ -0,0 +1,110 @@
+# Inline Assembly Safety Directive
+
+## Overview
+
+The `.inline_asm_mode` directive provides enhanced safety for inline assembly blocks by warning about potentially unsafe label usage. This directive helps prevent common errors where programmers create non-local labels in inline assembly that could be inadvertently jumped to from external code.
+
+## Syntax
+
+```assembly
+.inline_asm_mode strict # Enable strict mode - warn on non-local labels
+.inline_asm_mode relaxed # Disable strict mode (default)
+```
+
+## Description
+
+When `.inline_asm_mode strict` is active, the assembler will emit warnings for labels that are considered potentially unsafe for inline assembly:
+
+- **Safe labels** (no warnings):
+ - Local labels starting with `.L` (e.g., `.L_loop`, `.L_end`)
+ - Numeric labels (e.g., `1:`, `42:`)
+ - Labels starting with special prefixes (`$`, `__`)
+ - Labels starting with `.` (local scope)
----------------
Amanieu wrote:
Only numeric labels are suitable for inline asm. The problem with local labels is that they are file local which means that you can still get duplicate symbol errors if the optimizer decides to clone the function containing the inline asm.
https://github.com/llvm/llvm-project/pull/146215
More information about the llvm-commits
mailing list