aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorMelanie Blower <melanie.blower@intel.com>2020-06-26 09:23:45 -0700
committerMelanie Blower <melanie.blower@intel.com>2020-06-27 01:34:57 -0700
commitf4aaed3bf16b3c07152c7a47d1a363a8267ebcf1 (patch)
treef96af05b5edd63e33c240d5f447057ad014c08d1 /clang/lib/CodeGen/CodeGenFunction.cpp
parent89812eeee97c8f7ab2e6ee2c48edb7a409dfff39 (diff)
downloadllvm-f4aaed3bf16b3c07152c7a47d1a363a8267ebcf1.zip
llvm-f4aaed3bf16b3c07152c7a47d1a363a8267ebcf1.tar.gz
llvm-f4aaed3bf16b3c07152c7a47d1a363a8267ebcf1.tar.bz2
Reland D81869 "Modify FPFeatures to use delta not absolute settings"
This reverts commit defd43a5b393bb63a902042adf578081b03b171d. with correction to solve msan report To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the floating point settings in PCH files aren't compatible, rewrite FPFeatures to use a delta in the settings rather than absolute settings. With this patch, these floating point options can be benign. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D81869
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 23208b2d..cfd32d1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -117,12 +117,12 @@ void CodeGenFunction::SetFPModel() {
void CodeGenFunction::SetFastMathFlags(FPOptions FPFeatures) {
llvm::FastMathFlags FMF;
- FMF.setAllowReassoc(FPFeatures.allowAssociativeMath());
- FMF.setNoNaNs(FPFeatures.noHonorNaNs());
- FMF.setNoInfs(FPFeatures.noHonorInfs());
- FMF.setNoSignedZeros(FPFeatures.noSignedZeros());
- FMF.setAllowReciprocal(FPFeatures.allowReciprocalMath());
- FMF.setApproxFunc(FPFeatures.allowApproximateFunctions());
+ FMF.setAllowReassoc(FPFeatures.getAllowFPReassociate());
+ FMF.setNoNaNs(FPFeatures.getNoHonorNaNs());
+ FMF.setNoInfs(FPFeatures.getNoHonorInfs());
+ FMF.setNoSignedZeros(FPFeatures.getNoSignedZero());
+ FMF.setAllowReciprocal(FPFeatures.getAllowReciprocal());
+ FMF.setApproxFunc(FPFeatures.getAllowApproxFunc());
FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement());
Builder.setFastMathFlags(FMF);
}
@@ -137,10 +137,12 @@ CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
FMFGuard.emplace(CGF.Builder);
- auto NewRoundingBehavior = FPFeatures.getRoundingMode();
+ llvm::RoundingMode NewRoundingBehavior =
+ static_cast<llvm::RoundingMode>(FPFeatures.getRoundingMode());
CGF.Builder.setDefaultConstrainedRounding(NewRoundingBehavior);
auto NewExceptionBehavior =
- ToConstrainedExceptMD(FPFeatures.getExceptionMode());
+ ToConstrainedExceptMD(static_cast<LangOptions::FPExceptionModeKind>(
+ FPFeatures.getFPExceptionMode()));
CGF.Builder.setDefaultConstrainedExcept(NewExceptionBehavior);
CGF.SetFastMathFlags(FPFeatures);
@@ -159,13 +161,13 @@ CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
if (OldValue != NewValue)
CGF.CurFn->addFnAttr(Name, llvm::toStringRef(NewValue));
};
- mergeFnAttrValue("no-infs-fp-math", FPFeatures.noHonorInfs());
- mergeFnAttrValue("no-nans-fp-math", FPFeatures.noHonorNaNs());
- mergeFnAttrValue("no-signed-zeros-fp-math", FPFeatures.noSignedZeros());
- mergeFnAttrValue(
- "unsafe-fp-math",
- FPFeatures.allowAssociativeMath() && FPFeatures.allowReciprocalMath() &&
- FPFeatures.allowApproximateFunctions() && FPFeatures.noSignedZeros());
+ mergeFnAttrValue("no-infs-fp-math", FPFeatures.getNoHonorInfs());
+ mergeFnAttrValue("no-nans-fp-math", FPFeatures.getNoHonorNaNs());
+ mergeFnAttrValue("no-signed-zeros-fp-math", FPFeatures.getNoSignedZero());
+ mergeFnAttrValue("unsafe-fp-math", FPFeatures.getAllowFPReassociate() &&
+ FPFeatures.getAllowReciprocal() &&
+ FPFeatures.getAllowApproxFunc() &&
+ FPFeatures.getNoSignedZero());
}
CodeGenFunction::CGFPOptionsRAII::~CGFPOptionsRAII() {