-
Notifications
You must be signed in to change notification settings - Fork 13.4k
MIPS: Fix asm constraints "f" and "r" for softfloat #79116
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
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: YunQiang Su (wzssyqa) ChangesCurrently, clang accpets contraint f for softfloat, then LLVM meet an internal error. See: #64241 Full diff: https://github.com/llvm/llvm-project/pull/79116.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index f46b95abfd75c73..2b8ad6645e605fc 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -238,6 +238,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
case 'd': // Equivalent to "r" unless generating MIPS16 code.
case 'y': // Equivalent to "r", backward compatibility only.
case 'f': // floating-point registers.
+ if (*Name == 'f' && FloatABI == SoftFloat)
+ return false;
+ LLVM_FALLTHROUGH;
case 'c': // $25 for indirect jumps
case 'l': // lo register
case 'x': // hilo register pair
diff --git a/clang/test/Driver/mips-float.c b/clang/test/Driver/mips-float.c
index 2f1b813a153224c..bbf17abfb13839f 100644
--- a/clang/test/Driver/mips-float.c
+++ b/clang/test/Driver/mips-float.c
@@ -102,3 +102,17 @@
// CHECK-ABI-SOFT-MIPS16: "-target-feature" "+mips16"
// CHECK-ABI-SOFT-MIPS16: "-msoft-float"
// CHECK-ABI-SOFT-MIPS16: "-mfloat-abi" "soft"
+
+/// On MIPS, don't accept constraint "f" for soft-float.
+// RUN: not %clang -S %s -o %t.s 2>&1 \
+// RUN: -target mips-linux-gnu -msoft-float \
+// RUN: -DSOFT_FLOAT_NO_CONSTRAINT_F \
+// RUN: | FileCheck --check-prefix=CHECK-SOFTFLOAT-ASM-NO-F %s
+// CHECK-SOFTFLOAT-ASM-NO-F: error: invalid input constraint 'f' in asm
+
+#ifdef SOFT_FLOAT_NO_CONSTRAINT_F
+void read_float(float* p) {
+ float result = *p;
+ __asm__("" ::"f"(result));
+}
+#endif // SOFT_FLOAT_NO_CONSTRAINT_F
|
f01ce8f
to
afacada
Compare
a9f3b9e
to
009bd23
Compare
009bd23
to
af69ccc
Compare
@wzssyqa Ping. |
8383948
to
0da6811
Compare
define dso_local void @read_double(ptr nocapture noundef readonly %0) local_unnamed_addr #0 { | ||
%2 = load double, ptr %0, align 8 | ||
; MIPS32-LABEL: read_double: | ||
; MIPS32: lw $2, 4($4) |
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.
Ensure that lw
is indented by 2 compared with read_double:
clang/lib/Basic/Targets/Mips.h
Outdated
@@ -238,6 +238,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo { | |||
case 'd': // Equivalent to "r" unless generating MIPS16 code. | |||
case 'y': // Equivalent to "r", backward compatibility only. | |||
case 'f': // floating-point registers. | |||
if (*Name == 'f' && FloatABI == SoftFloat) |
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's better to move 'd' and 'y' below. I'll fix it.
This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meet an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r' Fixes: llvm#64241
0da6811
to
97dd952
Compare
This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meets an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'. Fixes: llvm#64241, llvm#63632 --------- Co-authored-by: Fangrui Song <i@maskray.me> (cherry picked from commit c88beb4)
This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meets an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'. Fixes: llvm#64241, llvm#63632 --------- Co-authored-by: Fangrui Song <i@maskray.me> (cherry picked from commit c88beb4)
This include 2 fixes:
1. Disallow 'f' for softfloat.
2. Allow 'r' for softfloat.
Currently, 'f' is accpeted by clang, then LLVM meets an internal error.
'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'.
Fixes: #64241, #63632