[PATCH] D42381: [DA] Correct size parameter from dependency analysis to AA

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 09:28:26 PST 2018


dmgreen created this revision.

We were supplying the size to AA as DL.getTypeStoreSize(AObj->getType()),
which causes us to incorrectly presume noalias between loads/stores
with dependencies. I believe BasicAA was returning noalias because it
is undefined behaviour to access objects with a larger access than the
object size.


https://reviews.llvm.org/D42381

Files:
  lib/Analysis/DependenceAnalysis.cpp
  test/Analysis/DependenceAnalysis/AASize.ll


Index: test/Analysis/DependenceAnalysis/AASize.ll
===================================================================
--- /dev/null
+++ test/Analysis/DependenceAnalysis/AASize.ll
@@ -0,0 +1,46 @@
+; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
+
+; CHECK-LABEL: test
+; CHECK: da analyze - none!
+; CHECK: da analyze - none!
+; CHECK: da analyze - confused!
+; CHECK: da analyze - consistent output [|<]!
+; CHECK: da analyze - none!
+; CHECK: da analyze - confused!
+; CHECK: da analyze - none!
+; CHECK: da analyze - consistent input [S]!
+; load @d6 and store @d6
+; CHECK: da analyze - confused!
+; CHECK: da analyze - consistent output [S]!
+
+; There is a dependency in here, between @d and %0 (=@f)
+ at d6 = hidden global i16 5, align 2
+ at f6 = hidden local_unnamed_addr global i16* @d6, align 4
+
+define i32 @test() local_unnamed_addr #1 {
+entry:
+  store i16 1, i16* @d6, align 2
+  %0 = load i16*, i16** @f6, align 4
+  br label %for.body.i
+
+for.body.i:
+  %inc8.sink14.i = phi i16 [ 1, %entry ], [ %inc8.i, %for.cond.cleanup.i ]
+  %1 = load i16, i16* %0, align 2
+  br label %for.body6.i
+
+for.cond.cleanup.i:
+  %inc8.i = add nuw nsw i16 %inc8.sink14.i, 1
+  store i16 %inc8.i, i16* @d6, align 2
+  %cmp.i = icmp ult i16 %inc8.i, 6
+  br i1 %cmp.i, label %for.body.i, label %test.exit
+
+for.body6.i:
+  %c.013.i = phi i32 [ 0, %for.body.i ], [ %inc.i, %for.body6.i ]
+  %inc.i = add nuw nsw i32 %c.013.i, 1
+  %exitcond.i = icmp eq i32 %inc.i, 7
+  br i1 %exitcond.i, label %for.cond.cleanup.i, label %for.body6.i
+
+test.exit:
+  %conv2.i = sext i16 %1 to i32
+  ret i32 0
+}
\ No newline at end of file
Index: lib/Analysis/DependenceAnalysis.cpp
===================================================================
--- lib/Analysis/DependenceAnalysis.cpp
+++ lib/Analysis/DependenceAnalysis.cpp
@@ -627,8 +627,7 @@
                                           const Value *B) {
   const Value *AObj = GetUnderlyingObject(A, DL);
   const Value *BObj = GetUnderlyingObject(B, DL);
-  return AA->alias(AObj, DL.getTypeStoreSize(AObj->getType()),
-                   BObj, DL.getTypeStoreSize(BObj->getType()));
+  return AA->alias(AObj, BObj);
 }
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42381.130917.patch
Type: text/x-patch
Size: 2170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180122/be0d32af/attachment.bin>


More information about the llvm-commits mailing list