]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Fix PR43617
authorEvandro Menezes <e.menezes@samsung.com>
Wed, 9 Oct 2019 22:03:23 +0000 (22:03 +0000)
committerEvandro Menezes <e.menezes@samsung.com>
Wed, 9 Oct 2019 22:03:23 +0000 (22:03 +0000)
Check for `nullptr` before inspecting composite function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374243 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyLibCalls.cpp

index 461a5e2cba0d631c170c8b2e4a81b5f4d371877b..beb0d307c26161434a228358d61a0cb0bf2df4a6 100644 (file)
@@ -1916,10 +1916,10 @@ Value *LibCallSimplifier::optimizeLog(CallInst *Log, IRBuilder<> &B) {
   B.setFastMathFlags(FastMathFlags::getFast());
 
   Function *ArgFn = Arg->getCalledFunction();
-  StringRef ArgNm = ArgFn->getName();
-  Intrinsic::ID ArgID = ArgFn->getIntrinsicID();
+  Intrinsic::ID ArgID =
+      ArgFn ? ArgFn->getIntrinsicID() : Intrinsic::not_intrinsic;
   LibFunc ArgLb = NotLibFunc;
-  TLI->getLibFunc(ArgNm, ArgLb);
+  TLI->getLibFunc(Arg, ArgLb);
 
   // log(pow(x,y)) -> y*log(x)
   if (ArgLb == PowLb || ArgID == Intrinsic::pow) {
@@ -1934,9 +1934,10 @@ Value *LibCallSimplifier::optimizeLog(CallInst *Log, IRBuilder<> &B) {
     substituteInParent(Arg, MulY);
     return MulY;
   }
+
   // log(exp{,2,10}(y)) -> y*log({e,2,10})
   // TODO: There is no exp10() intrinsic yet.
-  else if (ArgLb == ExpLb || ArgLb == Exp2Lb || ArgLb == Exp10Lb ||
+  if (ArgLb == ExpLb || ArgLb == Exp2Lb || ArgLb == Exp10Lb ||
            ArgID == Intrinsic::exp || ArgID == Intrinsic::exp2) {
     Constant *Eul;
     if (ArgLb == ExpLb || ArgID == Intrinsic::exp)