[SimplifyLibCalls] Don't crash if the function doesn't have a name.
[oota-llvm.git] / lib / Transforms / Utils / SimplifyLibCalls.cpp
index e7eb39d6312fa595b9724412cdfd3434116761fc..47e587fab7b6a94f585a36a26d47b909fde4a72d 100644 (file)
@@ -1317,9 +1317,8 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) {
 
   LibFunc::Func Func;
   Function *F = OpC->getCalledFunction();
-  StringRef FuncName = F->getName();
-  if ((TLI->getLibFunc(FuncName, Func) && TLI->has(Func) &&
-      Func == LibFunc::pow) || F->getIntrinsicID() == Intrinsic::pow)
+  if (F && ((TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) &&
+      Func == LibFunc::pow) || F->getIntrinsicID() == Intrinsic::pow))
     return B.CreateFMul(OpC->getArgOperand(1),
       EmitUnaryFloatFnCall(OpC->getOperand(0), Callee->getName(), B,
                            Callee->getAttributes()), "mul");