Implement getEscapingAllocations & getNonEscapingAllocations
llvm-svn: 2021
This commit is contained in:
parent
c3ae15cf0b
commit
8d4894e3fa
|
@ -357,6 +357,8 @@ class FunctionDSGraph {
|
||||||
PointerValSet cloneFunctionIntoSelf(const FunctionDSGraph &G, bool ValueMap);
|
PointerValSet cloneFunctionIntoSelf(const FunctionDSGraph &G, bool ValueMap);
|
||||||
bool RemoveUnreachableNodes();
|
bool RemoveUnreachableNodes();
|
||||||
bool UnlinkUndistinguishableNodes();
|
bool UnlinkUndistinguishableNodes();
|
||||||
|
void MarkEscapeableNodesReachable(std::vector<bool> &RSN,
|
||||||
|
std::vector<bool> &RAN);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Define the interface only accessable to DataStructure
|
// Define the interface only accessable to DataStructure
|
||||||
|
@ -375,8 +377,8 @@ public:
|
||||||
//
|
//
|
||||||
void getEscapingAllocations(std::vector<AllocDSNode*> &Allocs);
|
void getEscapingAllocations(std::vector<AllocDSNode*> &Allocs);
|
||||||
|
|
||||||
// getEscapingAllocations - Add all allocations that do not escape the current
|
// getNonEscapingAllocations - Add all allocations that do not escape the
|
||||||
// function to the specified vector.
|
// current function to the specified vector.
|
||||||
//
|
//
|
||||||
void getNonEscapingAllocations(std::vector<AllocDSNode*> &Allocs);
|
void getNonEscapingAllocations(std::vector<AllocDSNode*> &Allocs);
|
||||||
|
|
||||||
|
|
|
@ -193,16 +193,9 @@ static void MarkReferredNodesReachable(DSNode *N,
|
||||||
AllocNodes, ReachableAllocNodes);
|
AllocNodes, ReachableAllocNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionDSGraph::RemoveUnreachableNodes() {
|
void FunctionDSGraph::MarkEscapeableNodesReachable(
|
||||||
bool Changed = false;
|
vector<bool> &ReachableShadowNodes,
|
||||||
|
vector<bool> &ReachableAllocNodes) {
|
||||||
while (1) {
|
|
||||||
// Reachable*Nodes - Contains true if there is an edge from a reachable
|
|
||||||
// node to the numbered node...
|
|
||||||
//
|
|
||||||
vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
|
||||||
vector<bool> ReachableAllocNodes (AllocNodes.size());
|
|
||||||
|
|
||||||
// Mark all shadow nodes that have edges from other nodes as reachable.
|
// Mark all shadow nodes that have edges from other nodes as reachable.
|
||||||
// Recursively mark any shadow nodes pointed to by the newly live shadow
|
// Recursively mark any shadow nodes pointed to by the newly live shadow
|
||||||
// nodes as also alive.
|
// nodes as also alive.
|
||||||
|
@ -226,6 +219,19 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
MarkReferredNodeSetReachable(RetNode,
|
MarkReferredNodeSetReachable(RetNode,
|
||||||
ShadowNodes, ReachableShadowNodes,
|
ShadowNodes, ReachableShadowNodes,
|
||||||
AllocNodes, ReachableAllocNodes);
|
AllocNodes, ReachableAllocNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
|
bool Changed = false;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// Reachable*Nodes - Contains true if there is an edge from a reachable
|
||||||
|
// node to the numbered node...
|
||||||
|
//
|
||||||
|
vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
||||||
|
vector<bool> ReachableAllocNodes (AllocNodes.size());
|
||||||
|
|
||||||
|
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
||||||
|
|
||||||
// Mark all nodes in the value map as being reachable...
|
// Mark all nodes in the value map as being reachable...
|
||||||
for (std::map<Value*, PointerValSet>::iterator I = ValueMap.begin(),
|
for (std::map<Value*, PointerValSet>::iterator I = ValueMap.begin(),
|
||||||
|
@ -280,3 +286,34 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
Changed = true;
|
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]);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue