diff options
author | Duncan Sands <baldrick@free.fr> | 2008-09-03 15:31:24 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-09-03 15:31:24 +0000 |
commit | bad32949d6191f6167d08a51328fa04062d41db2 (patch) | |
tree | 4e4a4900da55efe996274d087096cb54c26b6f06 | |
parent | 4bf2ca3526a1ff9864a1ccd9bf3a3d2ccf783d8e (diff) | |
download | external_llvm-bad32949d6191f6167d08a51328fa04062d41db2.zip external_llvm-bad32949d6191f6167d08a51328fa04062d41db2.tar.gz external_llvm-bad32949d6191f6167d08a51328fa04062d41db2.tar.bz2 |
Since onlyReadsMemory returns true if in fact
doesNotAccessMemory, check doesNotAccessMemory
first, since otherwise functions may be
marked readonly rather than readnone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55697 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/IPA/GlobalsModRef.cpp | 6 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index c8347c2..5f38469 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -376,14 +376,16 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { if (F->isDeclaration()) { // Try to get mod/ref behaviour from function attributes. - if (F->onlyReadsMemory()) { + if (F->doesNotAccessMemory()) { + // Can't do better than that! + } else if (F->onlyReadsMemory()) { FunctionEffect |= Ref; // This function might call back into the module and read a global, so // mark all globals read somewhere as being read by this function. for (std::set<GlobalValue*>::iterator GI = ReadGlobals.begin(), E = ReadGlobals.end(); GI != E; ++GI) FR.GlobalInfo[*GI] |= Ref; - } else if (!F->doesNotAccessMemory()) { + } else { // Can't say anything useful. KnowNothing = true; } diff --git a/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll b/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll new file mode 100644 index 0000000..b286ada --- /dev/null +++ b/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | opt -globalsmodref-aa -markmodref | llvm-dis | grep readnone | count 2 + +define i32 @f() { +entry: + %tmp = call i32 @e( ) ; <i32> [#uses=1] + ret i32 %tmp +} + +declare i32 @e() readnone |