diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-02-25 23:31:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-02-25 23:31:02 +0000 |
| commit | fab2872b6cf0965d28a204037e281637d68ddfd3 (patch) | |
| tree | 0d61f04f5c3abf12f2ec2155b0c0d2ce473301bb /llvm/lib/Analysis/DataStructure/Local.cpp | |
| parent | e62ddd405dc34b5d5dfe5626e9823954ace9e116 (diff) | |
| download | bcm5719-llvm-fab2872b6cf0965d28a204037e281637d68ddfd3.tar.gz bcm5719-llvm-fab2872b6cf0965d28a204037e281637d68ddfd3.zip | |
When building local graphs, clone the initializer for constant globals into each
local graph that uses the global.
llvm-svn: 11850
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
| -rw-r--r-- | llvm/lib/Analysis/DataStructure/Local.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp index c6575132ab6..6f9bc73510f 100644 --- a/llvm/lib/Analysis/DataStructure/Local.cpp +++ b/llvm/lib/Analysis/DataStructure/Local.cpp @@ -177,6 +177,18 @@ DSGraph::DSGraph(const TargetData &td, Function &F, DSGraph *GG) else ++I; + // If there are any constant globals referenced in this function, merge their + // initializers into the local graph from the globals graph. + if (ScalarMap.global_begin() != ScalarMap.global_end()) { + ReachabilityCloner RC(*this, *GG, 0); + + for (DSScalarMap::global_iterator I = ScalarMap.global_begin(); + I != ScalarMap.global_end(); ++I) + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) + if (GV->isConstant()) + RC.merge(ScalarMap[GV], GG->ScalarMap[GV]); + } + markIncompleteNodes(DSGraph::MarkFormalArgs); // Remove any nodes made dead due to merging... @@ -894,18 +906,20 @@ bool LocalDataStructures::run(Module &M) { const TargetData &TD = getAnalysis<TargetData>(); + { + GraphBuilder GGB(*GlobalsGraph); + + // Add initializers for all of the globals to the globals graph... + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) + if (!I->isExternal()) + GGB.mergeInGlobalInitializer(I); + } + // Calculate all of the graphs... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) DSInfo.insert(std::make_pair(I, new DSGraph(TD, *I, GlobalsGraph))); - GraphBuilder GGB(*GlobalsGraph); - - // Add initializers for all of the globals to the globals graph... - for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) - if (!I->isExternal()) - GGB.mergeInGlobalInitializer(I); - GlobalsGraph->removeTriviallyDeadNodes(); GlobalsGraph->markIncompleteNodes(DSGraph::MarkFormalArgs); return false; |

