-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Alias cc modifier to c #127719
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
[clang] Alias cc modifier to c #127719
Conversation
@llvm/pr-subscribers-clang Author: None (PiJoules) ChangesFull diff: https://github.com/llvm/llvm-project/pull/127719.diff 4 Files Affected:
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 685c00d0cb44f..c8ff2ecea20cc 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -708,6 +708,13 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
DiagOffs = CurPtr-StrStart-1;
return diag::err_asm_invalid_escape;
}
+
+ // Specifically handle `cc` which we will alias to `c`.
+ // Note this is the only operand modifier that exists which has two
+ // characters.
+ if (EscapedChar == 'c' && *CurPtr == 'c')
+ CurPtr++;
+
EscapedChar = *CurPtr++;
}
diff --git a/clang/test/AST/cc-modifier.cc b/clang/test/AST/cc-modifier.cc
new file mode 100644
index 0000000000000..24eb105acd2b7
--- /dev/null
+++ b/clang/test/AST/cc-modifier.cc
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -verify
+// expected-no-diagnostics
+
+void func();
+void func2();
+
+bool func3() {
+ __asm__("%cc0 = %c1" : : "X"(func), "X"(func2));
+ return func2 == func;
+}
diff --git a/clang/test/AST/cc-modifier.cpp b/clang/test/AST/cc-modifier.cpp
new file mode 100644
index 0000000000000..24eb105acd2b7
--- /dev/null
+++ b/clang/test/AST/cc-modifier.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -verify
+// expected-no-diagnostics
+
+void func();
+void func2();
+
+bool func3() {
+ __asm__("%cc0 = %c1" : : "X"(func), "X"(func2));
+ return func2 == func;
+}
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index 10102cc2c4db1..9687c993e6464 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -284,3 +284,9 @@ void *t33(void *ptr)
// CHECK: @t33
// CHECK: %1 = call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr %0)
}
+
+void t34(void) {
+ __asm__ volatile("T34 CC NAMED MODIFIER: %cc[input]" :: [input] "i" (4));
+ // CHECK: @t34()
+ // CHECK: T34 CC NAMED MODIFIER: ${0:c}
+}
|
4b8d742
to
25554bd
Compare
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.
Thanks for the fix! The changes should come with a release note in clang/docs/ReleaseNotes.rst
I'm not super familiar with GCC Asm Statements, but the changes look correct to me otherwise.
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#GenericOperandmodifiers provides the `c` and `cc` modifiers. GCC 15 introduces the `cc` modifier which does the same as `c`. This patch lets Clang handle this for compatibility.
25554bd
to
886754d
Compare
Done |
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.
It seems like for gcc at least, IIUC, cc
does a bit more than c
so while we are supporting cc
for compatibility we are not fully supporting it? Specifically:
except try harder to print it with no punctuation
Perhaps we should document that in the comment in Stmt.cpp
, for gcc comparability but not totally equivalent?
In our testing, Clang's |
If that is the case then I think we are good. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/6897 Here is the relevant piece of the build log for the reference
|
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#GenericOperandmodifiers provides the
c
andcc
modifiers. GCC 15 introduces thecc
modifier which does the same asc
. This patch lets Clang handle this for compatibility.