From f5360d4bb3376347479d86547d21b95d80be786d Mon Sep 17 00:00:00 2001 From: Melanie Blower Date: Fri, 1 May 2020 10:32:06 -0700 Subject: Reapply "Add support for #pragma float_control" with buildbot fixes Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit fce82c0ed310174fe48e2402ac731b6340098389. --- clang/lib/CodeGen/CodeGenFunction.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 24e01c4..4fcf31a 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. -static llvm::fp::ExceptionBehavior ToConstrainedExceptMD( - LangOptions::FPExceptionModeKind Kind) { +llvm::fp::ExceptionBehavior +clang::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) { switch (Kind) { case LangOptions::FPE_Ignore: return llvm::fp::ebIgnore; @@ -133,15 +133,10 @@ void CodeGenFunction::SetFPModel() { auto fpExceptionBehavior = ToConstrainedExceptMD( getLangOpts().getFPExceptionMode()); - if (fpExceptionBehavior == llvm::fp::ebIgnore && - RM == llvm::RoundingMode::NearestTiesToEven) - // Constrained intrinsics are not used. - ; - else { - Builder.setIsFPConstrained(true); - Builder.setDefaultConstrainedRounding(RM); - Builder.setDefaultConstrainedExcept(fpExceptionBehavior); - } + Builder.setDefaultConstrainedRounding(RM); + Builder.setDefaultConstrainedExcept(fpExceptionBehavior); + Builder.setIsFPConstrained(fpExceptionBehavior != llvm::fp::ebIgnore || + RM != llvm::RoundingMode::NearestTiesToEven); } CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T, @@ -919,9 +914,11 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, Fn->addFnAttr(llvm::Attribute::NoRecurse); } - if (const FunctionDecl *FD = dyn_cast_or_null(D)) + if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + Builder.setIsFPConstrained(FD->usesFPIntrin()); 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. -- cgit v1.1