Home | History | Annotate | Download | only in Steensgaard
      1 ; This testcase ensures that CFL AA handles escaped values no more conservative than it should
      2 
      3 ; RUN: opt < %s -disable-basicaa -cfl-steens-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
      4 ; RUN: opt < %s -aa-pipeline=cfl-steens-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
      5 
      6 ; CHECK-LABEL: Function: test_local
      7 ; CHECK: NoAlias: i32* %a, i32* %b
      8 ; CHECK: MayAlias: i32* %a, i32* %aAlias
      9 ; CHECK: NoAlias: i32* %aAlias, i32* %b
     10 define void @test_local() {
     11 	%a = alloca i32, align 4
     12 	%b = alloca i32, align 4
     13 	%aint = ptrtoint i32* %a to i64
     14 	%aAlias = inttoptr i64 %aint to i32*
     15 	ret void
     16 }
     17 
     18 ; CHECK-LABEL: Function: test_global_param
     19 ; CHECK: NoAlias: i32* %a, i32** %x
     20 ; CHECK: MayAlias: i32* %a, i32* %xload
     21 ; CHECK: MayAlias: i32* %a, i32* %gload
     22 ; CHECK: MayAlias: i32* %gload, i32* %xload
     23 ; CHECK: MayAlias: i32** %x, i32** @ext_global
     24 ; CHECK: NoAlias: i32* %a, i32** @ext_global
     25 @ext_global = external global i32*
     26 define void @test_global_param(i32** %x) {
     27 	%a = alloca i32, align 4
     28 	%aint = ptrtoint i32* %a to i64
     29 	%xload = load i32*, i32** %x
     30 	%gload = load i32*, i32** @ext_global
     31 	ret void
     32 }
     33 
     34 declare void @external_func(i32**)
     35 ; CHECK-LABEL: Function: test_external_call
     36 ; CHECK: NoAlias: i32* %b, i32* %x
     37 ; CHECK: NoAlias: i32* %b, i32** %a
     38 ; CHECK: MayAlias: i32* %c, i32* %x
     39 ; CHECK: MayAlias: i32* %c, i32** %a
     40 ; CHECK: NoAlias: i32* %b, i32* %c
     41 define void @test_external_call(i32* %x) {
     42 	%a = alloca i32*, align 8
     43 	%b = alloca i32, align 4
     44 	call void @external_func(i32** %a)
     45 	%c = load i32*, i32** %a
     46 	ret void
     47 }
     48 
     49 declare void @external_func_readonly(i32**) readonly
     50 ; CHECK-LABEL: Function: test_external_call_func_readonly
     51 ; CHECK: MayAlias: i32* %c, i32* %x
     52 ; CHECK: NoAlias: i32* %c, i32** %a
     53 define void @test_external_call_func_readonly(i32* %x) {
     54 	%a = alloca i32*, align 8
     55 	%b = alloca i32, align 4
     56 	store i32* %x, i32** %a, align 4
     57 	call void @external_func_readonly(i32** %a)
     58 	%c = load i32*, i32** %a
     59 	ret void
     60 }
     61 
     62 ; CHECK-LABEL: Function: test_external_call_callsite_readonly
     63 ; CHECK: MayAlias: i32* %c, i32* %x
     64 ; CHECK: NoAlias: i32* %c, i32** %a
     65 define void @test_external_call_callsite_readonly(i32* %x) {
     66 	%a = alloca i32*, align 8
     67 	%b = alloca i32, align 4
     68 	store i32* %x, i32** %a, align 4
     69 	call void @external_func(i32** %a) readonly
     70 	%c = load i32*, i32** %a
     71 	ret void
     72 }
     73 
     74 declare i32* @external_func_normal_return(i32*)
     75 ; CHECK-LABEL: Function: test_external_call_normal_return
     76 ; CHECK: MayAlias: i32* %c, i32* %x
     77 ; CHECK: MayAlias: i32* %a, i32* %c
     78 define void @test_external_call_normal_return(i32* %x) {
     79 	%a = alloca i32, align 8
     80 	%b = alloca i32, align 4
     81 	%c = call i32* @external_func_normal_return(i32* %a)
     82 	ret void
     83 }
     84 
     85 declare noalias i32* @external_func_noalias_return(i32*)
     86 ; CHECK-LABEL: Function: test_external_call_noalias_return
     87 ; CHECK: NoAlias: i32* %c, i32* %x
     88 ; CHECK: NoAlias: i32* %a, i32* %c
     89 define void @test_external_call_noalias_return(i32* %x) {
     90 	%a = alloca i32, align 8
     91 	%b = alloca i32, align 4
     92 	%c = call i32* @external_func_noalias_return(i32* %a)
     93 	ret void
     94 }
     95