diff options
author | John McCall <rjmccall@apple.com> | 2020-06-01 21:02:02 -0400 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2020-06-01 22:00:30 -0400 |
commit | 8a8d703be0986dd6785cba0b610c9c4708b83e89 (patch) | |
tree | cb1da53250fb1bc0bfcfbe74adfb6de68535ab8e /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 11d1aa0bcc1197f1b3010171b02c6e9662f34b75 (diff) | |
download | llvm-8a8d703be0986dd6785cba0b610c9c4708b83e89.zip llvm-8a8d703be0986dd6785cba0b610c9c4708b83e89.tar.gz llvm-8a8d703be0986dd6785cba0b610c9c4708b83e89.tar.bz2 |
Fix how cc1 command line options are mapped into FP options.
Canonicalize on storing FP options in LangOptions instead of
redundantly in CodeGenOptions. Incorporate -ffast-math directly
into the values of those LangOptions rather than considering it
separately when building FPOptions. Build IR attributes from
those options rather than a mix of sources.
We should really simplify the driver/cc1 interaction here and have
the driver pass down options that cc1 directly honors. That can
happen in a follow-up, though.
Patch by Michele Scandale!
https://reviews.llvm.org/D80315
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index a348103..d6622a4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -71,26 +71,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) if (!suppressNewContext) CGM.getCXXABI().getMangleContext().startNewFunction(); - llvm::FastMathFlags FMF; - if (CGM.getLangOpts().FastMath) - FMF.setFast(); - if (CGM.getLangOpts().FiniteMathOnly) { - FMF.setNoNaNs(); - FMF.setNoInfs(); - } - if (CGM.getCodeGenOpts().NoNaNsFPMath) { - FMF.setNoNaNs(); - } - if (CGM.getCodeGenOpts().NoSignedZeros) { - FMF.setNoSignedZeros(); - } - if (CGM.getCodeGenOpts().ReciprocalMath) { - FMF.setAllowReciprocal(); - } - if (CGM.getCodeGenOpts().Reassociate) { - FMF.setAllowReassoc(); - } - Builder.setFastMathFlags(FMF); + SetFastMathFlags(FPOptions(CGM.getLangOpts())); SetFPModel(); } @@ -139,6 +120,18 @@ void CodeGenFunction::SetFPModel() { RM != llvm::RoundingMode::NearestTiesToEven); } +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.setAllowContract(FPFeatures.allowFPContractAcrossStatement()); + Builder.setFastMathFlags(FMF); +} + LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) { LValueBaseInfo BaseInfo; TBAAAccessInfo TBAAInfo; |