Index: lib/Analysis/GlobalsModRef.cpp =================================================================== --- lib/Analysis/GlobalsModRef.cpp +++ lib/Analysis/GlobalsModRef.cpp @@ -516,7 +516,7 @@ 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); @@ -525,6 +525,7 @@ // 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 Index: test/Analysis/GlobalsModRef/modreftest.ll =================================================================== --- test/Analysis/GlobalsModRef/modreftest.ll +++ test/Analysis/GlobalsModRef/modreftest.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -globals-aa -gvn -S | FileCheck %s +; RUN: opt < %s -basicaa -globals-aa -gvn -licm -S | FileCheck %s @X = internal global i32 4 ; [#uses=2] @@ -36,3 +36,19 @@ attributes #0 = { inaccessiblememonly } attributes #1 = { inaccessiblemem_or_argmemonly } + +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 +}