[Mlir-commits] [mlir] 946f803 - Reland "[mlir] Enable opaque pointers in LLVM conversion passes by default"

Markus Böck llvmlistbot at llvm.org
Fri Mar 10 02:26:20 PST 2023


Author: Markus Böck
Date: 2023-03-10T11:24:58+01:00
New Revision: 946f8030b58d3d6975369c1b8e047385b86c7ab0

URL: https://github.com/llvm/llvm-project/commit/946f8030b58d3d6975369c1b8e047385b86c7ab0
DIFF: https://github.com/llvm/llvm-project/commit/946f8030b58d3d6975369c1b8e047385b86c7ab0.diff

LOG: Reland "[mlir] Enable opaque pointers in LLVM conversion passes by default"

This reverts commit cdd914a959528cd7abf36c096b4a0644c1721214.

Added: 
    

Modified: 
    flang/lib/Optimizer/CodeGen/TypeConverter.h
    mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
    mlir/include/mlir/Conversion/Passes.td
    mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h
index c97400180a64c..36c02b8ff71c8 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -47,7 +47,13 @@ namespace fir {
 class LLVMTypeConverter : public mlir::LLVMTypeConverter {
 public:
   LLVMTypeConverter(mlir::ModuleOp module, bool applyTBAA)
-      : mlir::LLVMTypeConverter(module.getContext()),
+      : mlir::LLVMTypeConverter(module.getContext(),
+                                [&] {
+                                  mlir::LowerToLLVMOptions options(
+                                      module.getContext());
+                                  options.useOpaquePointers = false;
+                                  return options;
+                                }()),
         kindMapping(getKindMapping(module)),
         specifics(CodeGenSpecifics::get(module.getContext(),
                                         getTargetTriple(module),

diff  --git a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
index a3338ebf982c2..bc45fcd84e098 100644
--- a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
+++ b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
@@ -33,7 +33,7 @@ class LowerToLLVMOptions {
   LowerToLLVMOptions(MLIRContext *ctx, const DataLayout &dl);
 
   bool useBarePtrCallConv = false;
-  bool useOpaquePointers = false;
+  bool useOpaquePointers = true;
 
   enum class AllocLowering {
     /// Use malloc for for heap allocations.

diff  --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 700ed6109ae34..690958b24a608 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -158,7 +158,7 @@ def ConvertAsyncToLLVMPass : Pass<"convert-async-to-llvm", "ModuleOp"> {
   ];
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-           /*default=*/"false", "Generate LLVM IR using opaque pointers "
+           /*default=*/"true", "Generate LLVM IR using opaque pointers "
            "instead of typed pointers">,
   ];
 }
@@ -251,7 +251,7 @@ def ConvertControlFlowToLLVMPass : Pass<"convert-cf-to-llvm", "ModuleOp"> {
            /*default=kDeriveIndexBitwidthFromDataLayout*/"0",
            "Bitwidth of the index type, 0 to use size of machine word">,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                   /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                   /*default=*/"true", "Generate LLVM IR using opaque pointers "
                    "instead of typed pointers">,
   ];
 }
@@ -314,7 +314,7 @@ def ConvertFuncToLLVMPass : Pass<"convert-func-to-llvm", "ModuleOp"> {
            "String description (LLVM format) of the data layout that is "
            "expected on the produced module">,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                       /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                       /*default=*/"true", "Generate LLVM IR using opaque pointers "
                        "instead of typed pointers">,
   ];
 }
@@ -362,7 +362,7 @@ def GpuToLLVMConversionPass : Pass<"gpu-to-llvm", "ModuleOp"> {
                "Annotation attribute string for GPU binary"
                >,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-               /*default=*/"false", "Generate LLVM IR using opaque pointers "
+               /*default=*/"true", "Generate LLVM IR using opaque pointers "
                "instead of typed pointers">,
   ];
 
@@ -388,7 +388,7 @@ def LowerHostCodeToLLVMPass : Pass<"lower-host-to-llvm", "ModuleOp"> {
 
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                 /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"true", "Generate LLVM IR using opaque pointers "
                  "instead of typed pointers">
   ];
 
@@ -414,7 +414,7 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
     Option<"hasRedux", "has-redux", "bool", /*default=*/"false",
            "Target gpu supports redux">,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                   /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                   /*default=*/"true", "Generate LLVM IR using opaque pointers "
                    "instead of typed pointers">,
   ];
 }
