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-basic-aa -cfl-anders-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
5; RUN: opt < %s -aa-pipeline=cfl-anders-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* %b
18; CHECK: NoAlias: i32* %a, i32** %lpp
19; CHECK: NoAlias: i32* %b, i32** %lpp
20; CHECK: MayAlias: i32** %lpp, i32** %p
21; CHECK: MayAlias: i32* %a, i32* %lpp_deref
22; CHECK: MayAlias: i32* %b, i32* %lpp_deref
23; CHECK: NoAlias: i32* %lpp_deref, i32** %p
24; CHECK: NoAlias: i32* %lpp_deref, i32*** %pp
25; CHECK: NoAlias: i32* %lpp_deref, i32** %lpp
26; CHECK: MayAlias: i32* %a, i32* %lp
27; CHECK: NoAlias: i32* %lp, i32*** %pp
28; CHECK: NoAlias: i32* %lp, i32** %lpp
29; CHECK: MayAlias: i32* %lp, i32* %lpp_deref
30define void @test_store_arg_multilevel() {
31  %a = alloca i32, align 4
32  %b = alloca i32, align 4
33  %p = alloca i32*, align 8
34  %pp = alloca i32**, align 8
35
36  store i32* %a, i32** %p
37  store i32** %p, i32*** %pp
38  call void @store_arg_multilevel_callee(i32*** %pp, i32* %b)
39
40  %lpp = load i32**, i32*** %pp
41  %lpp_deref = load i32*, i32** %lpp
42  %lp = load i32*, i32** %p
43
44  ret void
45}