1; This testcase ensures that CFL AA answers queries soundly when callee tries
2; to mutate the memory pointed to by its parameters
3
4; RUN: opt < %s -disable-basicaa -cfl-steens-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
5; RUN: opt < %s -aa-pipeline=cfl-steens-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
6
7declare noalias i8* @malloc(i64)
8
9define void @store_arg_multilevel_callee(i32*** %arg1, i32* %arg2) {
10  %ptr = call noalias i8* @malloc(i64 8)
11  %ptr_cast = bitcast i8* %ptr to i32**
12	store i32* %arg2, i32** %ptr_cast
13  store i32** %ptr_cast, i32*** %arg1
14	ret void
15}
16; CHECK-LABEL: Function: test_store_arg_multilevel
17; CHECK: NoAlias: i32* %a, i32** %lpp
18; CHECK: NoAlias: i32* %b, i32** %lpp
19; CHECK: MayAlias: i32** %lpp, i32** %p
20; CHECK: MayAlias: i32* %a, i32* %lpp_deref
21; CHECK: MayAlias: i32* %b, i32* %lpp_deref
22; CHECK: NoAlias: i32* %lpp_deref, i32** %p
23; CHECK: NoAlias: i32* %lpp_deref, i32*** %pp
24; CHECK: NoAlias: i32* %lpp_deref, i32** %lpp
25; CHECK: MayAlias: i32* %a, i32* %lp
26; CHECK: NoAlias: i32* %lp, i32*** %pp
27; CHECK: NoAlias: i32* %lp, i32** %lpp
28; CHECK: MayAlias: i32* %lp, i32* %lpp_deref
29
30; We could've proven the following facts if the analysis were inclusion-based:
31; NoAlias: i32* %a, i32* %b
32; NoAlias: i32* %b, i32* %lp
33define void @test_store_arg_multilevel() {
34  %a = alloca i32, align 4
35  %b = alloca i32, align 4
36  %p = alloca i32*, align 8
37  %pp = alloca i32**, align 8
38
39  store i32* %a, i32** %p
40  store i32** %p, i32*** %pp
41  call void @store_arg_multilevel_callee(i32*** %pp, i32* %b)
42
43  %lpp = load i32**, i32*** %pp
44  %lpp_deref = load i32*, i32** %lpp
45  %lp = load i32*, i32** %p
46
47  ret void
48}