Skip to content

Commit

Permalink
Revert "[mlir] Enable opaque pointers in LLVM conversion passes by de…
Browse files Browse the repository at this point in the history
…fault"

This reverts commit 552522b.

There are test failures in integration tests for GPU builds
  • Loading branch information
zero9178 committed Mar 10, 2023
1 parent 552522b commit cdd914a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
8 changes: 1 addition & 7 deletions flang/lib/Optimizer/CodeGen/TypeConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 17 additions & 16 deletions mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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">,
];
}
Expand Down Expand Up @@ -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">,
];
}
Expand Down Expand Up @@ -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">,
];
}
Expand Down Expand Up @@ -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">,
];

Expand All @@ -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">
];

Expand All @@ -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">,
];
}
Expand Down Expand Up @@ -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">,
];
}
Expand Down Expand Up @@ -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">
];

Expand Down Expand Up @@ -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">
];
}

Expand Down Expand Up @@ -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">
];
}
Expand Down Expand Up @@ -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">
];
}
Expand All @@ -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">,
];
}
Expand Down Expand Up @@ -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">
];

Expand Down Expand Up @@ -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">
];
}
Expand Down Expand Up @@ -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">
];
}
Expand Down
2 changes: 2 additions & 0 deletions mlir/test/mlir-cpu-runner/bare-ptr-call-conv.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cdd914a

Please sign in to comment.