Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ void AddDebugInfoPass::runOnOperation() {
mlir::LLVM::DICompileUnitAttr cuAttr = mlir::LLVM::DICompileUnitAttr::get(
mlir::DistinctAttr::create(mlir::UnitAttr::get(context)),
llvm::dwarf::getLanguage("DW_LANG_Fortran95"), fileAttr, producer,
isOptimized, debugLevel);
isOptimized, debugLevel,
/*nameTableKind=*/mlir::LLVM::DINameTableKind::Default,
/*splitDwarfFile=*/mlir::StringAttr());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*splitDwarfFile=*/mlir::StringAttr());
/*splitDebugFilename=*/mlir::StringAttr());

nit:


module.walk([&](mlir::func::FuncOp funcOp) {
handleFuncOp(funcOp, fileAttr, cuAttr, typeGen, &symbolTable);
Expand Down
3 changes: 2 additions & 1 deletion mlir/include/mlir-c/Dialect/LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ typedef enum MlirLLVMDINameTableKind MlirLLVMDINameTableKind;
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompileUnitAttrGet(
MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
MlirAttribute file, MlirAttribute producer, bool isOptimized,
MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind);
MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
MlirAttribute splitDwarfFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MlirAttribute splitDwarfFile);
MlirAttribute splitDebugFilename);

nit: Shouldn't this match the field name?


/// Creates a LLVM DIFlags attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx,
Expand Down
8 changes: 5 additions & 3 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,19 @@ def LLVM_DICompileUnitAttr : LLVM_Attr<"DICompileUnit", "di_compile_unit",
OptionalParameter<"StringAttr">:$producer,
"bool":$isOptimized,
"DIEmissionKind":$emissionKind,
OptionalParameter<"DINameTableKind">:$nameTableKind
OptionalParameter<"DINameTableKind">:$nameTableKind,
OptionalParameter<"StringAttr">:$splitDebugFilename
);
let builders = [
AttrBuilderWithInferredContext<(ins
"DistinctAttr":$id, "unsigned":$sourceLanguage, "DIFileAttr":$file,
"StringAttr":$producer, "bool":$isOptimized,
"DIEmissionKind":$emissionKind,
CArg<"DINameTableKind", "DINameTableKind::Default">:$nameTableKind
CArg<"DINameTableKind", "DINameTableKind::Default">:$nameTableKind,
CArg<"StringAttr", "{}">:$splitDwarfFile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CArg<"StringAttr", "{}">:$splitDwarfFile
CArg<"StringAttr", "{}">:$splitDebugFileName

nit: Shouldn't this match the field name?

), [{
return $_get(id.getContext(), id, sourceLanguage, file, producer,
isOptimized, emissionKind, nameTableKind);
isOptimized, emissionKind, nameTableKind, splitDwarfFile);
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
Expand Down
15 changes: 7 additions & 8 deletions mlir/lib/CAPI/Dialect/LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,16 @@ MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name,
cast<StringAttr>(unwrap(directory))));
}

MlirAttribute
mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id,
unsigned int sourceLanguage, MlirAttribute file,
MlirAttribute producer, bool isOptimized,
MlirLLVMDIEmissionKind emissionKind,
MlirLLVMDINameTableKind nameTableKind) {
MlirAttribute mlirLLVMDICompileUnitAttrGet(
MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
MlirAttribute file, MlirAttribute producer, bool isOptimized,
MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
MlirAttribute splitDwarfFile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MlirAttribute splitDwarfFile) {
MlirAttribute splitDebugFileName) {

nit: Shouldn't this match the field name?

return wrap(DICompileUnitAttr::get(
unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
isOptimized, DIEmissionKind(emissionKind),
DINameTableKind(nameTableKind)));
isOptimized, DIEmissionKind(emissionKind), DINameTableKind(nameTableKind),
cast<StringAttr>(unwrap(splitDwarfFile))));
}

MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Target/LLVMIR/DebugImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ DICompileUnitAttr DebugImporter::translateImpl(llvm::DICompileUnit *node) {
return DICompileUnitAttr::get(
context, getOrCreateDistinctID(node), node->getSourceLanguage(),
translate(node->getFile()), getStringAttrOrNull(node->getRawProducer()),
node->isOptimized(), emissionKind.value(), nameTableKind.value());
node->isOptimized(), emissionKind.value(), nameTableKind.value(),
getStringAttrOrNull(node->getRawSplitDebugFilename()));
}

