summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/EliminateNodes.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-28 19:33:00 +0000
committerChris Lattner <sabre@nondot.org>2002-03-28 19:33:00 +0000
commit8d4894e3fa1dcfb3cb22bdf04d3f8e208ca4b811 (patch)
treebfe2f9ff759c3e205bf54275972d30a11e185b54 /llvm/lib/Analysis/DataStructure/EliminateNodes.cpp
parentc3ae15cf0ba1df8eb1812f7f70593306124fe4de (diff)
downloadbcm5719-llvm-8d4894e3fa1dcfb3cb22bdf04d3f8e208ca4b811.tar.gz
bcm5719-llvm-8d4894e3fa1dcfb3cb22bdf04d3f8e208ca4b811.zip
Implement getEscapingAllocations & getNonEscapingAllocations
llvm-svn: 2021
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/EliminateNodes.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/EliminateNodes.cpp85
1 files changed, 61 insertions, 24 deletions
diff --git a/llvm/lib/Analysis/DataStructure/EliminateNodes.cpp b/llvm/lib/Analysis/DataStructure/EliminateNodes.cpp
index 471c6281df9..ab94c60d6d8 100644
--- a/llvm/lib/Analysis/DataStructure/EliminateNodes.cpp
+++ b/llvm/lib/Analysis/DataStructure/EliminateNodes.cpp
@@ -193,6 +193,34 @@ static void MarkReferredNodesReachable(DSNode *N,
AllocNodes, ReachableAllocNodes);
}
+void FunctionDSGraph::MarkEscapeableNodesReachable(
+ vector<bool> &ReachableShadowNodes,
+ vector<bool> &ReachableAllocNodes) {
+ // Mark all shadow nodes that have edges from other nodes as reachable.
+ // Recursively mark any shadow nodes pointed to by the newly live shadow
+ // nodes as also alive.
+ //
+ for (unsigned i = 0, e = ArgNodes.size(); i != e; ++i)
+ MarkReferredNodesReachable(ArgNodes[i],
+ ShadowNodes, ReachableShadowNodes,
+ AllocNodes, ReachableAllocNodes);
+
+ for (unsigned i = 0, e = GlobalNodes.size(); i != e; ++i)
+ MarkReferredNodesReachable(GlobalNodes[i],
+ ShadowNodes, ReachableShadowNodes,
+ AllocNodes, ReachableAllocNodes);
+
+ for (unsigned i = 0, e = CallNodes.size(); i != e; ++i)
+ MarkReferredNodesReachable(CallNodes[i],
+ ShadowNodes, ReachableShadowNodes,
+ AllocNodes, ReachableAllocNodes);
+
+ // Mark all nodes in the return set as being reachable...
+ MarkReferredNodeSetReachable(RetNode,
+ ShadowNodes, ReachableShadowNodes,
+ AllocNodes, ReachableAllocNodes);
+}
+
bool FunctionDSGraph::RemoveUnreachableNodes() {
bool Changed = false;
@@ -202,30 +230,8 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
//
vector<bool> ReachableShadowNodes(ShadowNodes.size());
vector<bool> ReachableAllocNodes (AllocNodes.size());
-
- // Mark all shadow nodes that have edges from other nodes as reachable.
- // Recursively mark any shadow nodes pointed to by the newly live shadow
- // nodes as also alive.
- //
- for (unsigned i = 0, e = ArgNodes.size(); i != e; ++i)
- MarkReferredNodesReachable(ArgNodes[i],
- ShadowNodes, ReachableShadowNodes,
- AllocNodes, ReachableAllocNodes);
-
- for (unsigned i = 0, e = GlobalNodes.size(); i != e; ++i)
- MarkReferredNodesReachable(GlobalNodes[i],
- ShadowNodes, ReachableShadowNodes,
- AllocNodes, ReachableAllocNodes);
-
- for (unsigned i = 0, e = CallNodes.size(); i != e; ++i)
- MarkReferredNodesReachable(CallNodes[i],
- ShadowNodes, ReachableShadowNodes,
- AllocNodes, ReachableAllocNodes);
-
- // Mark all nodes in the return set as being reachable...
- MarkReferredNodeSetReachable(RetNode,
- ShadowNodes, ReachableShadowNodes,
- AllocNodes, ReachableAllocNodes);
+
+ MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
// Mark all nodes in the value map as being reachable...
for (std::map<Value*, PointerValSet>::iterator I = ValueMap.begin(),
@@ -280,3 +286,34 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
Changed = true;
}
}
+
+
+
+
+// getEscapingAllocations - Add all allocations that escape the current
+// function to the specified vector.
+//
+void FunctionDSGraph::getEscapingAllocations(vector<AllocDSNode*> &Allocs) {
+ vector<bool> ReachableShadowNodes(ShadowNodes.size());
+ vector<bool> ReachableAllocNodes (AllocNodes.size());
+
+ MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
+
+ for (unsigned i = 0, e = AllocNodes.size(); i != e; ++i)
+ if (ReachableAllocNodes[i])
+ Allocs.push_back(AllocNodes[i]);
+}
+
+// getNonEscapingAllocations - Add all allocations that do not escape the
+// current function to the specified vector.
+//
+void FunctionDSGraph::getNonEscapingAllocations(vector<AllocDSNode*> &Allocs) {
+ vector<bool> ReachableShadowNodes(ShadowNodes.size());
+ vector<bool> ReachableAllocNodes (AllocNodes.size());
+
+ MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
+
+ for (unsigned i = 0, e = AllocNodes.size(); i != e; ++i)
+ if (!ReachableAllocNodes[i])
+ Allocs.push_back(AllocNodes[i]);
+}
OpenPOWER on IntegriCloud