Skip to content

[mlir] add overload createDIScopeForLLVMFuncOp function #111689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>();
}
Loading