[clang] [clang][sema] forbid '+f' on output register (PR #75208)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 12 08:03:15 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: flyingcat  (knightXun)

<details>
<summary>Changes</summary>

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

fix issue: https://github.com/llvm/llvm-project/issues/75019

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


1 Files Affected:

- (modified) clang/lib/Basic/TargetInfo.cpp (+8-1) 


``````````diff
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) {

``````````

</details>


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


More information about the cfe-commits mailing list