[all-commits] [llvm/llvm-project] 5c562f: [clang] number labels in asm goto strings after ti...
Nick Desaulniers via All-commits
all-commits at lists.llvm.org
Tue Jan 11 12:10:27 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5c562f62a4ee15592f5d764d0710553a4b07a6f2
https://github.com/llvm/llvm-project/commit/5c562f62a4ee15592f5d764d0710553a4b07a6f2
Author: Nick Desaulniers <ndesaulniers at google.com>
Date: 2022-01-11 (Tue, 11 Jan 2022)
Changed paths:
M clang/docs/LanguageExtensions.rst
M clang/docs/ReleaseNotes.rst
M clang/lib/AST/Stmt.cpp
M clang/lib/CodeGen/CGStmt.cpp
M clang/test/CodeGen/asm-goto.c
Log Message:
-----------
[clang] number labels in asm goto strings after tied inputs
I noticed that the following case would compile in Clang but not GCC:
void *x(void) {
void *p = &&foo;
asm goto ("# %0\n\t# %l1":"+r"(p):::foo);
foo:;
return p;
}
Changing the output template above from %l2 would compile in GCC but not
Clang.
This demonstrates that when using tied outputs (say via the "+r" output
constraint), the hidden inputs occur or are numbered BEFORE the labels,
at least with GCC.
In fact, GCC does denote this in its documentation:
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Extended-Asm.html#Goto-Labels
> Output operand with constraint modifier ‘+’ is counted as two operands
> because it is considered as one output and one input operand.
For the sake of compatibility, I think it's worthwhile to just make this
change.
It's better to use symbolic names for compatibility (especially now
between released version of Clang that support asm goto with outputs).
ie. %l1 from the above would be %l[foo]. The GCC docs also make this
recommendation.
Also, I cleaned up some cruft in GCCAsmStmt::getNamedOperand. AFAICT,
NumPlusOperands was no longer used, though I couldn't find which commit
didn't clean that up correctly.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103640
Link: https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Extended-Asm.html#Goto-Labels
Reviewed By: void
Differential Revision: https://reviews.llvm.org/D115471
More information about the All-commits
mailing list