[flang-commits] [flang] 868c212 - [flang] Keep fully qualified !fir.heap type for fir.freemem op

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Thu Mar 31 12:37:26 PDT 2022


Author: Valentin Clement
Date: 2022-03-31T21:37:21+02:00
New Revision: 868c212f42f80582fc6fb4adbd088e55b2d64111

URL: https://github.com/llvm/llvm-project/commit/868c212f42f80582fc6fb4adbd088e55b2d64111
DIFF: https://github.com/llvm/llvm-project/commit/868c212f42f80582fc6fb4adbd088e55b2d64111.diff

LOG: [flang] Keep fully qualified !fir.heap type for fir.freemem op

Re-introduce a fully qualified type on teh fir.freemem operation.
Since this is the only operation where the prefix gets elided in fir, this
patch make it fully qualified so the dialect syntax feels more consistent.

Reviewed By: vdonaldson

Differential Revision: https://reviews.llvm.org/D122839

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIROps.td
    flang/test/Fir/array-value-copy.fir
    flang/test/Fir/fir-ops.fir
    flang/test/Lower/Intrinsics/matmul.f90
    flang/test/Lower/Intrinsics/repeat.f90
    flang/test/Lower/Intrinsics/transpose.f90
    flang/test/Lower/Intrinsics/trim.f90

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index f667709836236..262d95327cae2 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -250,7 +250,7 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
 
   let arguments = (ins Arg<fir_HeapType, "", [MemFree]>:$heapref);
 
