Skip to content

Commit

Permalink
[mlir] add overload createDIScopeForLLVMFuncOp function (#111689)
Browse files Browse the repository at this point in the history
follow up work of #106229, add
create pass overload function to create pass.

---------

Co-authored-by: jingzec <[email protected]>
  • Loading branch information
Observer007 and jingzec authored Oct 10, 2024
1 parent 5184d76 commit d124b98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 0 additions & 3 deletions mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ namespace mlir {

namespace LLVM {

/// Create a pass to add DIScope to LLVMFuncOp that are missing it.
std::unique_ptr<Pass> createDIScopeForLLVMFuncOpPass();

/// Generate the code for registering conversion passes.
#define GEN_PASS_DECL
#define GEN_PASS_REGISTRATION
Expand Down
3 changes: 1 addition & 2 deletions mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.",
Expand Down
13 changes: 6 additions & 7 deletions mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<DIScopeForLLVMFuncOp> {
struct DIScopeForLLVMFuncOpPass
: public LLVM::impl::DIScopeForLLVMFuncOpPassBase<
DIScopeForLLVMFuncOpPass> {
using Base::Base;

void runOnOperation() override {
ModuleOp module = getOperation();
Location loc = module.getLoc();
Expand Down Expand Up @@ -131,7 +134,3 @@ struct DIScopeForLLVMFuncOp
};

} // end anonymous namespace

std::unique_ptr<Pass> mlir::LLVM::createDIScopeForLLVMFuncOpPass() {
return std::make_unique<DIScopeForLLVMFuncOp>();
}

0 comments on commit d124b98

Please sign in to comment.