1; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" 4target triple = "i386-unknown-linux-gnu" 5 6declare i32* @random.i32(i32* %ptr) 7 8; CHECK-LABEL: Function: arr: 9; CHECK-DAG: MayAlias: i32* %alloca, i32* %p0 10; CHECK-DAG: NoAlias: i32* %alloca, i32* %p1 11define void @arr() { 12 %alloca = alloca i32, i32 4 13 %random = call i32* @random.i32(i32* %alloca) 14 %p0 = getelementptr inbounds i32, i32* %random, i32 0 15 %p1 = getelementptr inbounds i32, i32* %random, i32 1 16 ret void 17} 18 19; CHECK-LABEL: Function: arg: 20; CHECK-DAG: MayAlias: i32* %arg, i32* %p0 21; CHECK-DAG: MayAlias: i32* %arg, i32* %p1 22define void @arg(i32* %arg) { 23 %random = call i32* @random.i32(i32* %arg) 24 %p0 = getelementptr inbounds i32, i32* %random, i32 0 25 %p1 = getelementptr inbounds i32, i32* %random, i32 1 26 ret void 27} 28 29@gv = global i32 1 30; CHECK-LABEL: Function: global: 31; CHECK-DAG: MayAlias: i32* %p0, i32* @gv 32; CHECK-DAG: NoAlias: i32* %p1, i32* @gv 33define void @global() { 34 %random = call i32* @random.i32(i32* @gv) 35 %p0 = getelementptr inbounds i32, i32* %random, i32 0 36 %p1 = getelementptr inbounds i32, i32* %random, i32 1 37 ret void 38} 39 40; CHECK-LABEL: Function: struct: 41; CHECK-DAG: MayAlias: i32* %f0, i32* %p0 42; CHECK-DAG: MayAlias: i32* %f1, i32* %p0 43; CHECK-DAG: NoAlias: i32* %f0, i32* %p1 44; CHECK-DAG: MayAlias: i32* %f1, i32* %p1 45%struct = type { i32, i32, i32 } 46define void @struct() { 47 %alloca = alloca %struct 48 %alloca.i32 = bitcast %struct* %alloca to i32* 49 %random = call i32* @random.i32(i32* %alloca.i32) 50 %f0 = getelementptr inbounds %struct, %struct* %alloca, i32 0, i32 0 51 %f1 = getelementptr inbounds %struct, %struct* %alloca, i32 0, i32 1 52 %p0 = getelementptr inbounds i32, i32* %random, i32 0 53 %p1 = getelementptr inbounds i32, i32* %random, i32 1 54 ret void 55} 56 57; CHECK-LABEL: Function: complex1: 58; CHECK-DAG: MayAlias: i32* %a2.0, i32* %r2.0 59; CHECK-DAG: NoAlias: i32* %a2.0, i32* %r2.1 60; CHECK-DAG: MayAlias: i32* %a2.0, i32* %r2.i 61; CHECK-DAG: MayAlias: i32* %a2.0, i32* %r2.1i 62; CHECK-DAG: NoAlias: i32* %a1, i32* %r2.0 63; CHECK-DAG: NoAlias: i32* %a1, i32* %r2.1 64; CHECK-DAG: NoAlias: i32* %a1, i32* %r2.i 65; CHECK-DAG: NoAlias: i32* %a1, i32* %r2.1i 66%complex = type { i32, i32, [4 x i32] } 67define void @complex1(i32 %i) { 68 %alloca = alloca %complex 69 %alloca.i32 = bitcast %complex* %alloca to i32* 70 %r.i32 = call i32* @random.i32(i32* %alloca.i32) 71 %random = bitcast i32* %r.i32 to %complex* 72 %a1 = getelementptr inbounds %complex, %complex* %alloca, i32 0, i32 1 73 %a2.0 = getelementptr inbounds %complex, %complex* %alloca, i32 0, i32 2, i32 0 74 %r2.0 = getelementptr inbounds %complex, %complex* %random, i32 0, i32 2, i32 0 75 %r2.1 = getelementptr inbounds %complex, %complex* %random, i32 0, i32 2, i32 1 76 %r2.i = getelementptr inbounds %complex, %complex* %random, i32 0, i32 2, i32 %i 77 %r2.1i = getelementptr inbounds i32, i32* %r2.1, i32 %i 78 ret void 79} 80 81; CHECK-LABEL: Function: complex2: 82; CHECK-DAG: NoAlias: i32* %alloca, i32* %p120 83; CHECK-DAG: NoAlias: i32* %alloca, i32* %pi20 84; CHECK-DAG: NoAlias: i32* %alloca, i32* %pij1 85; CHECK-DAG: MayAlias: i32* %a3, i32* %pij1 86%inner = type { i32, i32 } 87%outer = type { i32, i32, [10 x %inner] } 88declare %outer* @rand_outer(i32* %p) 89define void @complex2(i32 %i, i32 %j) { 90 %alloca = alloca i32, i32 128 91 %a3 = getelementptr inbounds i32, i32* %alloca, i32 3 92 %random = call %outer* @rand_outer(i32* %alloca) 93 %p120 = getelementptr inbounds %outer, %outer* %random, i32 1, i32 2, i32 2, i32 0 94 %pi20 = getelementptr inbounds %outer, %outer* %random, i32 %i, i32 2, i32 2, i32 0 95 %pij1 = getelementptr inbounds %outer, %outer* %random, i32 %i, i32 2, i32 %j, i32 1 96 ret void 97} 98 99