[PATCH] D15665: GlobalsAA: InaccessibleMemOnly does not mean ReadNone.

Vaivaswatha Nagaraj via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 18:33:25 PST 2016


vaivaswatha updated this revision to Diff 43956.
vaivaswatha added a comment.

Updating comment and test case as per review comment.


http://reviews.llvm.org/D15665

Files:
  lib/Analysis/GlobalsModRef.cpp
  test/Analysis/GlobalsModRef/modreftest2.ll

Index: test/Analysis/GlobalsModRef/modreftest2.ll
===================================================================
--- /dev/null
+++ test/Analysis/GlobalsModRef/modreftest2.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -basicaa -globals-aa -gvn -licm -S | FileCheck %s
+
+ at X = internal global i32 4
+
+declare void @InaccessibleMemOnlyFunc( ) #0
+
+attributes #0 = { inaccessiblememonly }
+
+define i32 @test3( ) {
+entry:
+  br label %for.body7
+
+for.body7:
+; CHECK: for.body7
+; CHECK: call void @InaccessibleMemOnlyFunc()
+  %XB = bitcast i32* @X to i1*
+  %x = load i1, i1* %XB
+  call void @InaccessibleMemOnlyFunc( )
+  br i1 %x, label %for.body7, label %for.end12
+
+for.end12: 
+  ret i32 0
+}
+
+
Index: lib/Analysis/GlobalsModRef.cpp
===================================================================
--- lib/Analysis/GlobalsModRef.cpp
+++ lib/Analysis/GlobalsModRef.cpp
@@ -516,18 +516,20 @@
 
       if (F->isDeclaration()) {
         // Try to get mod/ref behaviour from function attributes.
-        if (F->doesNotAccessMemory() || F->onlyAccessesInaccessibleMemory()) {
+        if (F->doesNotAccessMemory()) {
           // Can't do better than that!
         } else if (F->onlyReadsMemory()) {
           FI.addModRefInfo(MRI_Ref);
           if (!F->isIntrinsic())
             // This function might call back into the module and read a global -
             // consider every global as possibly being read by this function.
             FI.setMayReadAnyGlobal();
         } else if (F->onlyAccessesArgMemory() || 
+                   F->onlyAccessesInaccessibleMemory() ||
                    F->onlyAccessesInaccessibleMemOrArgMem()) {
-          // This function may only access (read/write) memory pointed to by its
-          // arguments. If this pointer is to a global, this escaping use of the
+          // This function may at most access (read/write) memory pointed to by its
+          // arguments (i.e., it may not read any globals in this module directly). 
+          // If an argument points to a global, this escaping use of the
           // pointer is captured in AnalyzeUsesOfPointer().
           FI.addModRefInfo(MRI_ModRef);
         } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15665.43956.patch
Type: text/x-patch
Size: 2183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160105/726a4a0a/attachment.bin>


More information about the llvm-commits mailing list