Strip off CPR's manually, because if we don't, the inliner doesn't delete dead
authorChris Lattner <sabre@nondot.org>
Fri, 31 Oct 2003 21:05:58 +0000 (21:05 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Oct 2003 21:05:58 +0000 (21:05 +0000)
functions.  GRR

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

lib/Transforms/IPO/Inliner.cpp

index 503879e43038a1aaa8e354bd2c65bf219fbc22da..6c7a1914a958fc08a5c1fc7dca9a97b8b010fc57 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Inliner.h"
+#include "llvm/Constants.h"   // ConstantPointerRef should die
 #include "llvm/Module.h"
 #include "llvm/iOther.h"
 #include "llvm/iTerminators.h"
@@ -108,12 +109,18 @@ bool Inliner::performInlining(CallSite CS, std::set<Function*> &SCC) {
   // Attempt to inline the function...
   if (!InlineFunction(CS)) return false;
   ++NumInlined;
-              
+  
+  if (Callee->hasOneUse())
+    if (ConstantPointerRef *CPR =
+        dyn_cast<ConstantPointerRef>(Callee->use_back()))
+      if (CPR->use_empty())
+        CPR->destroyConstant();
+  
   // If we inlined the last possible call site to the function,
   // delete the function body now.
   if (Callee->use_empty() && Callee != Caller &&
       (Callee->hasInternalLinkage() || Callee->hasLinkOnceLinkage())) {
-    DEBUG(std::cerr << "    -> Deleting dead function: "
+    DEBUG(std::cerr << "    -> Deleting dead function: " << (void*)Callee
                     << Callee->getName() << "\n");
     std::set<Function*>::iterator I = SCC.find(Callee);
     if (I != SCC.end())       // Remove function from this SCC...