[llvm-commits] [llvm] r95017 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/2010-02-01-TaillCallCrash.ll

Evan Cheng evan.cheng at apple.com
Mon Feb 1 14:40:09 PST 2010


Author: evancheng
Date: Mon Feb  1 16:40:09 2010
New Revision: 95017

URL: http://llvm.org/viewvc/llvm-project?rev=95017&view=rev
Log:
Fix PR6196. GV callee may not be a function.

Added:
    llvm/trunk/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll
Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=95017&r1=95016&r2=95017&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb  1 16:40:09 2010
@@ -2288,9 +2288,11 @@
   // Don't tail call optimize recursive call.
   GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
   if (!G) return false;  // FIXME: common external symbols?
-  const Function *CalleeF = cast<Function>(G->getGlobal());
-  const Type *CalleeRetTy = CalleeF->getReturnType();
-  return CallerRetTy == CalleeRetTy;
+  if (const Function *CalleeF = dyn_cast<Function>(G->getGlobal())) {
+    const Type *CalleeRetTy = CalleeF->getReturnType();
+    return CallerRetTy == CalleeRetTy;
+  }
+  return false;
 }
 
 FastISel *

Added: llvm/trunk/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll?rev=95017&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll Mon Feb  1 16:40:09 2010
@@ -0,0 +1,12 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu
+; PR6196
+
+%"char[]" = type [1 x i8]
+
+ at .str = external constant %"char[]", align 1      ; <%"char[]"*> [#uses=1]
+
+define i32 @regex_subst() nounwind {
+entry:
+  %0 = tail call i32 bitcast (%"char[]"* @.str to i32 (i32)*)(i32 0) nounwind ; <i32> [#uses=1]
+  ret i32 %0
+}





More information about the llvm-commits mailing list