Fix PR6196. GV callee may not be a function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95017 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 5b76298..a8308b8 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -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 *