Skip to content

Commit 487f356

Browse files
authored
[RemoveDIs][AsmWriter] Add empty-metadata operands to the SlotTracker (#85636)
1 parent c5177f1 commit 487f356

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,15 @@ void SlotTracker::processDbgRecordMetadata(const DbgRecord &DR) {
11431143
// Process metadata used by DbgRecords; we only specifically care about the
11441144
// DILocalVariable, DILocation, and DIAssignID fields, as the Value and
11451145
// Expression fields should only be printed inline and so do not use a slot.
1146+
// Note: The above doesn't apply for empty-metadata operands.
1147+
if (auto *Empty = dyn_cast<MDNode>(DPV->getRawLocation()))
1148+
CreateMetadataSlot(Empty);
11461149
CreateMetadataSlot(DPV->getRawVariable());
1147-
if (DPV->isDbgAssign())
1150+
if (DPV->isDbgAssign()) {
11481151
CreateMetadataSlot(cast<MDNode>(DPV->getRawAssignID()));
1152+
if (auto *Empty = dyn_cast<MDNode>(DPV->getRawAddress()))
1153+
CreateMetadataSlot(Empty);
1154+
}
11491155
} else if (const DPLabel *DPL = dyn_cast<const DPLabel>(&DR)) {
11501156
CreateMetadataSlot(DPL->getRawLabel());
11511157
} else {

llvm/test/DebugInfo/print-non-instruction-debug-info.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
; CHECK-NEXT: {{^}} store i32 %[[VAL_ADD]]{{.+}}, !DIAssignID ![[ASSIGNID:[0-9]+]]
2727
; OLDDBG-NEXT: call void @llvm.dbg.assign(metadata i32 %[[VAL_ADD]], metadata ![[VAR_B]], metadata !DIExpression(), metadata ![[ASSIGNID]], metadata ptr %[[VAL_B]], metadata !DIExpression()), !dbg ![[LOC_4:[0-9]+]]
2828
; NEWDBG-NEXT: {{^}} #dbg_assign(i32 %[[VAL_ADD]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ptr %[[VAL_B]], !DIExpression(), ![[LOC_4:[0-9]+]])
29+
; OLDDBG-NEXT: call void @llvm.dbg.assign(metadata ![[EMPTY:[0-9]+]], metadata ![[VAR_B]], metadata !DIExpression(), metadata ![[ASSIGNID]], metadata ![[EMPTY]], metadata !DIExpression()), !dbg ![[LOC_4]]
30+
; NEWDBG-NEXT: {{^}} #dbg_assign(![[EMPTY:[0-9]+]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ![[EMPTY]], !DIExpression(), ![[LOC_4]])
2931
; CHECK-NEXT: {{^}} ret i32
3032

3133
; OLDDBG-DAG: declare void @llvm.dbg.value
@@ -40,6 +42,7 @@
4042
; CHECK-DAG: ![[LOC_3]] = !DILocation(line: 3, column: 25
4143
; CHECK-DAG: ![[LOC_4]] = !DILocation(line: 3, column: 30
4244
; CHECK-DAG: ![[LABEL_ID]] = !DILabel(
45+
; CHECK-DAG: ![[EMPTY]] = !{}
4346

4447
define dso_local i32 @f(i32 %a) !dbg !7 {
4548
entry:
@@ -51,6 +54,7 @@ entry:
5154
call void @llvm.dbg.label(metadata !50), !dbg !32
5255
store i32 %add, ptr %b, !dbg !32, !DIAssignID !40
5356
call void @llvm.dbg.assign(metadata i32 %add, metadata !21, metadata !DIExpression(), metadata !40, metadata ptr %b, metadata !DIExpression()), !dbg !33
57+
call void @llvm.dbg.assign(metadata !2, metadata !21, metadata !DIExpression(), metadata !40, metadata !2, metadata !DIExpression()), !dbg !33
5458
ret i32 %add, !dbg !33
5559

5660
}

0 commit comments

Comments
 (0)