[llvm] [RemoveDIs][AsmWriter] Add empty-metadata operands to the SlotTracker (PR #85636)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 07:39:34 PDT 2024
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/85636
>From e6115cade28b682d22af2414d7f17ffa981724ac Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Mon, 18 Mar 2024 12:02:00 +0000
Subject: [PATCH 1/2] [RemoveDIs][AsmWriter] Add empty-metadata operands to the
SlotTracker
---
llvm/lib/IR/AsmWriter.cpp | 8 +++++++-
llvm/test/DebugInfo/print-non-instruction-debug-info.ll | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 11383ea6214bf3..19acc89f73fb7e 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -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 {
diff --git a/llvm/test/DebugInfo/print-non-instruction-debug-info.ll b/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
index 2e765619fcb896..4e0b0894524b76 100644
--- a/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
+++ b/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
@@ -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:[0-9]+]]
+; NEWDBG-NEXT: {{^}} #dbg_assign(![[EMPTY:[0-9]+]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ![[EMPTY]], !DIExpression(), ![[LOC_4:[0-9]+]])
; CHECK-NEXT: {{^}} ret i32
; OLDDBG-DAG: declare void @llvm.dbg.value
@@ -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:
@@ -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
}
>From 0b9ed3cb43782d83b4d60b3e24ca845250f195f6 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlandoch.och at gmail.com>
Date: Mon, 18 Mar 2024 14:39:28 +0000
Subject: [PATCH 2/2] Update
llvm/test/DebugInfo/print-non-instruction-debug-info.ll
Co-authored-by: Stephen Tozer <Melamoto at gmail.com>
---
llvm/test/DebugInfo/print-non-instruction-debug-info.ll | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/test/DebugInfo/print-non-instruction-debug-info.ll b/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
index 4e0b0894524b76..490f24ff76ff56 100644
--- a/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
+++ b/llvm/test/DebugInfo/print-non-instruction-debug-info.ll
@@ -26,8 +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:[0-9]+]]
-; NEWDBG-NEXT: {{^}} #dbg_assign(![[EMPTY:[0-9]+]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ![[EMPTY]], !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
More information about the llvm-commits
mailing list