aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-31 21:05:58 +0000
committerChris Lattner <sabre@nondot.org>2003-10-31 21:05:58 +0000
commitbb9ae1512e1179681c1774f2f1a9d8c042941a56 (patch)
tree796aa15ef6b723d65c86c464666cf645f8abd39f /lib/Transforms/IPO
parent07a38e7b77d29b87bc649b9b4cd73e5dfa84eecf (diff)
downloadexternal_llvm-bb9ae1512e1179681c1774f2f1a9d8c042941a56.zip
external_llvm-bb9ae1512e1179681c1774f2f1a9d8c042941a56.tar.gz
external_llvm-bb9ae1512e1179681c1774f2f1a9d8c042941a56.tar.bz2
Strip off CPR's manually, because if we don't, the inliner doesn't delete dead
functions. GRR git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9641 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/Inliner.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index 503879e..6c7a191 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -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...