Skip to content
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][sema] forbid '+f' on output register #75208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

knightXun
Copy link
Contributor

to align with GCC asm: "+f" is not allowed to be used on output register.

fix issue: #75019

to align with GCC asm: "+f" is not allowed to be used on output register.

fix issue: llvm#75019
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Dec 12, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 12, 2023

@llvm/pr-subscribers-clang

Author: flyingcat (knightXun)

Changes

to align with GCC asm: "+f" is not allowed to be used on output register.

fix issue: #75019


Full diff: https://github.com/llvm/llvm-project/pull/75208.diff

1 Files Affected:

  • (modified) clang/lib/Basic/TargetInfo.cpp (+8-1)
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 6cd5d618a4aca..57a81e03bc484 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -717,8 +717,15 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
   if (*Name != '=' && *Name != '+')
     return false;
 
-  if (*Name == '+')
+  if (*Name == '+') {
     Info.setIsReadWrite();
+    // To align with GCC asm: "=f" is not allowed, the
+    // operand constraints must select a class with a single reg.
+    auto Flag = Name + 1;
+    if (Flag && *Flag == 'f') {
+      return false;
+    }
+  }
 
   Name++;
   while (*Name) {

@knightXun
Copy link
Contributor Author

cc @phoebewang @shafik

Comment on lines +720 to +728
if (*Name == '+') {
Info.setIsReadWrite();
// To align with GCC asm: "=f" is not allowed, the
// operand constraints must select a class with a single reg.
auto Flag = Name + 1;
if (Flag && *Flag == 'f') {
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants