[llvm] r256932 - Revert "GlobalsAA: Take advantage of ArgMemOnly, InaccessibleMemOnly and InaccessibleMemOrArgMemOnly attributes"
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 6 05:23:53 PST 2016
Author: deadalnix
Date: Wed Jan 6 07:23:52 2016
New Revision: 256932
URL: http://llvm.org/viewvc/llvm-project?rev=256932&view=rev
Log:
Revert "GlobalsAA: Take advantage of ArgMemOnly, InaccessibleMemOnly and InaccessibleMemOrArgMemOnly attributes"
Summary:
This reverts commit 5a9e526f29cf8510ab5c3d566fbdcf47ac24e1e9.
As per discussion in D15665
This also add a test case so that regression introduced by that diff are not reintroduced.
Reviewers: vaivaswatha, jmolloy, hfinkel, reames
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15919
Added:
llvm/trunk/test/Analysis/GlobalsModRef/inaccessiblememonly.ll
Removed:
llvm/trunk/test/Analysis/GlobalsModRef/argmemonly-escape.ll
Modified:
llvm/trunk/lib/Analysis/GlobalsModRef.cpp
llvm/trunk/test/Analysis/GlobalsModRef/modreftest.ll
Modified: llvm/trunk/lib/Analysis/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/GlobalsModRef.cpp?rev=256932&r1=256931&r2=256932&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp Wed Jan 6 07:23:52 2016
@@ -376,15 +376,6 @@ bool GlobalsAAResult::AnalyzeUsesOfPoint
} else {
return true; // Argument of an unknown call.
}
- // If the Callee is not ReadNone, it may read the global,
- // and if it is not ReadOnly, it may also write to it.
- Function *CalleeF = CS.getCalledFunction();
- if (!CalleeF->doesNotAccessMemory()) {
- if (Readers)
- Readers->insert(CalleeF);
- if (Writers && !CalleeF->onlyReadsMemory())
- Writers->insert(CalleeF);
- }
}
} else if (ICmpInst *ICI = dyn_cast<ICmpInst>(I)) {
if (!isa<ConstantPointerNull>(ICI->getOperand(1)))
@@ -516,7 +507,7 @@ void GlobalsAAResult::AnalyzeCallGraph(C
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);
@@ -524,12 +515,6 @@ void GlobalsAAResult::AnalyzeCallGraph(C
// 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->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
- // pointer is captured in AnalyzeUsesOfPointer().
- FI.addModRefInfo(MRI_ModRef);
} else {
FI.addModRefInfo(MRI_ModRef);
// Can't say anything useful unless it's an intrinsic - they don't
Removed: llvm/trunk/test/Analysis/GlobalsModRef/argmemonly-escape.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/argmemonly-escape.ll?rev=256931&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/argmemonly-escape.ll (original)
+++ llvm/trunk/test/Analysis/GlobalsModRef/argmemonly-escape.ll (removed)
@@ -1,47 +0,0 @@
-; RUN: opt < %s -O1 -S -enable-non-lto-gmr=true | FileCheck %s
-
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.10.0"
-
- at a = internal global [3 x i32] zeroinitializer, align 4
-
-; The important thing we're checking for here is the reload of (some element of)
-; @a after the memset.
-
-; CHECK-LABEL: @main
-; CHECK: load i32, i32* getelementptr {{.*}} @a
-; CHECK-NEXT: call void @memsetp0i8i64{{.*}} @a
-; CHECK-NEXT: load i32, i32* getelementptr {{.*}} @a
-; CHECK-NEXT: call void @memsetp0i8i64A{{.*}} @a
-; CHECK-NEXT: load i32, i32* getelementptr {{.*}} @a
-; CHECK: icmp eq
-; CHECK: br i1
-
-define i32 @main() {
-entry:
- %0 = bitcast [3 x i32]* @a to i8*
- %1 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
- call void @memsetp0i8i64(i8* %0, i8 0, i64 4, i32 4, i1 false)
- %2 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
- call void @memsetp0i8i64A(i8* %0, i8 0, i64 4, i32 4, i1 false)
- %3 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
- %4 = add i32 %2, %3
- %cmp1 = icmp eq i32 %1, %4
- br i1 %cmp1, label %if.then, label %if.end
-
-if.then: ; preds = %entr
- call void @abort() #3
- unreachable
-
-if.end: ; preds = %entry
- ret i32 0
-}
-
-; Function Attrs: nounwind argmemonly
-declare void @memsetp0i8i64(i8* nocapture, i8, i64, i32, i1) nounwind argmemonly
-
-; Function Attrs: nounwind inaccessiblemem_or_argmemonly
-declare void @memsetp0i8i64A(i8* nocapture, i8, i64, i32, i1) nounwind inaccessiblemem_or_argmemonly
-
-; Function Attrs: noreturn nounwind
-declare void @abort() noreturn nounwind
Added: llvm/trunk/test/Analysis/GlobalsModRef/inaccessiblememonly.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/inaccessiblememonly.ll?rev=256932&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/inaccessiblememonly.ll (added)
+++ llvm/trunk/test/Analysis/GlobalsModRef/inaccessiblememonly.ll Wed Jan 6 07:23:52 2016
@@ -0,0 +1,21 @@
+; RUN: opt -O3 -S < %s | FileCheck %s
+
+target datalayout = "e-i64:64-f80:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @donteliminate() {
+; CHECK-LABEL: donteliminate
+; CHECK-NEXT: tail call noalias i8* @allocmemory()
+; CHECK-NEXT: tail call noalias i8* @allocmemory()
+; CHECK-NEXT: tail call noalias i8* @allocmemory()
+; CHECK-NEXT: ret void
+ %1 = tail call noalias i8* @allocmemory()
+ %2 = tail call noalias i8* @allocmemory()
+ %3 = tail call noalias i8* @allocmemory()
+ ret void
+}
+
+; Function Attrs: inaccessiblememonly
+declare noalias i8* @allocmemory() #0
+
+attributes #0 = { inaccessiblememonly }
Modified: llvm/trunk/test/Analysis/GlobalsModRef/modreftest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/modreftest.ll?rev=256932&r1=256931&r2=256932&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/modreftest.ll (original)
+++ llvm/trunk/test/Analysis/GlobalsModRef/modreftest.ll Wed Jan 6 07:23:52 2016
@@ -16,23 +16,3 @@ define i32 @test(i32* %P) {
define void @doesnotmodX() {
ret void
}
-
-declare void @InaccessibleMemOnlyFunc( ) #0
-declare void @InaccessibleMemOrArgMemOnlyFunc( ) #1
-
-define i32 @test2(i32* %P) {
-; CHECK: @test2
-; CHECK-NEXT: store i32 12, i32* @X
-; CHECK-NEXT: call void @InaccessibleMemOnlyFunc()
-; CHECK-NEXT: call void @InaccessibleMemOrArgMemOnlyFunc()
-; CHECK-NOT: load i32
-; CHECK-NEXT: ret i32 12
- store i32 12, i32* @X
- call void @InaccessibleMemOnlyFunc( )
- call void @InaccessibleMemOrArgMemOnlyFunc( )
- %V = load i32, i32* @X ; <i32> [#uses=1]
- ret i32 %V
-}
-
-attributes #0 = { inaccessiblememonly }
-attributes #1 = { inaccessiblemem_or_argmemonly }
More information about the llvm-commits
mailing list