In addition to deleting calls, the inliner can constant fold them as well.
authorChris Lattner <sabre@nondot.org>
Wed, 12 Jul 2006 18:37:18 +0000 (18:37 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Jul 2006 18:37:18 +0000 (18:37 +0000)
Handle this case, which doesn't require a new callgraph edge.  This fixes
a crash compiling MallocBench/gs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29121 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/InlineFunction.cpp

index 277b10a767f88e828d8b53a991712043944a492a..eeb69116ed551262e5d33b02bb72e1b45e71c0d4 100644 (file)
@@ -158,8 +158,10 @@ static void UpdateCallGraphAfterInlining(const Function *Caller,
     
     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);
     }
   }
 }