aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/DataStructure
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-01-23 22:05:33 +0000
committerChris Lattner <sabre@nondot.org>2003-01-23 22:05:33 +0000
commit394471f1973db98b13e97e82ed8a5beb35dd4811 (patch)
treeaf2f4a763bbfb2e8ff3699266a44f96dcef50cba /lib/Analysis/DataStructure
parent787645839a3730a5c225b06e46574f957b37635d (diff)
downloadexternal_llvm-394471f1973db98b13e97e82ed8a5beb35dd4811.zip
external_llvm-394471f1973db98b13e97e82ed8a5beb35dd4811.tar.gz
external_llvm-394471f1973db98b13e97e82ed8a5beb35dd4811.tar.bz2
* Eliminate boolean arguments in favor of using enums
* T-D pass now eliminates unreachable globals git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r--lib/Analysis/DataStructure/BottomUpClosure.cpp12
-rw-r--r--lib/Analysis/DataStructure/DataStructure.cpp13
-rw-r--r--lib/Analysis/DataStructure/Local.cpp4
-rw-r--r--lib/Analysis/DataStructure/Steensgaard.cpp4
-rw-r--r--lib/Analysis/DataStructure/TopDownClosure.cpp5
5 files changed, 20 insertions, 18 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index c7fb42d..d1c9626 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -364,8 +364,8 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
// Recompute the Incomplete markers. If there are any function calls left
// now that are complete, we must loop!
Graph.maskIncompleteMarkers();
- Graph.markIncompleteNodes();
- Graph.removeDeadNodes();
+ Graph.markIncompleteNodes(DSGraph::MarkFormalArgs);
+ Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
DEBUG(std::cerr << " [BU] Done inlining: " << F.getName() << " ["
<< Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
@@ -440,8 +440,8 @@ DSGraph &BUDataStructures::inlineNonSCCGraphs(Function &F,
// Recompute the Incomplete markers. If there are any function calls left
// now that are complete, we must loop!
Graph.maskIncompleteMarkers();
- Graph.markIncompleteNodes();
- Graph.removeDeadNodes();
+ Graph.markIncompleteNodes(DSGraph::MarkFormalArgs);
+ Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
DEBUG(std::cerr << " [BU] Done Non-SCC inlining: " << F.getName() << " ["
<< Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
@@ -535,8 +535,8 @@ DSGraph &BUDataStructures::calculateSCCGraph(Function &F,
// Recompute the Incomplete markers. If there are any function calls left
// now that are complete, we must loop!
Graph.maskIncompleteMarkers();
- Graph.markIncompleteNodes();
- Graph.removeDeadNodes();
+ Graph.markIncompleteNodes(DSGraph::MarkFormalArgs);
+ Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
DEBUG(std::cerr << " [BU] Done inlining: " << F.getName() << " ["
<< Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index 0e61f03..f151951 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -785,9 +785,9 @@ static void markIncomplete(DSCallSite &Call) {
// scope of current analysis may have modified it), the 'Incomplete' flag is
// added to the NodeType.
//
-void DSGraph::markIncompleteNodes(bool markFormalArgs) {
+void DSGraph::markIncompleteNodes(unsigned Flags) {
// Mark any incoming arguments as incomplete...
- if (markFormalArgs && Func)
+ if ((Flags & DSGraph::MarkFormalArgs) && Func)
for (Function::aiterator I = Func->abegin(), E = Func->aend(); I != E; ++I)
if (isPointerType(I->getType()) && ScalarMap.find(I) != ScalarMap.end())
markIncompleteNode(ScalarMap[I].getNode());
@@ -1010,7 +1010,7 @@ static void markAlive(DSCallSite &CS, std::set<DSNode*> &Alive) {
// from the caller's graph entirely. This is only appropriate to use when
// inlining graphs.
//
-void DSGraph::removeDeadNodes() {
+void DSGraph::removeDeadNodes(unsigned Flags) {
// Reduce the amount of work we have to do...
removeTriviallyDeadNodes();
@@ -1023,10 +1023,11 @@ void DSGraph::removeDeadNodes() {
// Mark all nodes reachable by (non-global) scalar nodes as alive...
for (std::map<Value*, DSNodeHandle>::iterator I = ScalarMap.begin(),
E = ScalarMap.end(); I != E; ++I)
- // if (!isa<GlobalValue>(I->first)) // Don't mark globals!
+ if (!(Flags & DSGraph::RemoveUnreachableGlobals) ||
+ !isa<GlobalValue>(I->first)) // Don't mark globals!
markAlive(I->second.getNode(), Alive);
- // else // Keep track of global nodes
- // GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode()));
+ else // Keep track of global nodes
+ GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode()));
// The return value is alive as well...
markAlive(RetNode.getNode(), Alive);
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index f40080a..93c534a 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -136,10 +136,10 @@ DSGraph::DSGraph(Function &F, DSGraph *GG) : Func(&F), GlobalsGraph(GG) {
#ifndef NDEBUG
Timer::addPeakMemoryMeasurement();
#endif
- markIncompleteNodes();
+ markIncompleteNodes(DSGraph::MarkFormalArgs);
// Remove any nodes made dead due to merging...
- removeDeadNodes();
+ removeDeadNodes(DSGraph::KeepUnreachableGlobals);
}
diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp
index 0994a22..b6497c5 100644
--- a/lib/Analysis/DataStructure/Steensgaard.cpp
+++ b/lib/Analysis/DataStructure/Steensgaard.cpp
@@ -196,10 +196,10 @@ bool Steens::run(Module &M) {
// Update the "incomplete" markers on the nodes, ignoring unknownness due to
// incoming arguments...
ResultGraph->maskIncompleteMarkers();
- ResultGraph->markIncompleteNodes(false);
+ ResultGraph->markIncompleteNodes(DSGraph::IgnoreFormalArgs);
// Remove any nodes that are dead after all of the merging we have done...
- ResultGraph->removeDeadNodes();
+ ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
DEBUG(print(std::cerr, &M));
return false;
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp
index da9bc7c..b867f7e 100644
--- a/lib/Analysis/DataStructure/TopDownClosure.cpp
+++ b/lib/Analysis/DataStructure/TopDownClosure.cpp
@@ -186,9 +186,10 @@ void TDDataStructures::calculateGraph(Function &F) {
// Recompute the Incomplete markers and eliminate unreachable nodes.
CG.maskIncompleteMarkers();
- CG.markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage()
+ CG.markIncompleteNodes(F.hasInternalLinkage() ? DSGraph::IgnoreFormalArgs:
+ DSGraph::MarkFormalArgs
/*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/);
- CG.removeDeadNodes();
+ CG.removeDeadNodes(DSGraph::RemoveUnreachableGlobals);
}
DEBUG(std::cerr << " [TD] Done inlining into callees for: " << F.getName()