aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/CFLAliasAnalysis
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/CFLAliasAnalysis')
-rw-r--r--test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll16
-rw-r--r--test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll20
-rw-r--r--test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll6
-rw-r--r--test/Analysis/CFLAliasAnalysis/must-and-partial.ll25
-rw-r--r--test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll33
5 files changed, 84 insertions, 16 deletions
diff --git a/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll b/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll
new file mode 100644
index 0000000..d8ee94b
--- /dev/null
+++ b/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll
@@ -0,0 +1,16 @@
+; Test case for a bug where we would crash when we were requested to report
+; whether two values that didn't belong to a function (i.e. two globals, etc)
+; aliased.
+
+; RUN: opt < %s -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
+
+@G = private unnamed_addr constant [1 x i8] c"\00", align 1
+
+; CHECK: Function: test_no_crash
+; CHECK: 1 no alias responses
+define void @test_no_crash() #0 {
+entry:
+ call i8* asm "nop", "=r,r"(
+ i8* getelementptr inbounds ([1 x i8]* @G, i64 0, i64 0))
+ ret void
+}
diff --git a/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll b/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll
index 155fe13..21edfc2 100644
--- a/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll
+++ b/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll
@@ -2,8 +2,9 @@
; RUN: opt -S -tbaa -gvn < %s | FileCheck %s
; Adapted from the BasicAA full-store-partial-alias.ll test.
-; CFL AA should notice that the store stores to the entire %u object,
+; CFL AA could notice that the store stores to the entire %u object,
; so the %tmp5 load is PartialAlias with the store and suppress TBAA.
+; FIXME: However, right now, CFLAA cannot prove PartialAlias here
; Without CFL AA, TBAA should say that %tmp5 is NoAlias with the store.
target datalayout = "e-p:64:64:64"
@@ -14,8 +15,9 @@ target datalayout = "e-p:64:64:64"
@endianness_test = global i64 1, align 8
define i32 @signbit(double %x) nounwind {
-; CFLAA: ret i32 %tmp5.lobit
-; CHECK: ret i32 0
+; FIXME: This would be ret i32 %tmp5.lobit if CFLAA could prove PartialAlias
+; CFLAA: ret i32 0
+; CHECK: ret i32 0
entry:
%u = alloca %union.anon, align 8
%tmp9 = getelementptr inbounds %union.anon* %u, i64 0, i32 0
@@ -29,9 +31,9 @@ entry:
ret i32 %tmp5.lobit
}
-!0 = metadata !{metadata !4, metadata !4, i64 0}
-!1 = metadata !{metadata !"omnipotent char", metadata !2}
-!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
-!3 = metadata !{metadata !5, metadata !5, i64 0}
-!4 = metadata !{metadata !"double", metadata !1}
-!5 = metadata !{metadata !"int", metadata !1}
+!0 = !{!4, !4, i64 0}
+!1 = !{!"omnipotent char", !2}
+!2 = !{!"Simple C/C++ TBAA", null}
+!3 = !{!5, !5, i64 0}
+!4 = !{!"double", !1}
+!5 = !{!"int", !1}
diff --git a/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll b/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll
index a0195d7..19d251c 100644
--- a/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll
+++ b/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll
@@ -3,9 +3,11 @@
target datalayout = "e-p:32:32:32"
-; CHECK: 1 partial alias response
+; FIXME: This could be PartialAlias but CFLAA can't currently prove it
+; CHECK: 1 may alias response
-define i32 @test(i32* %tab, i32 %indvar) nounwind {
+define i32 @test(i32 %indvar) nounwind {
+ %tab = alloca i32, align 4
%tmp31 = mul i32 %indvar, -2
%tmp32 = add i32 %tmp31, 30
%t.5 = getelementptr i32* %tab, i32 %tmp32
diff --git a/test/Analysis/CFLAliasAnalysis/must-and-partial.ll b/test/Analysis/CFLAliasAnalysis/must-and-partial.ll
index df7de38..163a6c3 100644
--- a/test/Analysis/CFLAliasAnalysis/must-and-partial.ll
+++ b/test/Analysis/CFLAliasAnalysis/must-and-partial.ll
@@ -1,14 +1,15 @@
; RUN: opt < %s -cfl-aa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
-
; When merging MustAlias and PartialAlias, merge to PartialAlias
; instead of MayAlias.
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
-; CHECK: PartialAlias: i16* %bigbase0, i8* %phi
-define i8 @test0(i8* %base, i1 %x) {
+; FIXME: This could be PartialAlias but CFLAA can't currently prove it
+; CHECK: MayAlias: i16* %bigbase0, i8* %phi
+define i8 @test0(i1 %x) {
entry:
+ %base = alloca i8, align 4
%baseplusone = getelementptr i8* %base, i64 1
br i1 %x, label %red, label %green
red:
@@ -24,9 +25,11 @@ green:
ret i8 %loaded
}
-; CHECK: PartialAlias: i16* %bigbase1, i8* %sel
-define i8 @test1(i8* %base, i1 %x) {
+; FIXME: This could be PartialAlias but CFLAA can't currently prove it
+; CHECK: MayAlias: i16* %bigbase1, i8* %sel
+define i8 @test1(i1 %x) {
entry:
+ %base = alloca i8, align 4
%baseplusone = getelementptr i8* %base, i64 1
%sel = select i1 %x, i8* %baseplusone, i8* %base
store i8 0, i8* %sel
@@ -37,3 +40,15 @@ entry:
%loaded = load i8* %sel
ret i8 %loaded
}
+
+; Incoming pointer arguments should not be PartialAlias because we do not know their initial state
+; even if they are nocapture
+; CHECK: MayAlias: double* %A, double* %Index
+define void @testr2(double* nocapture readonly %A, double* nocapture readonly %Index) {
+ %arrayidx22 = getelementptr inbounds double* %Index, i64 2
+ %1 = load double* %arrayidx22
+ %arrayidx25 = getelementptr inbounds double* %A, i64 2
+ %2 = load double* %arrayidx25
+ %mul26 = fmul double %1, %2
+ ret void
+}
diff --git a/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll b/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll
new file mode 100644
index 0000000..8afedf2
--- /dev/null
+++ b/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll
@@ -0,0 +1,33 @@
+; This testcase ensures that CFLAA doesn't try to access out of bounds indices
+; when given functions with large amounts of arguments (specifically, more
+; arguments than the StratifiedAttrs bitset can handle)
+;
+; Because the result on failure is effectively crashing the compiler, output
+; checking is minimal.
+
+; RUN: opt < %s -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
+
+; CHECK: Function: test
+define void @test(i1 %cond,
+ i32* %arg1, i32* %arg2, i32* %arg3, i32* %arg4, i32* %arg5,
+ i32* %arg6, i32* %arg7, i32* %arg8, i32* %arg9, i32* %arg10,
+ i32* %arg11, i32* %arg12, i32* %arg13, i32* %arg14, i32* %arg15,
+ i32* %arg16, i32* %arg17, i32* %arg18, i32* %arg19, i32* %arg20,
+ i32* %arg21, i32* %arg22, i32* %arg23, i32* %arg24, i32* %arg25,
+ i32* %arg26, i32* %arg27, i32* %arg28, i32* %arg29, i32* %arg30,
+ i32* %arg31, i32* %arg32, i32* %arg33, i32* %arg34, i32* %arg35) {
+
+ ; CHECK: 946 Total Alias Queries Performed
+ ; CHECK: 810 no alias responses (85.6%)
+ %a = alloca i32, align 4
+ %b = select i1 %cond, i32* %arg35, i32* %arg34
+ %c = select i1 %cond, i32* %arg34, i32* %arg33
+ %d = select i1 %cond, i32* %arg33, i32* %arg32
+ %e = select i1 %cond, i32* %arg32, i32* %arg31
+ %f = select i1 %cond, i32* %arg31, i32* %arg30
+ %g = select i1 %cond, i32* %arg30, i32* %arg29
+ %h = select i1 %cond, i32* %arg29, i32* %arg28
+ %i = select i1 %cond, i32* %arg28, i32* %arg27
+
+ ret void
+}