aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorSumant Kowshik <kowshik@uiuc.edu>2003-08-12 00:45:13 +0000
committerSumant Kowshik <kowshik@uiuc.edu>2003-08-12 00:45:13 +0000
commit233d0758a1cc339946828fb0b5ef014b344b47ee (patch)
tree62973fc812864b5f484d59ef6d675862d33fca20 /lib/Transforms
parent228090cfe805154b1d49630ed1bd6415df70f0dc (diff)
Bug fix: Some nodes pointed to by globals may not be marked incomplete and need to be tracked to find pool arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7763 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/PoolAllocate.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Transforms/IPO/PoolAllocate.cpp b/lib/Transforms/IPO/PoolAllocate.cpp
index 685071ffee..337c4adee3 100644
--- a/lib/Transforms/IPO/PoolAllocate.cpp
+++ b/lib/Transforms/IPO/PoolAllocate.cpp
@@ -254,14 +254,27 @@ void PoolAllocate::InlineIndirectCalls(Function &F, DSGraph &G,
void PoolAllocate::FindFunctionPoolArgs(Function &F) {
- // The DSGraph is merged with the globals graph.
DSGraph &G = BU->getDSGraph(F);
- G.mergeInGlobalsGraph();
-
+
// Inline the potential targets of indirect calls
hash_set<Function*> visitedFuncs;
InlineIndirectCalls(F, G, visitedFuncs);
+ // The DSGraph is merged with the globals graph.
+ G.mergeInGlobalsGraph();
+
+ // The nodes reachable from globals need to be recognized as potential
+ // arguments. This is required because, upon merging in the globals graph,
+ // the nodes pointed to by globals that are not live are not marked
+ // incomplete.
+ hash_set<DSNode*> NodesFromGlobals;
+ for (DSGraph::ScalarMapTy::iterator I = G.getScalarMap().begin(),
+ E = G.getScalarMap().end(); I != E; ++I)
+ if (isa<GlobalValue>(I->first)) { // Found a global
+ DSNodeHandle &GH = I->second;
+ GH.getNode()->markReachableNodes(NodesFromGlobals);
+ }
+
// At this point the DS Graphs have been modified in place including
// information about globals as well as indirect calls, making it useful
// for pool allocation
@@ -296,8 +309,8 @@ void PoolAllocate::FindFunctionPoolArgs(Function &F) {
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
if (Nodes[i]->isGlobalNode() && !Nodes[i]->isIncomplete())
DEBUG(std::cerr << "Global node is not Incomplete\n");
- if ((Nodes[i]->isIncomplete() || Nodes[i]->isGlobalNode()) &&
- Nodes[i]->isHeapNode())
+ if ((Nodes[i]->isIncomplete() || Nodes[i]->isGlobalNode() ||
+ NodesFromGlobals.count(Nodes[i])) && Nodes[i]->isHeapNode())
Nodes[i]->markReachableNodes(MarkedNodes);
}