aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorKevin P. Neal <kevin.neal@sas.com>2020-11-06 10:44:13 -0500
committerKevin P. Neal <kevin.neal@sas.com>2020-11-06 11:56:12 -0500
commit2069403cdf35da826937dc40453930c60d52487f (patch)
tree5db44b28be3e7e87bea3bc86e827f0f1c5577d13 /clang/lib/CodeGen/CodeGenFunction.cpp
parentd0b8810fe4ece12213936605b336777ed5fd06cc (diff)
downloadllvm-2069403cdf35da826937dc40453930c60d52487f.zip
llvm-2069403cdf35da826937dc40453930c60d52487f.tar.gz
llvm-2069403cdf35da826937dc40453930c60d52487f.tar.bz2
[FPEnv] Use strictfp metadata in casting nodes
The strictfp metadata was added to the casting AST nodes in D85960, but we aren't using that metadata yet. This patch adds that support. In order to avoid lots of ad-hoc passing around of the strictfp bits I updated the IRBuilder when moving from a function that has the Expr* to a function that lacks it. I believe we should switch to this pattern to keep the strictfp support from being overly invasive. For the purpose of testing that we're picking up the right metadata, I also made my tests use a pragma to make the AST's strictfp metadata not match the global strictfp metadata. This exposes issues that we need to deal with in subsequent patches, and I believe this is the right method for most all of our clang strictfp tests. Differential Revision: https://reviews.llvm.org/D88913
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index ea33ea0..005ee74 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -25,6 +25,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Basic/Builtins.h"
@@ -131,10 +132,24 @@ void CodeGenFunction::SetFastMathFlags(FPOptions FPFeatures) {
}
CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
+ const Expr *E)
+ : CGF(CGF) {
+ ConstructorHelper(E->getFPFeaturesInEffect(CGF.getLangOpts()));
+}
+
+CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
FPOptions FPFeatures)
- : CGF(CGF), OldFPFeatures(CGF.CurFPFeatures) {
+ : CGF(CGF) {
+ ConstructorHelper(FPFeatures);
+}
+
+void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(FPOptions FPFeatures) {
+ OldFPFeatures = CGF.CurFPFeatures;
CGF.CurFPFeatures = FPFeatures;
+ OldExcept = CGF.Builder.getDefaultConstrainedExcept();
+ OldRounding = CGF.Builder.getDefaultConstrainedRounding();
+
if (OldFPFeatures == FPFeatures)
return;
@@ -175,6 +190,8 @@ CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
CodeGenFunction::CGFPOptionsRAII::~CGFPOptionsRAII() {
CGF.CurFPFeatures = OldFPFeatures;
+ CGF.Builder.setDefaultConstrainedExcept(OldExcept);
+ CGF.Builder.setDefaultConstrainedRounding(OldRounding);
}
LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {