diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-27 07:46:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-27 07:46:26 +0000 |
commit | 105d26acb4158daea4e54919cfd12545a3d901ea (patch) | |
tree | 9d28276a06334226b449e5c964cb7a21aa4d4363 /lib/Analysis/IPA/GlobalsModRef.cpp | |
parent | eaa243039b6a83f8915f4f96ced58fabb520c851 (diff) |
Fix conservative assumption, which was quite broken. Also, notice that
functions known to not access memory (like sin/cos) don't access memory! :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15264 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/GlobalsModRef.cpp')
-rw-r--r-- | lib/Analysis/IPA/GlobalsModRef.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 162b11f74c..15d76bf837 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -64,6 +64,8 @@ namespace { /// FunctionEffect - Capture whether or not this function reads or writes to /// ANY memory. If not, we can do a lot of aggressive analysis on it. unsigned FunctionEffect; + + FunctionRecord() : FunctionEffect(0) {} }; /// GlobalsModRef - The actual analysis pass. @@ -232,9 +234,27 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { // We do a bottom-up SCC traversal of the call graph. In other words, we // visit all callees before callers (leaf-first). for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG); I!=E; ++I) - // Do not call AnalyzeSCC on the external function node. - if ((*I).size() != 1 || (*I)[0]->getFunction()) + if ((*I).size() != 1) { AnalyzeSCC(*I); + } else if (Function *F = (*I)[0]->getFunction()) { + if (!F->isExternal()) { + // Nonexternal function. + AnalyzeSCC(*I); + } else { + // Otherwise external function. Handle intrinsics and other special + // cases here. + if (getAnalysis<AliasAnalysis>().doesNotAccessMemory(F)) + // If it does not access memory, process the function, causing us to + // realize it doesn't do anything (the body is empty). + AnalyzeSCC(*I); + else { + // Otherwise, don't process it. This will cause us to conservatively + // assume the worst. + } + } + } else { + // Do not process the external node, assume the worst. + } } void GlobalsModRef::AnalyzeSCC(std::vector<CallGraphNode *> &SCC) { |