• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This testcase ensures that CFL AA answers queries soundly when callee tries
2; to return the reference of one of 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 i32** @return_ref_arg_callee(i32* %arg1) {
10	%ptr = call noalias i8* @malloc(i64 8)
11	%ptr_cast = bitcast i8* %ptr to i32**
12	store i32* %arg1, i32** %ptr_cast
13	ret i32** %ptr_cast
14}
15; CHECK-LABEL: Function: test_return_ref_arg
16; CHECK: MayAlias: i32* %a, i32* %lb
17; CHECK: NoAlias: i32* %lb, i32** %p
18; CHECK: NoAlias: i32* %lb, i32** %b
19; CHECK: NoAlias: i32* %lp, i32** %p
20; CHECK: NoAlias: i32* %lp, i32** %b
21; CHECK: MayAlias: i32* %lb, i32* %lp
22
23; We could've proven the following facts if the analysis were inclusion-based:
24; NoAlias: i32** %b, i32** %p
25define void @test_return_ref_arg() {
26  %a = alloca i32, align 4
27  %p = alloca i32*, align 8
28
29  store i32* %a, i32** %p
30  %b = call i32** @return_ref_arg_callee(i32* %a)
31
32  %lb = load i32*, i32** %b
33  %lp = load i32*, i32** %p
34
35  ret void
36}