diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2010-02-01 22:40:09 +0000 | 
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2010-02-01 22:40:09 +0000 | 
| commit | a49d8e6d38e57b505742f367eae047b7c7f3b410 (patch) | |
| tree | 83db8b51309f897ffecf88ac0be5b92d21f1945b | |
| parent | e8fb4b7fd62d0d624aecd231c074affff466189d (diff) | |
| download | bcm5719-llvm-a49d8e6d38e57b505742f367eae047b7c7f3b410.tar.gz bcm5719-llvm-a49d8e6d38e57b505742f367eae047b7c7f3b410.zip  | |
Fix PR6196. GV callee may not be a function.
llvm-svn: 95017
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 8 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll | 12 | 
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 5b7629852ee..a8308b80a96 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -2288,9 +2288,11 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,    // 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 * diff --git a/llvm/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll b/llvm/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll new file mode 100644 index 00000000000..275117483d6 --- /dev/null +++ b/llvm/test/CodeGen/X86/2010-02-01-TaillCallCrash.ll @@ -0,0 +1,12 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu +; PR6196 + +%"char[]" = type [1 x i8] + +@.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 +}  | 

