Skip to content

Commit

Permalink
Revert "[mlir][func] Use the generated pass options in func to llvm."
Browse files Browse the repository at this point in the history
The commit breaks the mlir-vulkan runner:
https://lab.llvm.org/buildbot#builders/61/builds/39694

This reverts commit 771d9c0.
  • Loading branch information
gysit committed Feb 11, 2023
1 parent 771d9c0 commit 39da468
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
11 changes: 10 additions & 1 deletion mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
#include <string>

namespace mlir {
class LowerToLLVMOptions;
class ModuleOp;
template <typename T>
class OperationPass;
class Pass;

#define GEN_PASS_DECL_CONVERTFUNCTOLLVMPASS
#define GEN_PASS_DECL_CONVERTFUNCTOLLVM
#include "mlir/Conversion/Passes.h.inc"

/// Creates a pass to convert the Func dialect into the LLVMIR dialect.
std::unique_ptr<OperationPass<ModuleOp>> createConvertFuncToLLVMPass();
std::unique_ptr<OperationPass<ModuleOp>>
createConvertFuncToLLVMPass(const LowerToLLVMOptions &options);

} // namespace mlir

#endif // MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVMPASS_H_
3 changes: 2 additions & 1 deletion mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def ConvertControlFlowToSPIRV : Pass<"convert-cf-to-spirv"> {
// FuncToLLVM
//===----------------------------------------------------------------------===//

def ConvertFuncToLLVMPass : Pass<"convert-func-to-llvm", "ModuleOp"> {
def ConvertFuncToLLVM : Pass<"convert-func-to-llvm", "ModuleOp"> {
let summary = "Convert from the Func dialect to the LLVM dialect";
let description = [{
Convert Func dialect operations into the LLVM IR dialect operations.
Expand All @@ -300,6 +300,7 @@ def ConvertFuncToLLVMPass : Pass<"convert-func-to-llvm", "ModuleOp"> {
returns are updated accordingly. Block argument types are updated to use
LLVM IR types.
}];
let constructor = "mlir::createConvertFuncToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool",
Expand Down
31 changes: 28 additions & 3 deletions mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include <functional>

namespace mlir {
#define GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS
#define GEN_PASS_DEF_CONVERTFUNCTOLLVM
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir

Expand Down Expand Up @@ -711,8 +711,15 @@ void mlir::populateFuncToLLVMConversionPatterns(LLVMTypeConverter &converter,
namespace {
/// A pass converting Func operations into the LLVM IR dialect.
struct ConvertFuncToLLVMPass
: public impl::ConvertFuncToLLVMPassBase<ConvertFuncToLLVMPass> {
using Base::Base;
: public impl::ConvertFuncToLLVMBase<ConvertFuncToLLVMPass> {
ConvertFuncToLLVMPass() = default;
ConvertFuncToLLVMPass(bool useBarePtrCallConv, unsigned indexBitwidth,
bool useAlignedAlloc,
const llvm::DataLayout &dataLayout) {
this->useBarePtrCallConv = useBarePtrCallConv;
this->indexBitwidth = indexBitwidth;
this->dataLayout = dataLayout.getStringRepresentation();
}

/// Run the dialect converter on the module.
void runOnOperation() override {
Expand Down Expand Up @@ -754,3 +761,21 @@ struct ConvertFuncToLLVMPass
}
};
} // namespace

std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertFuncToLLVMPass() {
return std::make_unique<ConvertFuncToLLVMPass>();
}

std::unique_ptr<OperationPass<ModuleOp>>
mlir::createConvertFuncToLLVMPass(const LowerToLLVMOptions &options) {
auto allocLowering = options.allocLowering;
// There is no way to provide additional patterns for pass, so
// AllocLowering::None will always fail.
assert(allocLowering != LowerToLLVMOptions::AllocLowering::None &&
"ConvertFuncToLLVMPass doesn't support AllocLowering::None");
bool useAlignedAlloc =
(allocLowering == LowerToLLVMOptions::AllocLowering::AlignedAlloc);
return std::make_unique<ConvertFuncToLLVMPass>(
options.useBarePtrCallConv, options.getIndexBitwidth(), useAlignedAlloc,
options.dataLayout);
}
2 changes: 1 addition & 1 deletion mlir/test/CAPI/execution_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void lowerModuleToLLVM(MlirContext ctx, MlirModule module) {
MlirPassManager pm = mlirPassManagerCreate(ctx);
MlirOpPassManager opm = mlirPassManagerGetNestedUnder(
pm, mlirStringRefCreateFromCString("func.func"));
mlirPassManagerAddOwnedPass(pm, mlirCreateConversionConvertFuncToLLVMPass());
mlirPassManagerAddOwnedPass(pm, mlirCreateConversionConvertFuncToLLVM());
mlirOpPassManagerAddOwnedPass(
opm, mlirCreateConversionArithToLLVMConversionPass());
MlirLogicalResult status = mlirPassManagerRun(pm, module);
Expand Down

0 comments on commit 39da468

Please sign in to comment.