forked from OSchip/llvm-project
InstCombine: Fix a crasher when encountering a function pointer.
llvm-svn: 162180
This commit is contained in:
parent
e1014e7b98
commit
9d03242fcf
|
@ -2990,7 +2990,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
|
|||
CallInst *CI = cast<CallInst>(LHSI);
|
||||
LibFunc::Func Func;
|
||||
// Various optimization for fabs compared with zero.
|
||||
if (RHSC->isNullValue() &&
|
||||
if (RHSC->isNullValue() && CI->getCalledFunction() &&
|
||||
TLI->getLibFunc(CI->getCalledFunction()->getName(), Func) &&
|
||||
TLI->has(Func)) {
|
||||
if (Func == LibFunc::fabs || Func == LibFunc::fabsf ||
|
||||
|
|
|
@ -151,3 +151,11 @@ define i32 @test16(double %a) nounwind {
|
|||
; CHECK-NOT: fabs
|
||||
; CHECK: fcmp ueq double %a, 0.000000e+00
|
||||
}
|
||||
|
||||
; Don't crash.
|
||||
define i32 @test17(double %a, double (double)* %p) nounwind {
|
||||
%call = tail call double %p(double %a) nounwind
|
||||
%cmp = fcmp ueq double %call, 0.000000e+00
|
||||
%conv = zext i1 %cmp to i32
|
||||
ret i32 %conv
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue