Skip to content

Commit

Permalink
[RemoveDIs][AsmWriter] Add empty-metadata operands to the SlotTracker (
Browse files Browse the repository at this point in the history
  • Loading branch information
OCHyams authored Mar 18, 2024
1 parent c5177f1 commit 487f356
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion llvm/lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,15 @@ void SlotTracker::processDbgRecordMetadata(const DbgRecord &DR) {
// Process metadata used by DbgRecords; we only specifically care about the
// DILocalVariable, DILocation, and DIAssignID fields, as the Value and
// Expression fields should only be printed inline and so do not use a slot.
// Note: The above doesn't apply for empty-metadata operands.
if (auto *Empty = dyn_cast<MDNode>(DPV->getRawLocation()))
CreateMetadataSlot(Empty);
CreateMetadataSlot(DPV->getRawVariable());
if (DPV->isDbgAssign())
if (DPV->isDbgAssign()) {
CreateMetadataSlot(cast<MDNode>(DPV->getRawAssignID()));
if (auto *Empty = dyn_cast<MDNode>(DPV->getRawAddress()))
CreateMetadataSlot(Empty);
}
} else if (const DPLabel *DPL = dyn_cast<const DPLabel>(&DR)) {
CreateMetadataSlot(DPL->getRawLabel());
} else {
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/DebugInfo/print-non-instruction-debug-info.ll
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
; CHECK-NEXT: {{^}} store i32 %[[VAL_ADD]]{{.+}}, !DIAssignID ![[ASSIGNID:[0-9]+]]
; 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]+]]
; NEWDBG-NEXT: {{^}} #dbg_assign(i32 %[[VAL_ADD]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ptr %[[VAL_B]], !DIExpression(), ![[LOC_4:[0-9]+]])
; 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]]
; NEWDBG-NEXT: {{^}} #dbg_assign(![[EMPTY:[0-9]+]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ![[EMPTY]], !DIExpression(), ![[LOC_4]])
; CHECK-NEXT: {{^}} ret i32

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

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

}
Expand Down

0 comments on commit 487f356

Please sign in to comment.