diff --git a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp index c8347c23fdb9..5f3846949842 100644 --- a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/llvm/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::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/llvm/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll b/llvm/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll new file mode 100644 index 000000000000..b286ada83900 --- /dev/null +++ b/llvm/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( ) ; [#uses=1] + ret i32 %tmp +} + +declare i32 @e() readnone