diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-28 22:10:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-28 22:10:58 +0000 |
commit | 5e459dbc529d60a6e2c57e8448006ad0d2a8116a (patch) | |
tree | 514fcfe3309556b6fe84ad5639ae9ed3ed38efe2 /lib/Analysis/DataStructure | |
parent | 72d50a090fd315f7107005712353bb9c940e92bd (diff) | |
download | external_llvm-5e459dbc529d60a6e2c57e8448006ad0d2a8116a.zip external_llvm-5e459dbc529d60a6e2c57e8448006ad0d2a8116a.tar.gz external_llvm-5e459dbc529d60a6e2c57e8448006ad0d2a8116a.tar.bz2 |
Drop references to globals who do exist in the globals graph, but are never
read or written to. Keep track of how many times this happens. This should
be good for deleting things like references to type information in C++ classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructureOpt.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index ad5b894..297979a 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -14,6 +14,8 @@ namespace { Statistic<> NumGlobalsConstanted("ds-opt", "Number of globals marked constant"); + Statistic<> + NumGlobalsIsolated("ds-opt", "Number of globals with references dropped"); class DSOpt : public Pass { TDDataStructures *TD; @@ -60,8 +62,21 @@ bool DSOpt::OptimizeGlobals(Module &M) { // can delete it. We don't ACTUALLY want to delete the global, just // remove anything that references the global: later passes will take // care of nuking it. - I->replaceAllUsesWith(Constant::getNullValue((Type*)I->getType())); + if (!I->use_empty()) { + I->replaceAllUsesWith(Constant::getNullValue((Type*)I->getType())); + ++NumGlobalsIsolated; + } } else if (GNode && GNode->isComplete()) { + + // If the node has not been read or written, and it is not externally + // visible, kill any references to it so it can be DCE'd. + if (!GNode->isModified() && !GNode->isRead() &&I->hasInternalLinkage()){ + if (!I->use_empty()) { + I->replaceAllUsesWith(Constant::getNullValue((Type*)I->getType())); + ++NumGlobalsIsolated; + } + } + // We expect that there will almost always be a node for this global. // If there is, and the node doesn't have the M bit set, we can set the // 'constant' bit on the global. |