Home | History | Annotate | Download | only in Steensgaard
      1 ; This testcase ensures that CFL AA answers queries soundly when callee tries 
      2 ; to return an escaped pointer
      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 
      7 declare noalias i8* @malloc(i64)
      8 declare void @opaque(i32*)
      9 
     10 define i32* @return_escaped_callee() {
     11 	%ptr = call noalias i8* @malloc(i64 8)
     12 	%ptr_cast = bitcast i8* %ptr to i32*
     13 	call void @opaque(i32* %ptr_cast)
     14 	ret i32* %ptr_cast
     15 }
     16 ; CHECK-LABEL: Function: test_return_escape
     17 ; CHECK: NoAlias: i32* %a, i32** %x
     18 ; CHECK: NoAlias: i32* %b, i32** %x
     19 ; CHECK: NoAlias: i32* %a, i32* %b
     20 ; CHECK: NoAlias: i32* %c, i32** %x
     21 ; CHECK: NoAlias: i32* %a, i32* %c
     22 ; CHECK: NoAlias: i32* %b, i32* %c
     23 ; CHECK: NoAlias: i32* %a, i32* %d
     24 ; CHECK: MayAlias: i32* %b, i32* %d
     25 ; CHECK: MayAlias: i32* %c, i32* %d
     26 define void @test_return_escape(i32** %x) {
     27   %a = alloca i32, align 4
     28   %b = call i32* @return_escaped_callee()
     29   %c = call i32* @return_escaped_callee()
     30   %d = load i32*, i32** %x
     31 
     32   ret void
     33 }