[llvm-branch-commits] [llvm] 1dea8ed - [BasicAA] Remove unnecessary known size requirement

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Nov 28 01:22:01 PST 2020


Author: Nikita Popov
Date: 2020-11-28T10:17:12+01:00
New Revision: 1dea8ed8b7dd2ff5ea89dd6dcaf0b682a81e9815

URL: https://github.com/llvm/llvm-project/commit/1dea8ed8b7dd2ff5ea89dd6dcaf0b682a81e9815
DIFF: https://github.com/llvm/llvm-project/commit/1dea8ed8b7dd2ff5ea89dd6dcaf0b682a81e9815.diff

LOG: [BasicAA] Remove unnecessary known size requirement

The size requirement on V2 was present because it was not clear
whether an unknown size would allow an access before the start of
V2, which could then overlap. This is clarified since D91649: In
this part of BasicAA, all accesses can occur only after the base
pointer, even if they have unknown size.

This makes the positive and negative offset cases symmetric.

Differential Revision: https://reviews.llvm.org/D91482

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/test/Analysis/BasicAA/negoffset.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 5e6afd908ba3..2e4ee1c429dd 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1336,9 +1336,7 @@ AliasResult BasicAAResult::aliasGEP(
       // ---------------->|
       // |-->V1Size       |-------> V2Size
       // GEP1             V2
-      // We need to know that V2Size is not unknown, otherwise we might have
-      // stripped a gep with negative index ('gep <ptr>, -1, ...).
-      if (V1Size.hasValue() && V2Size.hasValue()) {
+      if (V1Size.hasValue()) {
         if ((-DecompGEP1.Offset).ult(V1Size.getValue()))
           return PartialAlias;
         return NoAlias;

diff  --git a/llvm/test/Analysis/BasicAA/negoffset.ll b/llvm/test/Analysis/BasicAA/negoffset.ll
index ac1ddfdf5ac5..cc0d68a48a12 100644
--- a/llvm/test/Analysis/BasicAA/negoffset.ll
+++ b/llvm/test/Analysis/BasicAA/negoffset.ll
@@ -117,3 +117,13 @@ entry:
   %2 = load i32, i32* %1
   ret i32 %2
 }
+
+; CHECK-LABEL: Function: one_size_unknown:
+; CHECK: NoModRef:  Ptr: i8* %p.minus1	<->  call void @llvm.memset.p0i8.i32(i8* %p, i8 0, i32 %size, i1 false)
+define void @one_size_unknown(i8* %p, i32 %size) {
+  %p.minus1 = getelementptr inbounds i8, i8* %p, i32 -1
+  call void @llvm.memset.p0i8.i32(i8* %p, i8 0, i32 %size, i1 false)
+  ret void
+}
+
+declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i1)


        


More information about the llvm-branch-commits mailing list