summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-09-27 21:29:20 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-09-27 21:29:20 +0000
commit1f386c4ce1983c448320aecca8d3cd27d1497867 (patch)
tree7e479dcf8dd92df64b3c5faafea45edb94fee80e /lib/Analysis
parent376ce97baca2bcf97ab420313a876214cde7f9df (diff)
downloadllvm-1f386c4ce1983c448320aecca8d3cd27d1497867.tar.gz
llvm-1f386c4ce1983c448320aecca8d3cd27d1497867.tar.bz2
llvm-1f386c4ce1983c448320aecca8d3cd27d1497867.tar.xz
Don't try to constant fold libm functions with non-finite arguments.
Usually we wouldn't do this anyway because llvm_fenv_testexcept would return an exception, but we have seen some cases where neither errno nor fenv detect an exception on arm-linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114893 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ConstantFolding.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 96656a3c73..d3596d1c86 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -1094,6 +1094,13 @@ llvm::ConstantFoldCall(Function *F,
if (!Ty->isFloatTy() && !Ty->isDoubleTy())
return 0;
+
+ /// We only fold functions with finite arguments. Folding NaN and inf is
+ /// likely to be aborted with an exception anyway, and some host libms
+ /// have known errors raising exceptions.
+ if (Op->getValueAPF().isNaN() || Op->getValueAPF().isInfinity())
+ return 0;
+
/// Currently APFloat versions of these functions do not exist, so we use
/// the host native double versions. Float versions are not called
/// directly but for all these it is true (float)(f((double)arg)) ==