DICompositeTypeAttr DebugImporter::translateImpl(llvm::DICompositeType *node) {
Expand Down
4 changes: 3 additions & 1 deletion mlir/lib/Target/LLVMIR/DebugTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ llvm::DICompileUnit *DebugTranslation::translateImpl(DICompileUnitAttr attr) {
attr.getSourceLanguage(), translate(attr.getFile()),
attr.getProducer() ? attr.getProducer().getValue() : "",
attr.getIsOptimized(),
/*Flags=*/"", /*RV=*/0, /*SplitName=*/{},
/*Flags=*/"", /*RV=*/0,
attr.getSplitDebugFilename() ? attr.getSplitDebugFilename().getValue()
: "",
static_cast<llvm::DICompileUnit::DebugEmissionKind>(
attr.getEmissionKind()),
0, true, false,
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/CAPI/llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static void testDebugInfoAttributes(MlirContext ctx) {

MlirAttribute compile_unit = mlirLLVMDICompileUnitAttrGet(
ctx, id, LLVMDWARFSourceLanguageC99, file, foo, false,
MlirLLVMDIEmissionKindFull, MlirLLVMDINameTableKindDefault);
MlirLLVMDIEmissionKindFull, MlirLLVMDINameTableKindDefault, bar);

// CHECK: #llvm.di_compile_unit<{{.*}}>
mlirAttributeDump(compile_unit);
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/Target/LLVMIR/Import/debug-info.ll
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ define void @composite_type() !dbg !3 {
; // -----

; CHECK-DAG: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
; CHECK-DAG: #[[CU:.+]] = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #[[FILE]], isOptimized = false, emissionKind = None, nameTableKind = None>
; CHECK-DAG: #[[CU:.+]] = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #[[FILE]], isOptimized = false, emissionKind = None, nameTableKind = None, splitDebugFilename = "test.dwo">
; Verify an empty subroutine types list is supported.
; CHECK-DAG: #[[SP_TYPE:.+]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>
; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #[[CU]], scope = #[[FILE]], name = "subprogram", linkageName = "subprogram", file = #[[FILE]], line = 42, scopeLine = 42, subprogramFlags = Definition, type = #[[SP_TYPE]]>
Expand All @@ -227,7 +227,7 @@ define void @subprogram() !dbg !3 {
!llvm.dbg.cu = !{!1}
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, nameTableKind: None)
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, nameTableKind: None, splitDebugFilename: "test.dwo")
!2 = !DIFile(filename: "debug-info.ll", directory: "/")
!3 = distinct !DISubprogram(name: "subprogram", linkageName: "subprogram", scope: !2, file: !2, line: 42, scopeLine: 42, spFlags: DISPFlagDefinition, unit: !1, type: !4)
!4 = !DISubroutineType(cc: DW_CC_normal, types: !5)
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/Target/LLVMIR/llvmir-debug.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ llvm.func @func_no_debug() {
#cu = #llvm.di_compile_unit<
id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #file,
producer = "MLIR", isOptimized = true, emissionKind = Full,
nameTableKind = None
nameTableKind = None, splitDebugFilename = "test.dwo"
>
#composite = #llvm.di_composite_type<
tag = DW_TAG_structure_type, name = "composite", file = #file,
Expand Down Expand Up @@ -140,7 +140,7 @@ llvm.func @empty_types() {
llvm.return
} loc(fused<#sp1>["foo.mlir":2:1])

// CHECK: ![[CU_LOC:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[CU_FILE_LOC:.*]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
// CHECK: ![[CU_LOC:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[CU_FILE_LOC:.*]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, nameTableKind: None)
// CHECK: ![[CU_FILE_LOC]] = !DIFile(filename: "foo.mlir", directory: "/test/")

// CHECK: ![[FUNC_LOC]] = distinct !DISubprogram(name: "func_with_debug", linkageName: "func_with_debug", scope: ![[NESTED_NAMESPACE:.*]], file: ![[CU_FILE_LOC]], line: 3, type: ![[FUNC_TYPE:.*]], scopeLine: 3, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: ![[CU_LOC]])
Expand Down