@@ -451,7 +451,7 @@ def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
             clEnumValN(::mlir::gpu::amd::Runtime::OpenCL, "OpenCL", "OpenCL")
           )}]>,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-               /*default=*/"false", "Generate LLVM IR using opaque pointers "
+               /*default=*/"true", "Generate LLVM IR using opaque pointers "
                "instead of typed pointers">,
   ];
 }
@@ -507,7 +507,7 @@ def ConvertVulkanLaunchFuncToVulkanCallsPass
 
   let options = [
      Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-            /*default=*/"false", "Generate LLVM IR using opaque pointers "
+            /*default=*/"true", "Generate LLVM IR using opaque pointers "
             "instead of typed pointers">
   ];
 
@@ -545,11 +545,10 @@ def ConvertLinalgToLLVMPass : Pass<"convert-linalg-to-llvm", "ModuleOp"> {
   let summary = "Convert the operations from the linalg dialect into the LLVM "
                 "dialect";
   let dependentDialects = ["scf::SCFDialect", "LLVM::LLVMDialect"];
-
   let options = [
      Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-            /*default=*/"false", "Generate LLVM IR using opaque pointers "
-            "instead of typed pointers">
+                /*default=*/"true", "Generate LLVM IR using opaque pointers "
+                "instead of typed pointers">
   ];
 }
 
@@ -657,7 +656,7 @@ def FinalizeMemRefToLLVMConversionPass :
            "Use generic allocation and deallocation functions instead of the "
            "classic 'malloc', 'aligned_alloc' and 'free' functions">,
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-               /*default=*/"false", "Generate LLVM IR using opaque pointers "
+               /*default=*/"true", "Generate LLVM IR using opaque pointers "
                "instead of typed pointers">
   ];
 }
@@ -702,7 +701,7 @@ def ConvertNVGPUToNVVMPass : Pass<"convert-nvgpu-to-nvvm"> {
   ];
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-              /*default=*/"false", "Generate LLVM IR using opaque pointers "
+              /*default=*/"true", "Generate LLVM IR using opaque pointers "
               "instead of typed pointers">
   ];
 }
@@ -727,7 +726,7 @@ def ConvertOpenACCToLLVMPass : Pass<"convert-openacc-to-llvm", "ModuleOp"> {
   let dependentDialects = ["LLVM::LLVMDialect"];
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-           /*default=*/"false", "Generate LLVM IR using opaque pointers "
+           /*default=*/"true", "Generate LLVM IR using opaque pointers "
            "instead of typed pointers">,
   ];
 }
@@ -798,7 +797,7 @@ def ConvertSCFToOpenMPPass : Pass<"convert-scf-to-openmp", "ModuleOp"> {
 
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                 /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"true", "Generate LLVM IR using opaque pointers "
                  "instead of typed pointers">
   ];
 
@@ -888,7 +887,7 @@ def ConvertSPIRVToLLVMPass : Pass<"convert-spirv-to-llvm", "ModuleOp"> {
 
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                 /*default=*/"false", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"true", "Generate LLVM IR using opaque pointers "
                  "instead of typed pointers">
   ];
 }
@@ -1098,7 +1097,7 @@ def ConvertVectorToLLVMPass : Pass<"convert-vector-to-llvm", "ModuleOp"> {
            "Enables the use of X86Vector dialect while lowering the vector "
 	   "dialect.">,
 	  Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-               /*default=*/"false", "Generate LLVM IR using opaque pointers "
+               /*default=*/"true", "Generate LLVM IR using opaque pointers "
                "instead of typed pointers">
   ];
 }

diff  --git a/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir b/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
index b934480c923bf..8bbaf3fbcd5f3 100644
--- a/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
+++ b/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
@@ -26,8 +26,6 @@ func.func @simple_add1_add2_test(%arg0: memref<2xf32>, %arg1: memref<2xf32>) {
 }
 
 // External declarations.
-llvm.func @malloc(i64) -> !llvm.ptr<i8>
-llvm.func @free(!llvm.ptr<i8>)
 func.func private @printF32(%arg0: f32)
 func.func private @printComma()
 func.func private @printNewline()


        


More information about the Mlir-commits mailing list