Skip to content

Commit ee1f6e7

Browse files
committed
Rebase fixes: add proper #dbg_label support
1 parent bd6df6b commit ee1f6e7

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Diff for: llvm/lib/IR/AsmWriter.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -4657,13 +4657,10 @@ void AssemblyWriter::printDbgRecordLine(const DbgRecord &DR) {
46574657
}
46584658

46594659
void AssemblyWriter::printDPLabel(const DPLabel &Label) {
4660-
// There's no formal representation of a DPLabel -- print purely as
4661-
// a debugging aid.
4662-
Out << " DPLabel { ";
46634660
auto WriterCtx = getContext();
4661+
Out << "#dbg_label(";
46644662
WriteAsOperandInternal(Out, Label.getLabel(), WriterCtx, true);
4665-
Out << " marker @" << Label.getMarker();
4666-
Out << " }";
4663+
Out << ")";
46674664
}
46684665

46694666
void AssemblyWriter::printMetadataAttachments(
@@ -4906,8 +4903,6 @@ void DPValue::print(raw_ostream &ROS, bool IsForDebug) const {
49064903

49074904
void DPMarker::print(raw_ostream &ROS, ModuleSlotTracker &MST,
49084905
bool IsForDebug) const {
4909-
// There's no formal representation of a DPMarker -- print purely as a
4910-
// debugging aid.
49114906
formatted_raw_ostream OS(ROS);
49124907
SlotTracker EmptySlotTable(static_cast<const Module *>(nullptr));
49134908
SlotTracker &SlotTable =
@@ -4946,8 +4941,6 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST,
49464941

49474942
void DPLabel::print(raw_ostream &ROS, ModuleSlotTracker &MST,
49484943
bool IsForDebug) const {
4949-
// There's no formal representation of a DbgLabelRecord -- print purely as
4950-
// a debugging aid.
49514944
formatted_raw_ostream OS(ROS);
49524945
SlotTracker EmptySlotTable(static_cast<const Module *>(nullptr));
49534946
SlotTracker &SlotTable =

Diff for: llvm/lib/IR/Module.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ void Module::removeDebugIntrinsicDeclarations() {
101101
assert(AssignIntrinsicFn->hasZeroLiveUses() &&
102102
"Debug assign intrinsic should have had uses removed.");
103103
AssignIntrinsicFn->eraseFromParent();
104+
auto *LabelntrinsicFn = Intrinsic::getDeclaration(this, Intrinsic::dbg_label);
105+
assert(LabelntrinsicFn->hasZeroLiveUses() &&
106+
"Debug label intrinsic should have had uses removed.");
107+
LabelntrinsicFn->eraseFromParent();
104108
}
105109

106110
std::unique_ptr<RandomNumberGenerator>

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
; CHECK-NEXT: {{^}} %[[VAL_ADD:[0-9a-zA-Z]+]] = add i32 %[[VAL_A]], 5
2222
; OLDDBG-NEXT: call void @llvm.dbg.value(metadata !DIArgList(i32 %[[VAL_A]], i32 %[[VAL_ADD]]), metadata ![[VAR_A]], metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg ![[LOC_3:[0-9]+]]
2323
; NEWDBG-NEXT: {{^}} #dbg_value(!DIArgList(i32 %[[VAL_A]], i32 %[[VAL_ADD]]), ![[VAR_A]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), ![[LOC_3:[0-9]+]])
24+
; OLDDBG-NEXT: call void @llvm.dbg.label(metadata ![[LABEL_ID:[0-9]+]])
25+
; NEWDBG-NEXT: {{^}} #dbg_label(![[LABEL_ID:[0-9]+]])
2426
; CHECK-NEXT: {{^}} store i32 %[[VAL_ADD]]{{.+}}, !DIAssignID ![[ASSIGNID:[0-9]+]]
2527
; 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]+]]
2628
; NEWDBG-NEXT: {{^}} #dbg_assign(i32 %[[VAL_ADD]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ptr %[[VAL_B]], !DIExpression(), ![[LOC_4:[0-9]+]])
@@ -37,6 +39,7 @@
3739
; CHECK-DAG: ![[LOC_2]] = !DILocation(line: 3, column: 20
3840
; CHECK-DAG: ![[LOC_3]] = !DILocation(line: 3, column: 25
3941
; CHECK-DAG: ![[LOC_4]] = !DILocation(line: 3, column: 30
42+
; CHECK-DAG: ![[LABEL_ID]] = !DILabel(
4043

4144
define dso_local i32 @f(i32 %a) !dbg !7 {
4245
entry:
@@ -45,6 +48,7 @@ entry:
4548
call void @llvm.dbg.declare(metadata ptr %b, metadata !21, metadata !DIExpression()), !dbg !31
4649
%add = add i32 %a, 5, !dbg !31
4750
call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %add), metadata !20, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !32
51+
call void @llvm.dbg.label(metadata !50), !dbg !32
4852
store i32 %add, ptr %b, !dbg !32, !DIAssignID !40
4953
call void @llvm.dbg.assign(metadata i32 %add, metadata !21, metadata !DIExpression(), metadata !40, metadata ptr %b, metadata !DIExpression()), !dbg !33
5054
ret i32 %add, !dbg !33
@@ -54,6 +58,7 @@ entry:
5458
declare void @llvm.dbg.value(metadata, metadata, metadata)
5559
declare void @llvm.dbg.declare(metadata, metadata, metadata)
5660
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
61+
declare void @llvm.dbg.label(metadata)
5762

5863
!llvm.dbg.cu = !{!0}
5964
!llvm.module.flags = !{!3, !4, !5}
@@ -77,4 +82,5 @@ declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata,
7782
!31 = !DILocation(line: 3, column: 20, scope: !7)
7883
!32 = !DILocation(line: 3, column: 25, scope: !7)
7984
!33 = !DILocation(line: 3, column: 30, scope: !7)
80-
!40 = distinct !DIAssignID()
85+
!40 = distinct !DIAssignID()
86+
!50 = !DILabel(scope: !7, name: "label", file: !1, line: 3)

0 commit comments

Comments
 (0)