[llvm-commits] [poolalloc] r118101 - in /poolalloc/trunk: include/dsa/DSGraph.h lib/DSA/BottomUpClosure.cpp lib/DSA/DSGraph.cpp lib/DSA/Local.cpp lib/DSA/StdLibPass.cpp lib/DSA/TopDownClosure.cpp
Will Dietz
wdietz2 at illinois.edu
Tue Nov 2 15:48:26 PDT 2010
Author: wdietz2
Date: Tue Nov 2 17:48:26 2010
New Revision: 118101
URL: http://llvm.org/viewvc/llvm-project?rev=118101&view=rev
Log:
Remove 'hack' of marking globals reachable from formals, and instead
clone the GG's back at the end of TD and recompute external with that.
Modified:
poolalloc/trunk/include/dsa/DSGraph.h
poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
poolalloc/trunk/lib/DSA/DSGraph.cpp
poolalloc/trunk/lib/DSA/Local.cpp
poolalloc/trunk/lib/DSA/StdLibPass.cpp
poolalloc/trunk/lib/DSA/TopDownClosure.cpp
Modified: poolalloc/trunk/include/dsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraph.h?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSGraph.h Tue Nov 2 17:48:26 2010
@@ -507,12 +507,11 @@
};
void markIncompleteNodes(unsigned Flags);
- // Mark all reachable from external as external.
+ // Mark all reachable from external as external.
enum ComputeExternalFlags {
MarkFormalsExternal = 1, DontMarkFormalsExternal = 0,
ProcessCallSites = 2, IgnoreCallSites = 0,
- ResetExternal = 4, DontResetExternal = 0,
- MarkGlobalsReachableFromFormals = 8, IgnoreGlobalsReachableFromFormals = 0
+ ResetExternal = 4, DontResetExternal = 0
};
void computeExternalFlags(unsigned Flags);
Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Nov 2 17:48:26 2010
@@ -144,8 +144,8 @@
// Merge the globals variables (not the calls) from the globals graph back
// into the individual function's graph so that changes made to globals during
- // BU can be reflected. This is specifically needed for correct call graph
-
+ // BU can be reflected. This is specifically needed for correct call graph
+
for (Module::iterator F = M.begin(); F != M.end(); ++F) {
if (!(F->isDeclaration())){
DSGraph *Graph = getOrCreateGraph(F);
Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Nov 2 17:48:26 2010
@@ -728,48 +728,6 @@
maskNodeTypes(~DSNode::ExternalNode);
}
- if (Flags & MarkGlobalsReachableFromFormals) {
- DenseSet<const DSNode*> ReachableFromFormals;
- for (ReturnNodesTy::iterator FI = ReturnNodes.begin(), E = ReturnNodes.end();
- FI != E; ++FI) {
- const Function &F = *FI->first;
- // Find all reachable from arguments...
- for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end();
- I != E; ++I)
- if (isa<PointerType>(I->getType())) {
- DSNode * N = getNodeForValue(I).getNode();
- if (N) N->markReachableNodes(ReachableFromFormals);
- }
- // ...and the return value...
- if (!FI->second.isNull())
- FI->second.getNode()->markReachableNodes(ReachableFromFormals);
- if (!getVANodeFor(F).isNull())
- getVANodeFor(F).getNode()->markReachableNodes(ReachableFromFormals);
- }
-
- DenseSet<const DSNode*> ReachableFromGlobals;
-
- for (DSScalarMap::global_iterator I = ScalarMap.global_begin(),
- E = ScalarMap.global_end(); I != E; ++I) {
- DSNode * N = getNodeForValue(*I).getNode();
- if (N) N->markReachableNodes(ReachableFromGlobals);
- }
-
- // Find intersection of the two...
- // FIXME: This works fine for local, but what about in other places where we might newly
- // discover that something reachable from an externally visible function's argument is
- // also reachable from a global and as such should be marked external in all graphs
- // that use it?
- for (DenseSet<const DSNode*>::iterator I = ReachableFromFormals.begin(),
- E = ReachableFromFormals.end(); I != E; ++I) {
- DSNode * N = (DSNode *)*I;
- if (ReachableFromGlobals.count(N)) {
- // Reachable from both a global and the formals, mark external!
- markExternalNode(N, processedNodes);
- }
- }
- }
-
// Make sure that everything reachable from something already external is also external
propagateExternal(this, processedNodes);
@@ -829,7 +787,7 @@
// Finally handle all external globals...
for (DSScalarMap::global_iterator I = ScalarMap.global_begin(),
- E = ScalarMap.global_end(); I != E; ++I)
+ E = ScalarMap.global_end(); I != E; ++I) {
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) {
// If the global is external... mark it as such!
// FIXME: It's unclear to me that a global we initialize
@@ -839,9 +797,8 @@
if (!GV->hasInitializer() || N->isExternalNode())
markExternalNode(N, processedNodes);
}
+ }
- // FIXME: Sync with globals graph?
- // For now, trust the caller to do this as appropriate.
}
static inline void killIfUselessEdge(DSNodeHandle &Edge) {
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue Nov 2 17:48:26 2010
@@ -186,11 +186,6 @@
unsigned EFlags = 0
| DSGraph::DontMarkFormalsExternal
| DSGraph::ProcessCallSites;
- // Mark globals reachable from formals as external if we don't have
- // internal linkage.
- if (!f.hasInternalLinkage()) {
- EFlags |= DSGraph::MarkGlobalsReachableFromFormals;
- }
g.computeExternalFlags(EFlags);
Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Nov 2 17:48:26 2010
@@ -407,9 +407,6 @@
| DSGraph::ResetExternal
| DSGraph::DontMarkFormalsExternal
| DSGraph::ProcessCallSites;
- if (!I->hasInternalLinkage()) {
- EFlags |= DSGraph::MarkGlobalsReachableFromFormals;
- }
G->computeExternalFlags(EFlags);
}
GlobalsGraph->computeExternalFlags(DSGraph::ProcessCallSites);
Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=118101&r1=118100&r2=118101&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Tue Nov 2 17:48:26 2010
@@ -167,6 +167,28 @@
GlobalsGraph->removeTriviallyDeadNodes();
GlobalsGraph->computeExternalFlags(DSGraph::DontMarkFormalsExternal);
+ // Make sure each graph has updated external information about globals
+ // in the globals graph.
+ for (Module::iterator F = M.begin(); F != M.end(); ++F) {
+ if (!(F->isDeclaration())){
+ DSGraph *Graph = getOrCreateGraph(F);
+
+ ReachabilityCloner RC(Graph, GlobalsGraph,
+ DSGraph::DontCloneCallNodes |
+ DSGraph::DontCloneAuxCallNodes);
+ for (DSScalarMap::global_iterator
+ GI = Graph->getScalarMap().global_begin(),
+ E = Graph->getScalarMap().global_end(); GI != E; ++GI)
+ RC.getClonedNH(GlobalsGraph->getNodeForValue(*GI));
+
+ // Clean up uninteresting nodes
+ Graph->removeDeadNodes(0);
+
+ Graph->computeExternalFlags(DSGraph::DontMarkFormalsExternal);
+
+ }
+ }
+
// CBU contains the correct call graph.
// Restore it, so that subsequent passes and clients can get it.
restoreCorrectCallGraph();
More information about the llvm-commits
mailing list