[llvm] [LangRef] inline asm: the instructions are treated opaquely (PR #157080)
Ralf Jung via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 06:52:54 PDT 2025
https://github.com/RalfJung updated https://github.com/llvm/llvm-project/pull/157080
>From 173fc51082e5821d8d8d54c81f3d9222999de36c Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Fri, 5 Sep 2025 13:42:56 +0200
Subject: [PATCH 1/2] [LangRef] inline asm: the template string is treated
opaquely
---
llvm/docs/LangRef.rst | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index e64b9343b7622..7ee137d50cfbc 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5227,7 +5227,10 @@ represents the inline assembler as a template string (containing the
instructions to emit), a list of operand constraints (stored as a string), a
flag that indicates whether or not the inline asm expression has side effects,
and a flag indicating whether the function containing the asm needs to align its
-stack conservatively.
+stack conservatively. The compiler's understanding of the semantics of the
+expression comes only from the list of operand constraints and the flags -- not
+the contents of the template string. In particular, no optimizations or analyses
+will be performed based on the contents of that string.
The template string supports argument substitution of the operands using "``$``"
followed by a number, to indicate substitution of the given register/memory
>From e5d04c8447b2bcf45e928ad7ab34b25a536b14cf Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Mon, 15 Sep 2025 15:52:35 +0200
Subject: [PATCH 2/2] explicitly mention self-modifying code
---
llvm/docs/LangRef.rst | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7ee137d50cfbc..01a160c958a9d 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5227,10 +5227,15 @@ represents the inline assembler as a template string (containing the
instructions to emit), a list of operand constraints (stored as a string), a
flag that indicates whether or not the inline asm expression has side effects,
and a flag indicating whether the function containing the asm needs to align its
-stack conservatively. The compiler's understanding of the semantics of the
-expression comes only from the list of operand constraints and the flags -- not
-the contents of the template string. In particular, no optimizations or analyses
-will be performed based on the contents of that string.
+stack conservatively.
+
+The compiler's understanding of the semantics of the expression comes only from
+the list of operand constraints and the flags -- not the contents of the
+template string. In particular, no optimizations or analyses will be performed
+based on the contents of that string. This ensures correct behavior if the
+assembly code emitted by this expression is altered later, e.g. via
+self-modifying code, as long as the code keeps upholding the requirements of the
+operand constraints and the flags.
The template string supports argument substitution of the operands using "``$``"
followed by a number, to indicate substitution of the given register/memory
More information about the llvm-commits
mailing list