-  let assemblyFormat = "$heapref attr-dict `:` type($heapref)";
+  let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
 def fir_LoadOp : fir_OneResultOp<"load"> {

diff  --git a/flang/test/Fir/array-value-copy.fir b/flang/test/Fir/array-value-copy.fir
index 59c2a2b735763..f6cbe556d764b 100644
--- a/flang/test/Fir/array-value-copy.fir
+++ b/flang/test/Fir/array-value-copy.fir
@@ -130,7 +130,7 @@ func @conversion_with_temporary(%arr0 : !fir.ref<!fir.array<10xi32>>) {
 // CHECK:           fir.store %[[LOAD0]] to %[[COOR1]] : !fir.ref<i32>
 // CHECK:         }
 // Free temporary array.
-// CHECK:         fir.freemem %[[TEMP]] : <!fir.array<10xi32>>
+// CHECK:         fir.freemem %[[TEMP]] : !fir.heap<!fir.array<10xi32>>
 
 // -----
 
@@ -211,7 +211,7 @@ func @conversion_with_temporary_multidim(%0: !fir.ref<!fir.array<10x5xi32>>) {
 // CHECK:             %[[COOR1:.*]] = fir.array_coor %[[ARR0]](%{{.*}}) %{{.*}}, %{{.*}} : (!fir.ref<!fir.array<10x5xi32>>, !fir.shape<2>, index, index) -> !fir.ref<i32>
 // CHECK:             %[[LOAD0:.*]] = fir.load %[[COOR0]] : !fir.ref<i32>
 // CHECK:             fir.store %[[LOAD0]] to %[[COOR1]] : !fir.ref<i32>
-// CHECK:         fir.freemem %[[TEMP]] : <!fir.array<10x5xi32>>
+// CHECK:         fir.freemem %[[TEMP]] : !fir.heap<!fir.array<10x5xi32>>
 
 // -----
 
@@ -309,7 +309,7 @@ func private @user_defined_assignment(!fir.ref<f32>, !fir.ref<f32>)
 // CHECK:             fir.store %[[LOAD0]] to %[[COOR1]] : !fir.ref<f32>
 // CHECK:           }
 // Free the temporary array.
-// CHECK:           fir.freemem %[[TEMP]] : <!fir.array<100xf32>>
+// CHECK:           fir.freemem %[[TEMP]] : !fir.heap<!fir.array<100xf32>>
 // CHECK:           return
 // CHECK:         }
 
@@ -425,7 +425,7 @@ func @conversion_with_temporary_boxed_array(%arr0 : !fir.box<!fir.array<10xi32>>
 // CHECK:           fir.store %[[LOAD0]] to %[[COOR1]] : !fir.ref<i32>
 // CHECK:         }
 // Free temporary array.
-// CHECK:         fir.freemem %[[TEMP]] : <!fir.array<10xi32>>
+// CHECK:         fir.freemem %[[TEMP]] : !fir.heap<!fir.array<10xi32>>
 
 // -----
 

diff  --git a/flang/test/Fir/fir-ops.fir b/flang/test/Fir/fir-ops.fir
index f7643bd4b3dfd..f23b03797776d 100644
--- a/flang/test/Fir/fir-ops.fir
+++ b/flang/test/Fir/fir-ops.fir
@@ -128,7 +128,7 @@ func @instructions() {
   %31 = fir.no_reassoc %29 : i64
 
 // CHECK: fir.call @user_i64([[VAL_35]]) : (i64) -> ()
-// CHECK: fir.freemem [[VAL_5]] : <!fir.array<100xf32>>
+// CHECK: fir.freemem [[VAL_5]] : !fir.heap<!fir.array<100xf32>>
 // CHECK: [[VAL_36:%.*]] = fir.call @get_func() : () -> (() -> ())
 // CHECK: fir.call [[VAL_36]]() : () -> ()
 // CHECK: [[VAL_37:%.*]] = fir.address_of(@it1) : !fir.ref<() -> !fir.int<4>>

diff  --git a/flang/test/Lower/Intrinsics/matmul.f90 b/flang/test/Lower/Intrinsics/matmul.f90
index 6c3c721063c9f..dedd09cae99fe 100644
--- a/flang/test/Lower/Intrinsics/matmul.f90
+++ b/flang/test/Lower/Intrinsics/matmul.f90
@@ -32,7 +32,7 @@
 ! CHECK:    fir.result
 ! CHECK:  }
 ! CHECK:  fir.array_merge_store %[[Z_BOX]], %[[Z_COPY_FROM_RESULT]] to %[[Z]] : !fir.array<2x2xf32>, !fir.array<2x2xf32>, !fir.ref<!fir.array<2x2xf32>>
-! CHECK:  fir.freemem %[[RESULT_TMP]] : <!fir.array<?x?xf32>>
+! CHECK:  fir.freemem %[[RESULT_TMP]] : !fir.heap<!fir.array<?x?xf32>>
 subroutine matmul_test(x,y,z)
   real :: x(3,1), y(1,3), z(2,2)
   z = matmul(x,y)
@@ -59,7 +59,7 @@ subroutine matmul_test(x,y,z)
 !CHECK:    fir.result
 !CHECK:  }
 !CHECK:  fir.array_merge_store %[[Z]], %[[Z_COPY_FROM_RESULT]] to %[[Z_BOX]] : !fir.array<?x!fir.logical<4>>, !fir.array<?x!fir.logical<4>>, !fir.box<!fir.array<?x!fir.logical<4>>>
-!CHECK:  fir.freemem %[[RESULT_TMP]] : <!fir.array<?x!fir.logical<4>>>
+!CHECK:  fir.freemem %[[RESULT_TMP]] : !fir.heap<!fir.array<?x!fir.logical<4>>>
 subroutine matmul_test2(X, Y, Z)
   logical :: X(:,:)
   logical :: Y(:)

diff  --git a/flang/test/Lower/Intrinsics/repeat.f90 b/flang/test/Lower/Intrinsics/repeat.f90
index f6e8452634abf..9b068e10cfded 100644
--- a/flang/test/Lower/Intrinsics/repeat.f90
+++ b/flang/test/Lower/Intrinsics/repeat.f90
@@ -18,7 +18,7 @@ subroutine repeat_test(c, n)
   ! CHECK-DAG: fir.box_elesize
   ! CHECK: fir.call @{{.*}}bar_repeat_test
   call bar_repeat_test(repeat(c,n))
-  ! CHECK: fir.freemem %[[tmpAddr]] : <!fir.char<1,?>>
+  ! CHECK: fir.freemem %[[tmpAddr]] : !fir.heap<!fir.char<1,?>>
   return
 end subroutine
 

diff  --git a/flang/test/Lower/Intrinsics/transpose.f90 b/flang/test/Lower/Intrinsics/transpose.f90
index 62bea39648988..fefadd5039da5 100644
--- a/flang/test/Lower/Intrinsics/transpose.f90
+++ b/flang/test/Lower/Intrinsics/transpose.f90
@@ -19,6 +19,6 @@ subroutine transpose_test(mat)
 ! CHECK:  %[[tmp2:.*]] = fir.box_addr %[[tmp1]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
 ! CHECK:  %[[tmp3:.*]] = fir.convert %[[tmp2]] : (!fir.heap<!fir.array<?x?xf32>>) -> !fir.ref<!fir.array<3x2xf32>>
 ! CHECK:  fir.call @_QPbar_transpose_test(%[[tmp3]]) : (!fir.ref<!fir.array<3x2xf32>>) -> ()
-! CHECK:  fir.freemem %[[tmp2]] : <!fir.array<?x?xf32>
+! CHECK:  fir.freemem %[[tmp2]] : !fir.heap<!fir.array<?x?xf32>
 end subroutine
 

diff  --git a/flang/test/Lower/Intrinsics/trim.f90 b/flang/test/Lower/Intrinsics/trim.f90
index 35ea606c34bfb..360921162193a 100644
--- a/flang/test/Lower/Intrinsics/trim.f90
+++ b/flang/test/Lower/Intrinsics/trim.f90
@@ -15,7 +15,7 @@ subroutine trim_test(c)
   ! CHECK-DAG: fir.box_elesize
   ! CHECK: fir.call @{{.*}}bar_trim_test
   call bar_trim_test(trim(c))
-  ! CHECK: fir.freemem %[[tmpAddr]] : <!fir.char<1,?>>
+  ! CHECK: fir.freemem %[[tmpAddr]] : !fir.heap<!fir.char<1,?>>
   return
 end subroutine
 


        


More information about the flang-commits mailing list