switch InlineInfo.DevirtualizedCalls's list to be of WeakVH.
authorChris Lattner <sabre@nondot.org>
Fri, 23 Apr 2010 18:37:01 +0000 (18:37 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 23 Apr 2010 18:37:01 +0000 (18:37 +0000)
This fixes a bug where calls inlined into an invoke would get
changed into an invoke but the array would keep pointing to
the (now dead) call.  The improved inliner behavior is still
disabled for now.

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

include/llvm/Transforms/Utils/Cloning.h
lib/Transforms/IPO/Inliner.cpp
lib/Transforms/Utils/InlineFunction.cpp

index a9dc95b4a81b384b87c3a1b509ccad5e9f245649..463c5d48e9eebf0cc2d190179094b33ff7ba1ad4 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ValueHandle.h"
 
 namespace llvm {
 
@@ -178,7 +179,7 @@ public:
   /// DevirtualizedCalls - InlineFunction fills this in with callsites that were
   /// inlined from the callee that went from being indirect calls to direct
   /// calls due to inlining.  This is only filled in if CG is non-null.
-  SmallVector<Instruction*, 2> DevirtualizedCalls;
+  SmallVector<WeakVH, 2> DevirtualizedCalls;
   
   void reset() {
     StaticAllocas.clear();
index 322b4698756c42ed8bb7d87d98f4a1b9a0eb54fd..1ac609ddf2c4eec141eb9afea355a8b555d7c1f4 100644 (file)
@@ -392,8 +392,10 @@ bool Inliner::runOnSCC(CallGraphSCC &SCC) {
         // onto our worklist to process.  They are useful inline candidates.
 #if 0
         for (unsigned i = 0, e = InlineInfo.DevirtualizedCalls.size();
-             i != e; ++i)
-          CallSites.push_back(CallSite(InlineInfo.DevirtualizedCalls[i]));
+             i != e; ++i) {
+          Value *Ptr = InlineInfo.DevirtualizedCalls[i];
+          CallSites.push_back(CallSite(Ptr));
+        }
 #endif
         
         // Update the cached cost info with the inlined call.
index a913d157e24a907931b06fb6defdf4c2180fa388..481cacf5a19423c583829f8ac3b20e8d50bce8b9 100644 (file)
@@ -72,7 +72,7 @@ static void HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
     II->setAttributes(CI->getAttributes());
     
     // Make sure that anything using the call now uses the invoke!  This also
-    // updates the CallGraph if present.
+    // updates the CallGraph if present, because it uses a WeakVH.
     CI->replaceAllUsesWith(II);
     
     // Delete the unconditional branch inserted by splitBasicBlock