diff options
author | Michael Ilseman <milseman@apple.com> | 2012-12-04 00:36:06 +0000 |
---|---|---|
committer | Michael Ilseman <milseman@apple.com> | 2012-12-04 00:36:06 +0000 |
commit | 7a167eef2f8a591ffa3a2df07722b92fbc64b86d (patch) | |
tree | 364e61cb6a07b71257eabec23dc2aa66e5ea3014 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 084665fa6d3d62dd61c5f8edd09281f5787f5ccc (diff) | |
download | bcm5719-llvm-7a167eef2f8a591ffa3a2df07722b92fbc64b86d.tar.gz bcm5719-llvm-7a167eef2f8a591ffa3a2df07722b92fbc64b86d.zip |
Have clang use LLVM IR's fast-math flags when in FastMath or FiniteMathOnly modes. Test cases included.
llvm-svn: 169191
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 3d7a978258d..c441403fb3e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -22,6 +22,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/StmtCXX.h" #include "clang/Frontend/CodeGenOptions.h" +#include "llvm/Operator.h" #include "llvm/Intrinsics.h" #include "llvm/MDBuilder.h" #include "llvm/DataLayout.h" @@ -46,6 +47,15 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) TerminateHandler(0), TrapBB(0) { if (!suppressNewContext) CGM.getCXXABI().getMangleContext().startNewFunction(); + + llvm::FastMathFlags FMF; + if (CGM.getLangOpts().FastMath) + FMF.UnsafeAlgebra = true; + if (CGM.getLangOpts().FiniteMathOnly) { + FMF.NoNaNs = true; + FMF.NoInfs = true; + } + Builder.SetFastMathFlags(FMF); } CodeGenFunction::~CodeGenFunction() { |