1*9880d681SAndroid Build Coastguard Worker; This testcase ensures that CFL AA answers queries soundly when callee tries 2*9880d681SAndroid Build Coastguard Worker; to return the reference of one of its parameters 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -disable-basicaa -cfl-steens-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s 5*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -aa-pipeline=cfl-steens-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workerdeclare noalias i8* @malloc(i64) 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine i32** @return_ref_arg_callee(i32* %arg1) { 10*9880d681SAndroid Build Coastguard Worker %ptr = call noalias i8* @malloc(i64 8) 11*9880d681SAndroid Build Coastguard Worker %ptr_cast = bitcast i8* %ptr to i32** 12*9880d681SAndroid Build Coastguard Worker store i32* %arg1, i32** %ptr_cast 13*9880d681SAndroid Build Coastguard Worker ret i32** %ptr_cast 14*9880d681SAndroid Build Coastguard Worker} 15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: Function: test_return_ref_arg 16*9880d681SAndroid Build Coastguard Worker; CHECK: MayAlias: i32* %a, i32* %lb 17*9880d681SAndroid Build Coastguard Worker; CHECK: NoAlias: i32* %lb, i32** %p 18*9880d681SAndroid Build Coastguard Worker; CHECK: NoAlias: i32* %lb, i32** %b 19*9880d681SAndroid Build Coastguard Worker; CHECK: NoAlias: i32* %lp, i32** %p 20*9880d681SAndroid Build Coastguard Worker; CHECK: NoAlias: i32* %lp, i32** %b 21*9880d681SAndroid Build Coastguard Worker; CHECK: MayAlias: i32* %lb, i32* %lp 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; We could've proven the following facts if the analysis were inclusion-based: 24*9880d681SAndroid Build Coastguard Worker; NoAlias: i32** %b, i32** %p 25*9880d681SAndroid Build Coastguard Workerdefine void @test_return_ref_arg() { 26*9880d681SAndroid Build Coastguard Worker %a = alloca i32, align 4 27*9880d681SAndroid Build Coastguard Worker %p = alloca i32*, align 8 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker store i32* %a, i32** %p 30*9880d681SAndroid Build Coastguard Worker %b = call i32** @return_ref_arg_callee(i32* %a) 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker %lb = load i32*, i32** %b 33*9880d681SAndroid Build Coastguard Worker %lp = load i32*, i32** %p 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker ret void 36*9880d681SAndroid Build Coastguard Worker}