[llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Oct 31 15:07:04 PST 2003


Changes in directory llvm/lib/Transforms/IPO:

Inliner.cpp updated: 1.2 -> 1.3

---
Log message:

Strip off CPR's manually, because if we don't, the inliner doesn't delete dead
functions.  GRR


---
Diffs of the changes:  (+9 -2)

Index: llvm/lib/Transforms/IPO/Inliner.cpp
diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.2 llvm/lib/Transforms/IPO/Inliner.cpp:1.3
--- llvm/lib/Transforms/IPO/Inliner.cpp:1.2	Mon Oct 20 14:43:19 2003
+++ llvm/lib/Transforms/IPO/Inliner.cpp	Fri Oct 31 15:05:58 2003
@@ -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 @@
   // 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...





More information about the llvm-commits mailing list