[Mlir-commits] [mlir] cdd914a - Revert "[mlir] Enable opaque pointers in LLVM conversion passes by default"

Markus Böck llvmlistbot at llvm.org
Thu Mar 9 23:52:06 PST 2023


Author: Markus Böck
Date: 2023-03-10T08:52:07+01:00
New Revision: cdd914a959528cd7abf36c096b4a0644c1721214

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

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

This reverts commit 552522bef66c56dc4336d5948662f295dd733c0d.

There are test failures in integration tests for GPU builds

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 36c02b8ff71c..c97400180a64 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -47,13 +47,7 @@ namespace fir {
 class LLVMTypeConverter : public mlir::LLVMTypeConverter {
 public:
   LLVMTypeConverter(mlir::ModuleOp module, bool applyTBAA)
-      : mlir::LLVMTypeConverter(module.getContext(),
-                                [&] {
-                                  mlir::LowerToLLVMOptions options(
-                                      module.getContext());
-                                  options.useOpaquePointers = false;
-                                  return options;
-                                }()),
+      : mlir::LLVMTypeConverter(module.getContext()),
         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 bc45fcd84e09..a3338ebf982c 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 = true;
+  bool useOpaquePointers = false;
 
   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 690958b24a60..700ed6109ae3 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=*/"true", "Generate LLVM IR using opaque pointers "
+           /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+                   /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+                       /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+               /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+                   /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+               /*default=*/"false", "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=*/"true", "Generate LLVM IR using opaque pointers "
+            /*default=*/"false", "Generate LLVM IR using opaque pointers "
             "instead of typed pointers">
   ];
 
@@ -545,10 +545,11 @@ 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=*/"true", "Generate LLVM IR using opaque pointers "
-                "instead of typed pointers">
+            /*default=*/"false", "Generate LLVM IR using opaque pointers "
+            "instead of typed pointers">
   ];
 }
 
@@ -656,7 +657,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=*/"true", "Generate LLVM IR using opaque pointers "
+               /*default=*/"false", "Generate LLVM IR using opaque pointers "
                "instead of typed pointers">
   ];
 }
@@ -701,7 +702,7 @@ def ConvertNVGPUToNVVMPass : Pass<"convert-nvgpu-to-nvvm"> {
   ];
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-              /*default=*/"true", "Generate LLVM IR using opaque pointers "
+              /*default=*/"false", "Generate LLVM IR using opaque pointers "
               "instead of typed pointers">
   ];
 }
@@ -726,7 +727,7 @@ def ConvertOpenACCToLLVMPass : Pass<"convert-openacc-to-llvm", "ModuleOp"> {
   let dependentDialects = ["LLVM::LLVMDialect"];
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-           /*default=*/"true", "Generate LLVM IR using opaque pointers "
+           /*default=*/"false", "Generate LLVM IR using opaque pointers "
            "instead of typed pointers">,
   ];
 }
@@ -797,7 +798,7 @@ def ConvertSCFToOpenMPPass : Pass<"convert-scf-to-openmp", "ModuleOp"> {
 
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                 /*default=*/"true", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"false", "Generate LLVM IR using opaque pointers "
                  "instead of typed pointers">
   ];
 
@@ -887,7 +888,7 @@ def ConvertSPIRVToLLVMPass : Pass<"convert-spirv-to-llvm", "ModuleOp"> {
 
   let options = [
     Option<"useOpaquePointers", "use-opaque-pointers", "bool",
-                 /*default=*/"true", "Generate LLVM IR using opaque pointers "
+                 /*default=*/"false", "Generate LLVM IR using opaque pointers "
                  "instead of typed pointers">
   ];
 }
@@ -1097,7 +1098,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=*/"true", "Generate LLVM IR using opaque pointers "
+               /*default=*/"false", "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 8bbaf3fbcd5f..b934480c923b 100644
--- a/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
+++ b/mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
@@ -26,6 +26,8 @@ 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