From 1ba5f1142d1d8e65dbbd04b8f507d4d2d2fa871c Mon Sep 17 00:00:00 2001 From: Observer007 <45875558+Observer007@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:11:14 +0800 Subject: [PATCH] [mlir] add overload `createDIScopeForLLVMFuncOp` function (#111689) follow up work of https://github.com/llvm/llvm-project/pull/106229, add create pass overload function to create pass. --------- Co-authored-by: jingzec --- .../include/mlir/Dialect/LLVMIR/Transforms/Passes.h | 3 --- .../mlir/Dialect/LLVMIR/Transforms/Passes.td | 3 +-- .../LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp | 13 ++++++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h index 078c7d12f6f22b..c598ffe3602dc1 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h @@ -20,9 +20,6 @@ namespace mlir { namespace LLVM { -/// Create a pass to add DIScope to LLVMFuncOp that are missing it. -std::unique_ptr createDIScopeForLLVMFuncOpPass(); - /// Generate the code for registering conversion passes. #define GEN_PASS_DECL #define GEN_PASS_REGISTRATION diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td index d54bc55c9edaab..b2a03ce61e7e48 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td @@ -48,7 +48,7 @@ def NVVMOptimizeForTarget : Pass<"llvm-optimize-for-nvvm-target"> { let constructor = "::mlir::NVVM::createOptimizeForTargetPass()"; } -def DIScopeForLLVMFuncOp : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir::ModuleOp"> { +def DIScopeForLLVMFuncOpPass : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir::ModuleOp"> { let summary = "Materialize LLVM debug info subprogram attribute on every LLVMFuncOp"; let description = [{ Having a debug info subprogram attribute on a function is required for @@ -60,7 +60,6 @@ def DIScopeForLLVMFuncOp : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir: line-by-line or get a backtrace with line numbers. }]; - let constructor = "mlir::LLVM::createDIScopeForLLVMFuncOpPass()"; let options = [ Option<"emissionKind", "emission-kind", "mlir::LLVM::DIEmissionKind", /*default=*/"mlir::LLVM::DIEmissionKind::LineTablesOnly", "Emission kind to generate debug info.", diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp index 052e98ea8b8d48..6db14ea5bbfd44 100644 --- a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp +++ b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp @@ -16,7 +16,7 @@ namespace mlir { namespace LLVM { -#define GEN_PASS_DEF_DISCOPEFORLLVMFUNCOP +#define GEN_PASS_DEF_DISCOPEFORLLVMFUNCOPPASS #include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" } // namespace LLVM } // namespace mlir @@ -84,8 +84,11 @@ static void addScopeToFunction(LLVM::LLVMFuncOp llvmFunc, namespace { /// Add a debug info scope to LLVMFuncOp that are missing it. -struct DIScopeForLLVMFuncOp - : public LLVM::impl::DIScopeForLLVMFuncOpBase { +struct DIScopeForLLVMFuncOpPass + : public LLVM::impl::DIScopeForLLVMFuncOpPassBase< + DIScopeForLLVMFuncOpPass> { + using Base::Base; + void runOnOperation() override { ModuleOp module = getOperation(); Location loc = module.getLoc(); @@ -131,7 +134,3 @@ struct DIScopeForLLVMFuncOp }; } // end anonymous namespace - -std::unique_ptr mlir::LLVM::createDIScopeForLLVMFuncOpPass() { - return std::make_unique(); -}