In addition to deleting calls, the inliner can constant fold them as well.
Handle this case, which doesn't require a new callgraph edge.  This fixes
a crash compiling MallocBench/gs.

llvm-svn: 29121
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 277b10a..eeb6911 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -158,8 +158,10 @@
     
     std::map<const Value*, Value*>::iterator VMI = ValueMap.find(OrigCall);
     if (VMI != ValueMap.end()) { // Only copy the edge if the call was inlined!
-      Instruction *NewCall = cast<Instruction>(VMI->second);
-      CallerNode->addCalledFunction(CallSite::get(NewCall), I->second);
+      // If the call was inlined, but then constant folded, there is no edge to
+      // add.  Check for this case.
+      if (Instruction *NewCall = dyn_cast<Instruction>(VMI->second))
+        CallerNode->addCalledFunction(CallSite::get(NewCall), I->second);
     }
   }
 }