diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -52,8 +52,7 @@ /// By default stdlib malloc/free are used for allocating MemRef payloads. /// Specifying `useAlloca-true` emits stack allocations instead. In the future /// this may become an enum when we have concrete uses for other options. -std::unique_ptr> -createLowerToLLVMPass(bool useAlloca = false); +std::unique_ptr> createLowerToLLVMPass(); namespace LLVM { /// Make argument-taking successors of each block distinct. PHI nodes in LLVM diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -35,20 +35,6 @@ #define PASS_NAME "convert-std-to-llvm" -static llvm::cl::OptionCategory - clOptionsCategory("Standard to LLVM lowering options"); - -static llvm::cl::opt - clUseAlloca(PASS_NAME "-use-alloca", - llvm::cl::desc("Replace emission of malloc/free by alloca"), - llvm::cl::init(false)); - -static llvm::cl::opt clUseBarePtrCallConv( - PASS_NAME "-use-bare-ptr-memref-call-conv", - llvm::cl::desc("Replace FuncOp's MemRef arguments with " - "bare pointers to the MemRef element types"), - llvm::cl::init(false)); - // Extract an LLVM IR type from the LLVM IR dialect type. static LLVM::LLVMType unwrap(Type type) { if (!type) @@ -2361,9 +2347,8 @@ /// A pass converting MLIR operations into the LLVM IR dialect. struct LLVMLoweringPass : public ModulePass { /// Creates an LLVM lowering pass. - explicit LLVMLoweringPass(bool useAlloca = false, - bool useBarePtrCallConv = false) - : useAlloca(useAlloca), useBarePtrCallConv(useBarePtrCallConv) {} + explicit LLVMLoweringPass() {} + LLVMLoweringPass(const LLVMLoweringPass &pass) {} /// Run the dialect converter on the module. void runOnModule() override { @@ -2389,23 +2374,26 @@ } /// Use `alloca` instead of `call @malloc` for converting std.alloc. - bool useAlloca; + Option useAlloca{ + *this, "use-alloca", + llvm::cl::desc("Replace emission of malloc/free by alloca"), + llvm::cl::init(false)}; /// Convert memrefs to bare pointers in function signatures. - bool useBarePtrCallConv; + Option useBarePtrCallConv{ + *this, "use-bare-ptr-memref-call-conv", + llvm::cl::desc("Replace FuncOp's MemRef arguments with " + "bare pointers to the MemRef element types"), + llvm::cl::init(false)}; }; } // end namespace -std::unique_ptr> -mlir::createLowerToLLVMPass(bool useAlloca) { - return std::make_unique(useAlloca); +std::unique_ptr> mlir::createLowerToLLVMPass() { + return std::make_unique(); } static PassRegistration pass("convert-std-to-llvm", "Convert scalar and vector operations from the " "Standard to the LLVM dialect", - [] { - return std::make_unique( - clUseAlloca.getValue(), clUseBarePtrCallConv.getValue()); - }); + [] { return std::make_unique(); }); diff --git a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir @@ -1,6 +1,6 @@ // RUN: mlir-opt -convert-std-to-llvm %s | FileCheck %s -// RUN: mlir-opt -convert-std-to-llvm -convert-std-to-llvm-use-alloca=1 %s | FileCheck %s --check-prefix=ALLOCA -// RUN: mlir-opt -convert-std-to-llvm -split-input-file -convert-std-to-llvm-use-bare-ptr-memref-call-conv=1 %s | FileCheck %s --check-prefix=BAREPTR +// RUN: mlir-opt -convert-std-to-llvm='use-alloca=1' %s | FileCheck %s --check-prefix=ALLOCA +// RUN: mlir-opt -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' -split-input-file %s | FileCheck %s --check-prefix=BAREPTR // BAREPTR-LABEL: func @check_noalias // BAREPTR-SAME: %{{.*}}: !llvm<"float*"> {llvm.noalias = true} diff --git a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir --- a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir +++ b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -convert-loop-to-std -convert-std-to-llvm -convert-std-to-llvm-use-bare-ptr-memref-call-conv | mlir-cpu-runner -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext -entry-point-result=void | FileCheck %s +// RUN: mlir-opt %s -convert-loop-to-std -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' | mlir-cpu-runner -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext -entry-point-result=void | FileCheck %s // Verify bare pointer memref calling convention. `simple_add1_add2_test` // gets two 2xf32 memrefs, adds 1.0f to the first one and 2.0f to the second