[llvm] r254265 - [SimplifyLibCalls] Don't crash if the function doesn't have a name.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 29 13:58:57 PST 2015
Author: davide
Date: Sun Nov 29 15:58:56 2015
New Revision: 254265
URL: http://llvm.org/viewvc/llvm-project?rev=254265&view=rev
Log:
[SimplifyLibCalls] Don't crash if the function doesn't have a name.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/InstCombine/log-pow.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=254265&r1=254264&r2=254265&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp Sun Nov 29 15:58:56 2015
@@ -1317,9 +1317,8 @@ Value *LibCallSimplifier::optimizeLog(Ca
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");
Modified: llvm/trunk/test/Transforms/InstCombine/log-pow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/log-pow.ll?rev=254265&r1=254264&r2=254265&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/log-pow.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/log-pow.ll Sun Nov 29 15:58:56 2015
@@ -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)
More information about the llvm-commits
mailing list