[clang] 33b1f3f - [clang][patch] Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions
Melanie Blower via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 15 09:16:51 PDT 2021
Author: Melanie Blower
Date: 2021-03-15T12:15:20-04:00
New Revision: 33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b
URL: https://github.com/llvm/llvm-project/commit/33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b
DIFF: https://github.com/llvm/llvm-project/commit/33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b.diff
LOG: [clang][patch] Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions
Previously, the CurFPFeatures state was set to command line settings before
semantic analysis of the nested member functions and initialization
expressions, that's not correct, it should use the pragma state which
is in effect at the lexical position.
Reviewed By: Erich Keane, Aaron Ballman
Differential Revision: https://reviews.llvm.org/D98211
Added:
Modified:
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp
Removed:
################################################################################
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index df71ba34cdd9..dd1cccf72668 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3417,15 +3417,6 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
// declarations and the lexed inline method definitions, along with any
// delayed attributes.
- // Save the state of Sema.FPFeatures, and change the setting
- // to the levels specified on the command line. Previous level
- // will be restored when the RAII object is destroyed.
- Sema::FPFeaturesStateRAII SaveFPFeaturesState(Actions);
- FPOptionsOverride NewOverrides;
- Actions.CurFPFeatures = NewOverrides.applyOverrides(getLangOpts());
- Actions.FpPragmaStack.Act(Tok.getLocation(), Sema::PSK_Reset, StringRef(),
- {} /*unused*/);
-
SourceLocation SavedPrevTokLocation = PrevTokLocation;
ParseLexedPragmas(getCurrentClass());
ParseLexedAttributes(getCurrentClass());
diff --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index f49b5088641c..122c621b4cbc 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@ float fun_default FUN(1)
#endif
float y();
class ON {
- // Settings for top level class initializer revert to command line
- // source pragma's do not pertain.
+ // Settings for top level class initializer use program source setting.
float z = 2 + y() * 7;
//CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
#if DEFAULT
@@ -224,11 +223,10 @@ class ON {
//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
#endif
#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
#endif
#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
#endif
};
ON on;
@@ -236,18 +234,28 @@ ON on;
class OFF {
float w = 2 + y() * 7;
//CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
};
OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+ float xx;
+ float yy;
+ MyComplex(float x, float y) {
+ xx = x;
+ yy = y;
+ }
+ MyComplex() {}
+ const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK: fadd reassoc float
+ return MyComplex(xx + other.xx, yy + other.yy);
+ }
+};
+MyComplex useAdd() {
+ MyComplex a (1, 3);
+ MyComplex b (2, 4);
+ return a + b;
+}
More information about the cfe-commits
mailing list