Skip to content

Commit 393d57c

Browse files
authored
[MLIR][LLVM] Avoid creating unused NameLocs for imported functions (llvm#163506)
This commit removes the creation of NameLocs when importing locations for LLVM IR functions. This made the generated fused location more complex by adding no valuable additional information to it. Note that removing it has no effect on the roundtrip from LLVM IR back to LLVM IR.
1 parent 37eda40 commit 393d57c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

mlir/lib/Target/LLVMIR/DebugImporter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ Location DebugImporter::translateFuncLocation(llvm::Function *func) {
3434
return UnknownLoc::get(context);
3535

3636
// Add a fused location to link the subprogram information.
37-
StringAttr funcName = StringAttr::get(context, subprogram->getName());
3837
StringAttr fileName = StringAttr::get(context, subprogram->getFilename());
3938
return FusedLocWith<DISubprogramAttr>::get(
40-
{NameLoc::get(funcName),
41-
FileLineColLoc::get(fileName, subprogram->getLine(), /*column=*/0)},
39+
{FileLineColLoc::get(fileName, subprogram->getLine(), /*column=*/0)},
4240
translate(subprogram), context);
4341
}
4442

mlir/test/Target/LLVMIR/Import/debug-info.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,10 @@ define void @subprogram() !dbg !3 {
240240
define void @func_loc() !dbg !3 {
241241
ret void
242242
}
243-
; CHECK-DAG: #[[NAME_LOC:.+]] = loc("func_loc")
244243
; CHECK-DAG: #[[FILE_LOC:.+]] = loc("debug-info.ll":42:0)
245244
; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "func_loc", file = #{{.*}}, line = 42, subprogramFlags = Definition>
246245

247-
; CHECK: loc(fused<#[[SP]]>[#[[NAME_LOC]], #[[FILE_LOC]]]
246+
; CHECK: loc(fused<#[[SP]]>[#[[FILE_LOC]]]
248247

249248
!llvm.dbg.cu = !{!1}
250249
!llvm.module.flags = !{!0}

0 commit comments

Comments
 (0)