[Mlir-commits] [mlir] 83b5979 - [mlir][LLVM] Enable opaque-pointers in e2e lowering test pass

Markus Böck llvmlistbot at llvm.org
Fri Feb 24 05:29:48 PST 2023


Author: Markus Böck
Date: 2023-02-24T14:29:01+01:00
New Revision: 83b59792bb0f0fd69213f5fb5a6385d3d3b78945

URL: https://github.com/llvm/llvm-project/commit/83b59792bb0f0fd69213f5fb5a6385d3d3b78945
DIFF: https://github.com/llvm/llvm-project/commit/83b59792bb0f0fd69213f5fb5a6385d3d3b78945.diff

LOG: [mlir][LLVM] Enable opaque-pointers in e2e lowering test pass

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

Given this is only a test pass I believe it should be fine to switch it to opaque-pointers entirely while migrating.

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

Added: 
    

Modified: 
    mlir/test/Dialect/LLVM/lower-to-llvm-e2e.mlir
    mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/LLVM/lower-to-llvm-e2e.mlir b/mlir/test/Dialect/LLVM/lower-to-llvm-e2e.mlir
index 998650a7aeceb..5dbdbbfdbc39e 100644
--- a/mlir/test/Dialect/LLVM/lower-to-llvm-e2e.mlir
+++ b/mlir/test/Dialect/LLVM/lower-to-llvm-e2e.mlir
@@ -6,8 +6,8 @@
 func.func @subview(%0 : memref<64x4xf32, strided<[4, 1], offset: 0>>, %arg0 : index, %arg1 : index, %arg2 : index)
 -> memref<?x?xf32, strided<[?, ?], offset: ?>> {
   // CHECK-LABEL: @subview
-  // CHECK-SAME: %[[BASE:[^:]*]]: !llvm.ptr<f32>,
-  // CHECK-SAME: %[[BASE_ALIGNED:[^:]*]]: !llvm.ptr<f32>,
+  // CHECK-SAME: %[[BASE:[^:]*]]: !llvm.ptr
+  // CHECK-SAME: %[[BASE_ALIGNED:[^:]*]]: !llvm.ptr,
   // CHECK-SAME: %[[BASE_OFFSET:[^:]*]]: i64,
   // CHECK-SAME: %[[BASE_STRIDE0:[^:]*]]: i64,
   // CHECK-SAME: %[[BASE_STRIDE1:[^:]*]]: i64,
@@ -16,27 +16,27 @@ func.func @subview(%0 : memref<64x4xf32, strided<[4, 1], offset: 0>>, %arg0 : in
   // CHECK-SAME: %[[ARG0:[^:]*]]: i64,
   // CHECK-SAME: %[[ARG1:[^:]*]]: i64,
   // CHECK-SAME: %[[ARG2:[^:]*]]: i64)
-  // CHECK-SAME: -> !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>
+  // CHECK-SAME: -> !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>
 
   // CHECK-DAG: %[[STRIDE0:.*]] = llvm.mlir.constant(4 : index) : i64
   // CHECK-DAG: %[[DESCSTRIDE0:.*]] = llvm.mul %[[ARG0]], %[[STRIDE0]] : i64
   // CHECK-DAG: %[[OFF2:.*]] = llvm.add %[[DESCSTRIDE0]], %[[ARG1]] : i64
-  // CHECK-DAG: %[[DESC:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK-DAG: %[[DESC:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
 
   // Base address and algined address.
-  // CHECK-DAG: %[[DESC0:.*]] = llvm.insertvalue %[[BASE]], %[[DESC]][0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
-  // CHECK-DAG: %[[DESC1:.*]] = llvm.insertvalue %[[BASE_ALIGNED]], %[[DESC0]][1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK-DAG: %[[DESC0:.*]] = llvm.insertvalue %[[BASE]], %[[DESC]][0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK-DAG: %[[DESC1:.*]] = llvm.insertvalue %[[BASE_ALIGNED]], %[[DESC0]][1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
 
   // Offset.
-  // CHECK: %[[DESC2:.*]] = llvm.insertvalue %[[OFF2]], %[[DESC1]][2] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK: %[[DESC2:.*]] = llvm.insertvalue %[[OFF2]], %[[DESC1]][2] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
   // Size 0.
-  // CHECK: %[[DESC3:.*]] = llvm.insertvalue %[[ARG0]], %[[DESC2]][3, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK: %[[DESC3:.*]] = llvm.insertvalue %[[ARG0]], %[[DESC2]][3, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
   // Stride 0 == 4 * %arg0.
-  // CHECK: %[[DESC4:.*]] = llvm.insertvalue %[[DESCSTRIDE0]], %[[DESC3]][4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK: %[[DESC4:.*]] = llvm.insertvalue %[[DESCSTRIDE0]], %[[DESC3]][4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
   // Size 1.
-  // CHECK: %[[DESC5:.*]] = llvm.insertvalue %[[ARG1]], %[[DESC4]][3, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK: %[[DESC5:.*]] = llvm.insertvalue %[[ARG1]], %[[DESC4]][3, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
   // Stride 1 == 1 * %arg1.
-  // CHECK: %[[DESC6:.*]] = llvm.insertvalue %[[ARG1]], %[[DESC5]][4, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
+  // CHECK: %[[DESC6:.*]] = llvm.insertvalue %[[ARG1]], %[[DESC5]][4, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
 
   %1 = memref.subview %0[%arg0, %arg1][%arg0, %arg1][%arg0, %arg1] :
     memref<64x4xf32, strided<[4, 1], offset: 0>>

diff  --git a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
index f3506226b16c1..e647f2025a047 100644
--- a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
+++ b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
@@ -49,6 +49,11 @@ void buildTestLowerToLLVM(OpPassManager &pm,
   // unrealized casts, but there needs to be the final module-wise cleanup in
   // the end. Keep module-level for now.
 
+  auto enableOpaquePointers = [](auto options) {
+    options.useOpaquePointers = true;
+    return options;
+  };
+
   // Blanket-convert any remaining high-level vector ops to loops if any remain.
   pm.addNestedPass<func::FuncOp>(createConvertVectorToSCFPass());
   // Blanket-convert any remaining linalg ops to loops if any remain.
@@ -65,7 +70,8 @@ void buildTestLowerToLLVM(OpPassManager &pm,
   // Convert vector to LLVM (always needed).
   pm.addPass(createConvertVectorToLLVMPass(
       // TODO: add more options on a per-need basis.
-      ConvertVectorToLLVMPassOptions{options.reassociateFPReductions}));
+      enableOpaquePointers(
+          ConvertVectorToLLVMPassOptions{options.reassociateFPReductions})));
   // Convert Math to LLVM (always needed).
   pm.addNestedPass<func::FuncOp>(createConvertMathToLLVMPass());
   // Expand complicated MemRef operations before lowering them.
@@ -73,9 +79,11 @@ void buildTestLowerToLLVM(OpPassManager &pm,
   // The expansion may create affine expressions. Get rid of them.
   pm.addPass(createLowerAffinePass());
   // Convert MemRef to LLVM (always needed).
-  pm.addPass(createFinalizeMemRefToLLVMConversionPass());
+  pm.addPass(createFinalizeMemRefToLLVMConversionPass(
+      enableOpaquePointers(FinalizeMemRefToLLVMConversionPassOptions{})));
   // Convert Func to LLVM (always needed).
-  pm.addPass(createConvertFuncToLLVMPass());
+  pm.addPass(createConvertFuncToLLVMPass(
+      enableOpaquePointers(ConvertFuncToLLVMPassOptions{})));
   // Convert Index to LLVM (always needed).
   pm.addPass(createConvertIndexToLLVMPass());
   // Convert remaining unrealized_casts (always needed).


        


More information about the Mlir-commits mailing list