diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4fcf31a..24e01c4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -117,8 +117,8 @@ CodeGenFunction::~CodeGenFunction() { // Map the LangOption for exception behavior into // the corresponding enum in the IR. -llvm::fp::ExceptionBehavior -clang::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) { +static llvm::fp::ExceptionBehavior ToConstrainedExceptMD( + LangOptions::FPExceptionModeKind Kind) { switch (Kind) { case LangOptions::FPE_Ignore: return llvm::fp::ebIgnore; @@ -133,10 +133,15 @@ void CodeGenFunction::SetFPModel() { auto fpExceptionBehavior = ToConstrainedExceptMD( getLangOpts().getFPExceptionMode()); - Builder.setDefaultConstrainedRounding(RM); - Builder.setDefaultConstrainedExcept(fpExceptionBehavior); - Builder.setIsFPConstrained(fpExceptionBehavior != llvm::fp::ebIgnore || - RM != llvm::RoundingMode::NearestTiesToEven); + if (fpExceptionBehavior == llvm::fp::ebIgnore && + RM == llvm::RoundingMode::NearestTiesToEven) + // Constrained intrinsics are not used. + ; + else { + Builder.setIsFPConstrained(true); + Builder.setDefaultConstrainedRounding(RM); + Builder.setDefaultConstrainedExcept(fpExceptionBehavior); + } } CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T, @@ -914,11 +919,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, Fn->addFnAttr(llvm::Attribute::NoRecurse); } - if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) { - Builder.setIsFPConstrained(FD->usesFPIntrin()); + if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) if (FD->usesFPIntrin()) Fn->addFnAttr(llvm::Attribute::StrictFP); - } // If a custom alignment is used, force realigning to this alignment on // any main function which certainly will need it. |