-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[LangRef] asm clobber constrains: '~memory' allows reads and synchronization #150191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-llvm-ir Author: Ralf Jung (RalfJung) ChangesCc @nikic -- does this sound right? I was not sure what the best way is for talking about "synchronization effects". Full diff: https://github.com/llvm/llvm-project/pull/150191.diff 1 Files Affected:
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index bac13cc0424a6..9f792fa392cca 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5448,10 +5448,13 @@ Clobber constraints
A clobber constraint is indicated by a "``~``" prefix. A clobber does not
consume an input operand, nor generate an output. Clobbers cannot use any of the
general constraint code letters -- they may use only explicit register
-constraints, e.g. "``~{eax}``". The one exception is that a clobber string of
-"``~{memory}``" indicates that the assembly writes to arbitrary undeclared
-memory locations -- not only the memory pointed to by a declared indirect
-output.
+constraints, e.g. "``~{eax}``".
+
+The one exception is that a clobber string of "``~{memory}``" indicates that the
+assembly reads and writes arbitrary undeclared memory locations -- not only the
+memory pointed to by a declared indirect output. Furthermore, the assembly may
+also cause synchronization with other threads, such as via release/acquire
+fences and atomic memory accesses.
Note that clobbering named registers that are also present in output
constraints is not legal.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also #110510 .
Maybe we should explicitly state this is a superset of "sideeffect", since synchronizing with other threads basically allows arbitrary effects.
Do you anticipate any transforms need to be changed based on this?
Do you mean the
This boils down to whether any transform considers asm blocks with this clobber to be |
I mean |
Ah, I see. Purely formally I could imagine |
Before isel, it looks like the only place that actually explicitly reasons about "sideffect" markings on inline asm is llvm/lib/Transforms/IPO/AttributorAttributes.cpp. which effectively uses the lack of it to infer the "norecurse" attribute. Everything else just sort of ignores the fact that it's an inline asm, and assumes the frontend will set appropriate attributes on the call. So as a practical matter, I'm not sure how much the formal rules matter here, if nothing is actually going to reason using them. |
Cc @nikic -- does this sound right? I was not sure what the best way is for talking about "synchronization effects".