[llvm-commits] [llvm] r55697 - in /llvm/trunk: lib/Analysis/IPA/GlobalsModRef.cpp test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll

Duncan Sands baldrick at free.fr
Wed Sep 3 08:31:28 PDT 2008


Author: baldrick
Date: Wed Sep  3 10:31:24 2008
New Revision: 55697

URL: http://llvm.org/viewvc/llvm-project?rev=55697&view=rev
Log:
Since onlyReadsMemory returns true if in fact
doesNotAccessMemory, check doesNotAccessMemory
first, since otherwise functions may be
marked readonly rather than readnone.

Added:
    llvm/trunk/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll
Modified:
    llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp

Modified: llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp?rev=55697&r1=55696&r2=55697&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp Wed Sep  3 10:31:24 2008
@@ -376,14 +376,16 @@
 
       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;
         }

Added: llvm/trunk/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll?rev=55697&view=auto

==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll (added)
+++ llvm/trunk/test/Analysis/GlobalsModRef/2008-09-03-ReadNone.ll Wed Sep  3 10:31:24 2008
@@ -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





More information about the llvm-commits mailing list