[SimplifyLibCalls] Don't crash if the function doesn't have a name.

llvm-svn: 254265
This commit is contained in:
Davide Italiano 2015-11-29 21:58:56 +00:00
parent e2db58cfb8
commit 0b14f29285
2 changed files with 11 additions and 3 deletions

View 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");

View File

@ -13,6 +13,15 @@ entry:
; CHECK: ret double %mul
; CHECK: }
define double @test2(double ()* %fptr, double %p1) #0 {
%call1 = call double %fptr()
%pow = call double @log(double %call1)
ret double %pow
}
; CHECK-LABEL: @test2
; CHECK: log
declare double @log(double) #0
declare double @llvm.pow.f64(double, double)