diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2016-06-01 18:12:01 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2016-06-01 18:12:01 +0000 |
commit | 7e49342f2d931a80d114fb246f522d2dc1b51428 (patch) | |
tree | fe978d1c5b266ba0568e9e8ea145646cc85cfb9e /test/Analysis/BasicAA | |
parent | 90ac7e3463e501075eba73ff6bb322b7aaa91220 (diff) |
Claim NoAlias if two GEPs index different fields of the same struct
Patch by Taewook Oh
Summary: Patch for Bug 27478. Make BasicAliasAnalysis claims NoAlias if two GEPs index different fields of the same structure.
Reviewers: hfinkel, dberlin
Subscribers: dberlin, mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D20665
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/BasicAA')
-rw-r--r-- | test/Analysis/BasicAA/noalias-structure.ll | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/Analysis/BasicAA/noalias-structure.ll b/test/Analysis/BasicAA/noalias-structure.ll new file mode 100644 index 00000000000..201c6f47479 --- /dev/null +++ b/test/Analysis/BasicAA/noalias-structure.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Type = type { [10 x i32], i32 } +@Foo = external global %struct.Type, align 4 + +; /// Check that BasicAA claims no alias between different fileds of a structure +; void test() { +; for (unsigned i = 0 ; i < 10 ; i++) +; Foo.arr[i] += Foo.i; +; } + +define void @test() { +; CHECK-LABEL: Function: test: +entry: + %0 = load i32, i32* getelementptr inbounds (%struct.Type, %struct.Type* @Foo, i64 0, i32 1), align 4 + br label %for.body + +for.cond.cleanup: ; preds = %for.body + ret void + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + + %arrayidx = getelementptr inbounds %struct.Type, %struct.Type* @Foo, i64 0, i32 0, i64 %indvars.iv + %1 = load i32, i32* %arrayidx, align 4 + %add = add nsw i32 %1, %0 + store i32 %add, i32* %arrayidx, align 4 +; CHECK: NoAlias: i32* %arrayidx, i32* getelementptr inbounds (%struct.Type, %struct.Type* @Foo, i64 0, i32 1) + + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 10 + br i1 %exitcond, label %for.cond.cleanup, label %for.body +} |