252
|
1 // RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(test-alias-analysis-modref))' -split-input-file -allow-unregistered-dialect 2>&1 | FileCheck %s
|
221
|
2
|
|
3 // CHECK-LABEL: Testing : "no_side_effects"
|
|
4 // CHECK: alloc -> func.region0#0: NoModRef
|
|
5 // CHECK: dealloc -> func.region0#0: NoModRef
|
|
6 // CHECK: return -> func.region0#0: NoModRef
|
236
|
7 func.func @no_side_effects(%arg: memref<2xf32>) attributes {test.ptr = "func"} {
|
221
|
8 %1 = memref.alloc() {test.ptr = "alloc"} : memref<8x64xf32>
|
|
9 memref.dealloc %1 {test.ptr = "dealloc"} : memref<8x64xf32>
|
|
10 return {test.ptr = "return"}
|
|
11 }
|
|
12
|
|
13 // -----
|
|
14
|
|
15 // CHECK-LABEL: Testing : "simple"
|
|
16 // CHECK-DAG: store -> alloc#0: Mod
|
|
17 // CHECK-DAG: load -> alloc#0: Ref
|
|
18
|
|
19 // CHECK-DAG: store -> func.region0#0: NoModRef
|
|
20 // CHECK-DAG: load -> func.region0#0: NoModRef
|
236
|
21 func.func @simple(%arg: memref<i32>, %value: i32) attributes {test.ptr = "func"} {
|
221
|
22 %1 = memref.alloca() {test.ptr = "alloc"} : memref<i32>
|
|
23 memref.store %value, %1[] {test.ptr = "store"} : memref<i32>
|
|
24 %2 = memref.load %1[] {test.ptr = "load"} : memref<i32>
|
|
25 return {test.ptr = "return"}
|
|
26 }
|
|
27
|
|
28 // -----
|
|
29
|
|
30 // CHECK-LABEL: Testing : "mayalias"
|
|
31 // CHECK-DAG: store -> func.region0#0: Mod
|
|
32 // CHECK-DAG: load -> func.region0#0: Ref
|
|
33
|
|
34 // CHECK-DAG: store -> func.region0#1: Mod
|
|
35 // CHECK-DAG: load -> func.region0#1: Ref
|
236
|
36 func.func @mayalias(%arg0: memref<i32>, %arg1: memref<i32>, %value: i32) attributes {test.ptr = "func"} {
|
221
|
37 memref.store %value, %arg1[] {test.ptr = "store"} : memref<i32>
|
|
38 %1 = memref.load %arg1[] {test.ptr = "load"} : memref<i32>
|
|
39 return {test.ptr = "return"}
|
|
40 }
|
|
41
|
|
42 // -----
|
|
43
|
|
44 // CHECK-LABEL: Testing : "recursive"
|
|
45 // CHECK-DAG: if -> func.region0#0: ModRef
|
|
46 // CHECK-DAG: if -> func.region0#1: ModRef
|
|
47
|
|
48 // TODO: This is provably NoModRef, but requires handling recursive side
|
|
49 // effects.
|
|
50 // CHECK-DAG: if -> alloc#0: ModRef
|
236
|
51 func.func @recursive(%arg0: memref<i32>, %arg1: memref<i32>, %cond: i1, %value: i32) attributes {test.ptr = "func"} {
|
221
|
52 %0 = memref.alloca() {test.ptr = "alloc"} : memref<i32>
|
|
53 scf.if %cond {
|
|
54 memref.store %value, %arg0[] : memref<i32>
|
|
55 %1 = memref.load %arg0[] : memref<i32>
|
|
56 } {test.ptr = "if"}
|
|
57 return {test.ptr = "return"}
|
|
58 }
|
|
59
|
|
60 // -----
|
|
61
|
|
62 // CHECK-LABEL: Testing : "unknown"
|
|
63 // CHECK-DAG: unknown -> func.region0#0: ModRef
|
236
|
64 func.func @unknown(%arg0: memref<i32>) attributes {test.ptr = "func"} {
|
221
|
65 "foo.op"() {test.ptr = "unknown"} : () -> ()
|
|
66 return
|
|
67 }
|