[llvm-commits] [llvm] r162180 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/fcmp.ll

Benjamin Kramer benny.kra at googlemail.com
Sat Aug 18 15:04:34 PDT 2012


Author: d0k
Date: Sat Aug 18 17:04:34 2012
New Revision: 162180

URL: http://llvm.org/viewvc/llvm-project?rev=162180&view=rev
Log:
InstCombine: Fix a crasher when encountering a function pointer.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/trunk/test/Transforms/InstCombine/fcmp.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=162180&r1=162179&r2=162180&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Sat Aug 18 17:04:34 2012
@@ -2990,7 +2990,7 @@
         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 ||

Modified: llvm/trunk/test/Transforms/InstCombine/fcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fcmp.ll?rev=162180&r1=162179&r2=162180&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fcmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fcmp.ll Sat Aug 18 17:04:34 2012
@@ -151,3 +151,11 @@
 ; 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
+}





More information about the llvm-commits mailing list