[PATCH] D15665: GlobalsAA: InaccessibleMemOnly does not mean ReadNone.
Vaivaswatha Nagaraj via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 19 00:56:58 PST 2015
vaivaswatha created this revision.
vaivaswatha added reviewers: jmolloy, hfinkel.
vaivaswatha added a subscriber: llvm-commits.
vaivaswatha added a dependency: D15605: GlobalsAA: Take advantage of ArgMemOnly, InaccessibleMemOnly and InaccessibleMemOrArgMemOnly attributes.
In AnalyzeCallGraph, if we treat InaccessibleMemOnly the same as ReadNone,
the function will end up having "FMRB_DoesNotAccessMemory". This will lead
to situations such as LICM moving out / eliminating calls such as malloc
(in the future, since malloc does not have InaccessibleMemOnly set yet)
from loops.
Instead, treat InaccessibleMemOnly such that the analysis still maintains
info for the function, but keeps it conservative as ModRef.
Depends on D15605
http://reviews.llvm.org/D15665
Files:
lib/Analysis/GlobalsModRef.cpp
test/Analysis/GlobalsModRef/modreftest.ll
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 ; <i32*> [#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
+}
Index: lib/Analysis/GlobalsModRef.cpp
===================================================================
--- lib/Analysis/GlobalsModRef.cpp
+++ lib/Analysis/GlobalsModRef.cpp
@@ -516,15 +516,16 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15665.43300.patch
Type: text/x-patch
Size: 1949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151219/26950f55/attachment.bin>
More information about the llvm-commits
mailing list