@@ -39,7 +39,7 @@ writes needs to dominate all buffer reads.
39
39
Example for breaking the invariant:
40
40
41
41
``` mlir
42
- func @condBranch(%arg0: i1, %arg1: memref<2xf32>) {
42
+ func.func @condBranch(%arg0: i1, %arg1: memref<2xf32>) {
43
43
%0 = memref.alloc() : memref<2xf32>
44
44
cf.cond_br %arg0, ^bb1, ^bb2
45
45
^bb1:
@@ -71,7 +71,7 @@ BufferDeallocation is fully compatible with “hybrid” setups in which tracked
71
71
untracked allocations are mixed:
72
72
73
73
``` mlir
74
- func @mixedAllocation(%arg0: i1) {
74
+ func.func @mixedAllocation(%arg0: i1) {
75
75
%0 = memref.alloca() : memref<2xf32> // aliases: %2
76
76
%1 = memref.alloc() : memref<2xf32> // aliases: %2
77
77
cf.cond_br %arg0, ^bb1, ^bb2
@@ -128,7 +128,7 @@ BufferHoisting pass:
128
128
![ branch_example_pre_move] ( /includes/img/branch_example_pre_move.svg )
129
129
130
130
``` mlir
131
- func @condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
131
+ func.func @condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
132
132
cf.cond_br %arg0, ^bb1, ^bb2
133
133
^bb1:
134
134
cf.br ^bb3(%arg1 : memref<2xf32>)
@@ -148,7 +148,7 @@ of code:
148
148
![ branch_example_post_move] ( /includes/img/branch_example_post_move.svg )
149
149
150
150
``` mlir
151
- func @condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
151
+ func.func @condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
152
152
%0 = memref.alloc() : memref<2xf32> // moved to bb0
153
153
cf.cond_br %arg0, ^bb1, ^bb2
154
154
^bb1:
@@ -170,7 +170,7 @@ Due to the data dependency of the allocation to %0, we cannot move the
170
170
allocation out of bb2 in this case:
171
171
172
172
``` mlir
173
- func @condBranchDynamicType(
173
+ func.func @condBranchDynamicType(
174
174
%arg0: i1,
175
175
%arg1: memref<?xf32>,
176
176
%arg2: memref<?xf32>,
@@ -199,7 +199,7 @@ copies to eliminate them. Consider the following example in which the
199
199
allocations have already been placed:
200
200
201
201
``` mlir
202
- func @branch(%arg0: i1) {
202
+ func.func @branch(%arg0: i1) {
203
203
%0 = memref.alloc() : memref<2xf32> // aliases: %2
204
204
cf.cond_br %arg0, ^bb1, ^bb2
205
205
^bb1:
@@ -231,7 +231,7 @@ Applying the BufferDeallocation pass to the program above yields the following
231
231
result:
232
232
233
233
``` mlir
234
- func @branch(%arg0: i1) {
234
+ func.func @branch(%arg0: i1) {
235
235
%0 = memref.alloc() : memref<2xf32>
236
236
cf.cond_br %arg0, ^bb1, ^bb2
237
237
^bb1:
@@ -268,7 +268,7 @@ and non-critical aliases:
268
268
![ nested_branch_example_pre_move] ( /includes/img/nested_branch_example_pre_move.svg )
269
269
270
270
``` mlir
271
- func @condBranchDynamicTypeNested(
271
+ func.func @condBranchDynamicTypeNested(
272
272
%arg0: i1,
273
273
%arg1: memref<?xf32>, // aliases: %3, %4
274
274
%arg2: memref<?xf32>,
@@ -301,7 +301,7 @@ Applying BufferDeallocation yields the following output:
301
301
![ nested_branch_example_post_move] ( /includes/img/nested_branch_example_post_move.svg )
302
302
303
303
``` mlir
304
- func @condBranchDynamicTypeNested(
304
+ func.func @condBranchDynamicTypeNested(
305
305
%arg0: i1,
306
306
%arg1: memref<?xf32>,
307
307
%arg2: memref<?xf32>,
@@ -379,7 +379,7 @@ the `RegionBranchOpInterface` to determine predecessors in order to infer the
379
379
high-level control flow:
380
380
381
381
``` mlir
382
- func @inner_region_control_flow(
382
+ func.func @inner_region_control_flow(
383
383
%arg0 : index,
384
384
%arg1 : index) -> memref<?x?xf32> {
385
385
%0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
@@ -403,7 +403,7 @@ dialect-specific operations. BufferDeallocation supports this behavior via the
403
403
operation to determine the value of %2 at runtime which creates an alias:
404
404
405
405
``` mlir
406
- func @nested_region_control_flow(%arg0 : index, %arg1 : index) -> memref<?x?xf32> {
406
+ func.func @nested_region_control_flow(%arg0 : index, %arg1 : index) -> memref<?x?xf32> {
407
407
%0 = arith.cmpi "eq", %arg0, %arg1 : index
408
408
%1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
409
409
%2 = scf.if %0 -> (memref<?x?xf32>) {
@@ -424,7 +424,7 @@ block since it cannot be accessed by the remainder of the program. Accessing the
424
424
%1 which does not need to be tracked.
425
425
426
426
``` mlir
427
- func @nested_region_control_flow(%arg0: index, %arg1: index) -> memref<?x?xf32> {
427
+ func.func @nested_region_control_flow(%arg0: index, %arg1: index) -> memref<?x?xf32> {
428
428
%0 = arith.cmpi "eq", %arg0, %arg1 : index
429
429
%1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
430
430
%2 = scf.if %0 -> (memref<?x?xf32>) {
@@ -448,7 +448,7 @@ Reconsider a slightly adapted version of the “custom.region_if” example from
448
448
above that uses a nested allocation:
449
449
450
450
``` mlir
451
- func @inner_region_control_flow_div(
451
+ func.func @inner_region_control_flow_div(
452
452
%arg0 : index,
453
453
%arg1 : index) -> memref<?x?xf32> {
454
454
%0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
@@ -471,7 +471,7 @@ Furthermore, %arg4 is returned to its parent operation and has an alias %1. This
471
471
causes BufferDeallocation to introduce additional copies:
472
472
473
473
``` mlir
474
- func @inner_region_control_flow_div(
474
+ func.func @inner_region_control_flow_div(
475
475
%arg0 : index,
476
476
%arg1 : index) -> memref<?x?xf32> {
477
477
%0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
@@ -509,7 +509,7 @@ Consider the following “scf.for” use case containing a nested structured
509
509
control-flow if:
510
510
511
511
``` mlir
512
- func @loop_nested_if(
512
+ func.func @loop_nested_if(
513
513
%lb: index,
514
514
%ub: index,
515
515
%step: index,
@@ -547,7 +547,7 @@ buffer, we have to free the buffer from the previous iteration to avoid memory
547
547
leaks:
548
548
549
549
``` mlir
550
- func @loop_nested_if(
550
+ func.func @loop_nested_if(
551
551
%lb: index,
552
552
%ub: index,
553
553
%step: index,
@@ -624,7 +624,7 @@ analysis of this sample reveals that the highlighted operations are redundant
624
624
and can be removed.
625
625
626
626
``` mlir
627
- func @dynamic_allocation(%arg0: index, %arg1: index) -> memref<?x?xf32> {
627
+ func.func @dynamic_allocation(%arg0: index, %arg1: index) -> memref<?x?xf32> {
628
628
%1 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
629
629
%2 = bufferization.clone %1 : (memref<?x?xf32>) -> (memref<?x?xf32>)
630
630
memref.dealloc %1 : memref<?x?xf32>
@@ -635,7 +635,7 @@ func @dynamic_allocation(%arg0: index, %arg1: index) -> memref<?x?xf32> {
635
635
Will be transformed to:
636
636
637
637
``` mlir
638
- func @dynamic_allocation(%arg0: index, %arg1: index) -> memref<?x?xf32> {
638
+ func.func @dynamic_allocation(%arg0: index, %arg1: index) -> memref<?x?xf32> {
639
639
%1 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
640
640
return %1 : memref<?x?xf32>
641
641
}
@@ -656,7 +656,7 @@ merged into a single step. Canonicalization removes the clone operation and
656
656
%temp, and replaces the uses of %temp with %result:
657
657
658
658
``` mlir
659
- func @reuseTarget(%arg0: memref<2xf32>, %result: memref<2xf32>){
659
+ func.func @reuseTarget(%arg0: memref<2xf32>, %result: memref<2xf32>){
660
660
%temp = memref.alloc() : memref<2xf32>
661
661
test.generic {
662
662
args_in = 1 : i64,
@@ -676,7 +676,7 @@ func @reuseTarget(%arg0: memref<2xf32>, %result: memref<2xf32>){
676
676
Will be transformed to:
677
677
678
678
``` mlir
679
- func @reuseTarget(%arg0: memref<2xf32>, %result: memref<2xf32>){
679
+ func.func @reuseTarget(%arg0: memref<2xf32>, %result: memref<2xf32>){
680
680
test.generic {
681
681
args_in = 1 : i64,
682
682
args_out = 1 : i64,
0 commit comments