[llvm] [BOLT][DWARF][NFC] Fix DebugStrOffsetsWriter (PR #100672)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 14:28:42 PDT 2024
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/100672
>From 3b8935a600ea0f243c18d27864d43848785fad08 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Thu, 25 Jul 2024 17:01:38 -0700
Subject: [PATCH 1/5] [BOLT][DWARF][NFC] Fix DebugStrOffsetsWriter so
updateAddressMap can't be called after it is finalized
Summary:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/D60293063
---
bolt/include/bolt/Core/DebugData.h | 5 +++++
bolt/lib/Core/DIEBuilder.cpp | 3 +++
bolt/lib/Core/DebugData.cpp | 1 +
bolt/lib/Rewrite/DWARFRewriter.cpp | 2 ++
bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test | 2 +-
5 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 5935ffaa46af7..ba988102a0fb5 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -503,10 +503,15 @@ class DebugStrOffsetsWriter {
return StrOffsetSectionWasModified;
}
+ std::unordered_map<uint64_t, bool> &getDebugStrOffsetFinalized() {
+ return DebugStrOffsetFinalized;
+ }
+
private:
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
std::map<uint32_t, uint32_t> IndexToAddressMap;
+ std::unordered_map<uint64_t, bool> DebugStrOffsetFinalized;
SmallVector<uint32_t, 5> StrOffsets;
std::unordered_map<uint64_t, uint64_t> ProcessedBaseOffsets;
bool StrOffsetSectionWasModified = false;
diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp
index b0f550fd77318..df055e418ccce 100644
--- a/bolt/lib/Core/DIEBuilder.cpp
+++ b/bolt/lib/Core/DIEBuilder.cpp
@@ -77,6 +77,9 @@ static void addStringHelper(DebugStrOffsetsWriter &StrOffstsWriter,
DIEValue &DIEAttrInfo, StringRef Str) {
uint32_t NewOffset = StrWriter.addString(Str);
if (Unit.getVersion() >= 5) {
+ assert(StrOffstsWriter.getDebugStrOffsetFinalized().count(
+ Unit.getOffset()) == 0 &&
+ "debug_str_offsets was already finalized.");
StrOffstsWriter.updateAddressMap(DIEAttrInfo.getDIEInteger().getValue(),
NewOffset);
return;
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 002f58c474346..c1662271abe8b 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -906,6 +906,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
}
StrOffsetSectionWasModified = false;
+ DebugStrOffsetFinalized[Unit.getOffset()] = true;
clear();
}
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 674b5f17adb3f..adf4c7a32e579 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -757,6 +757,8 @@ void DWARFRewriter::updateDebugInfo() {
: std::optional<std::string>(opts::DwarfOutputPath.c_str());
std::string DWOName = DIEBlder.updateDWONameCompDir(
*StrOffstsWriter, *StrWriter, *CU, DwarfOutputPath, std::nullopt);
+ if (CU->getVersion() >= 5)
+ StrOffstsWriter->finalizeSection(*CU, DIEBlder);
processSplitCU(*CU, **SplitCU, DIEBlder, *TempRangesSectionWriter,
AddressWriter, DWOName, DwarfOutputPath);
}
diff --git a/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
index a325395fd5320..45734bdb229fd 100644
--- a/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
+++ b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
@@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-input-lowpc-ranges-other.s \
; RUN: -split-dwarf-file=mainOther.dwo -o other.o
; RUN: %clang %cflags main.o other.o -o main.exe
-; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
+; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --cu-processing-batch-size=2
; RUN: llvm-dwarfdump --show-form --verbose --debug-rnglists main.exe.bolt &> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt >> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt
>From 8c807df42af8c61c992d575a7b8fe1ccd2f81a91 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 26 Jul 2024 11:12:28 -0700
Subject: [PATCH 2/5] Updates to tests
---
...-df-input-lowpc-ranges-cus-batch-size.test | 135 ++++++++++++++++++
.../X86/dwarf5-df-input-lowpc-ranges-cus.test | 2 +-
2 files changed, 136 insertions(+), 1 deletion(-)
create mode 100644 bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus-batch-size.test
diff --git a/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus-batch-size.test b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus-batch-size.test
new file mode 100644
index 0000000000000..db4d7468eb2b6
--- /dev/null
+++ b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus-batch-size.test
@@ -0,0 +1,135 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: cd %t
+; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-input-lowpc-ranges-main.s \
+; RUN: -split-dwarf-file=main.dwo -o main.o
+; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-input-lowpc-ranges-other.s \
+; RUN: -split-dwarf-file=mainOther.dwo -o other.o
+; RUN: %clang %cflags main.o other.o -o main.exe
+; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --cu-processing-batch-size=1
+; RUN: llvm-bolt main.exe -o main-batch.exe.bolt --update-debug-sections --cu-processing-batch-size=2
+; RUN: llvm-dwarfdump --show-form --verbose --debug-rnglists main.exe.bolt &> %t/foo.txt
+; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt >> %t/foo.txt
+; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt
+; RUN: cat %t/foo.txt | FileCheck -check-prefix=BOLT %s
+; RUN: llvm-dwarfdump --show-form --verbose --debug-rnglists main.exe.bolt &> %t/foo-batch.txt
+; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt >> %t/foo-batch.txt
+; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo-batch.txt
+; RUN: cat %t/foo-batch.txt | FileCheck -check-prefix=BOLT-BATCH %s
+; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo mainOther.dwo.dwo &> %t/mainddwodwo.txt
+; RUN: cat %t/mainddwodwo.txt | FileCheck -check-prefix=BOLT-DWO-MAIN %s
+
+;; Tests that BOLT correctly handles Skeleton CU which has DW_AT_low_pc/DW_AT_ranges as input and handles multiple CUs with ranges
+;; and with multiple batch sizes.
+
+; BOLT: Addrs: [
+; BOLT-NEXT: 0x[[#%.16x,ADDR1:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR2:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR3:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR4:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR5:]]
+
+; BOLT: Addrs: [
+; BOLT-NEXT: 0x[[#%.16x,ADDR6:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR7:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR8:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR9:]]
+; BOLT-NEXT: 0x[[#%.16x,ADDR10:]]
+
+; BOLT: DW_TAG_skeleton_unit
+; BOLT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "main.dwo.dwo")
+; BOLT-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+; BOLT-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
+; BOLT-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x16]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x16]], 0x[[#ADDR1 + 0x24]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x24]], 0x[[#ADDR1 + 0x29]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x30]], 0x[[#ADDR1 + 0x46]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x50]], 0x[[#ADDR1 + 0x77]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x77]], 0x[[#ADDR1 + 0x85]])
+; BOLT-NEXT: [0x[[#ADDR1 + 0x85]], 0x[[#ADDR1 + 0x9f]])
+; BOLT-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
+; BOLT-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
+
+; BOLT: DW_TAG_skeleton_unit
+; BOLT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "mainOther.dwo.dwo")
+; BOLT-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+; BOLT-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x0000003b
+; BOLT-NEXT: [0x[[#ADDR6]], 0x[[#ADDR6 + 0x16]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x16]], 0x[[#ADDR6 + 0x24]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x24]], 0x[[#ADDR6 + 0x29]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x30]], 0x[[#ADDR6 + 0x46]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x50]], 0x[[#ADDR6 + 0x70]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x70]], 0x[[#ADDR6 + 0x7e]])
+; BOLT-NEXT: [0x[[#ADDR6 + 0x7e]], 0x[[#ADDR6 + 0x98]])
+; BOLT-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000038)
+; BOLT-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000037)
+
+; BOLT-BATCH: Addrs: [
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR1:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR2:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR3:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR4:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR5:]]
+
+; BOLT-BATCH: Addrs: [
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR6:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR7:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR8:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR9:]]
+; BOLT-BATCH-NEXT: 0x[[#%.16x,ADDR10:]]
+
+; BOLT-BATCH: DW_TAG_skeleton_unit
+; BOLT-BATCH: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "main.dwo.dwo")
+; BOLT-BATCH-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+; BOLT-BATCH-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
+; BOLT-BATCH-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x16]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x16]], 0x[[#ADDR1 + 0x24]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x24]], 0x[[#ADDR1 + 0x29]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x30]], 0x[[#ADDR1 + 0x46]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x50]], 0x[[#ADDR1 + 0x77]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x77]], 0x[[#ADDR1 + 0x85]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR1 + 0x85]], 0x[[#ADDR1 + 0x9f]])
+; BOLT-BATCH-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
+; BOLT-BATCH-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
+
+; BOLT-BATCH: DW_TAG_skeleton_unit
+; BOLT-BATCH: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "mainOther.dwo.dwo")
+; BOLT-BATCH-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+; BOLT-BATCH-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x0000003b
+; BOLT-BATCH-NEXT: [0x[[#ADDR6]], 0x[[#ADDR6 + 0x16]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x16]], 0x[[#ADDR6 + 0x24]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x24]], 0x[[#ADDR6 + 0x29]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x30]], 0x[[#ADDR6 + 0x46]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x50]], 0x[[#ADDR6 + 0x70]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x70]], 0x[[#ADDR6 + 0x7e]])
+; BOLT-BATCH-NEXT: [0x[[#ADDR6 + 0x7e]], 0x[[#ADDR6 + 0x98]])
+; BOLT-BATCH-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000038)
+; BOLT-BATCH-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000037)
+
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000014
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000000, 0x0000000000000016)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000016, 0x0000000000000024)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000024, 0x0000000000000029))
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000020
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000002, 0x0000000000000029)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000029, 0x0000000000000037)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000037, 0x0000000000000051))
+
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000014
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000000, 0x0000000000000016)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000016, 0x0000000000000024)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000024, 0x0000000000000029))
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN: DW_TAG_subprogram
+; BOLT-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000020
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000002, 0x0000000000000022)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000022, 0x0000000000000030)
+; BOLT-DWO-MAIN-NEXT: [0x0000000000000030, 0x000000000000004a))
diff --git a/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
index 45734bdb229fd..a325395fd5320 100644
--- a/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
+++ b/bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
@@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-input-lowpc-ranges-other.s \
; RUN: -split-dwarf-file=mainOther.dwo -o other.o
; RUN: %clang %cflags main.o other.o -o main.exe
-; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --cu-processing-batch-size=2
+; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-dwarfdump --show-form --verbose --debug-rnglists main.exe.bolt &> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt >> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt
>From c983242d3254b61e141164cc643291e9616872b6 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 26 Jul 2024 13:00:11 -0700
Subject: [PATCH 3/5] Updates
---
bolt/include/bolt/Core/DebugData.h | 5 +++--
bolt/lib/Core/DIEBuilder.cpp | 3 ---
bolt/lib/Core/DebugData.cpp | 3 ++-
bolt/lib/Rewrite/DWARFRewriter.cpp | 3 ++-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index ba988102a0fb5..8437e24b1bbb4 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -503,7 +503,7 @@ class DebugStrOffsetsWriter {
return StrOffsetSectionWasModified;
}
- std::unordered_map<uint64_t, bool> &getDebugStrOffsetFinalized() {
+ DenseSet<uint64_t> &getDebugStrOffsetFinalized() {
return DebugStrOffsetFinalized;
}
@@ -511,7 +511,8 @@ class DebugStrOffsetsWriter {
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
std::map<uint32_t, uint32_t> IndexToAddressMap;
- std::unordered_map<uint64_t, bool> DebugStrOffsetFinalized;
+ [[maybe_unused]]
+ DenseSet<uint64_t> DebugStrOffsetFinalized;
SmallVector<uint32_t, 5> StrOffsets;
std::unordered_map<uint64_t, uint64_t> ProcessedBaseOffsets;
bool StrOffsetSectionWasModified = false;
diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp
index df055e418ccce..b0f550fd77318 100644
--- a/bolt/lib/Core/DIEBuilder.cpp
+++ b/bolt/lib/Core/DIEBuilder.cpp
@@ -77,9 +77,6 @@ static void addStringHelper(DebugStrOffsetsWriter &StrOffstsWriter,
DIEValue &DIEAttrInfo, StringRef Str) {
uint32_t NewOffset = StrWriter.addString(Str);
if (Unit.getVersion() >= 5) {
- assert(StrOffstsWriter.getDebugStrOffsetFinalized().count(
- Unit.getOffset()) == 0 &&
- "debug_str_offsets was already finalized.");
StrOffstsWriter.updateAddressMap(DIEAttrInfo.getDIEInteger().getValue(),
NewOffset);
return;
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index c1662271abe8b..1c84feda86182 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -906,7 +906,8 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
}
StrOffsetSectionWasModified = false;
- DebugStrOffsetFinalized[Unit.getOffset()] = true;
+ assert(DebugStrOffsetFinalized.insert(Unit.getOffset()).second == true &&
+ "debug_str_offsets was already finalized.");
clear();
}
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index adf4c7a32e579..649be59cdba46 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -711,7 +711,8 @@ void DWARFRewriter::updateDebugInfo() {
RangesBase = RangesSectionWriter.getSectionOffset() +
getDWARF5RngListLocListHeaderSize();
RangesSectionWriter.initSection(Unit);
- StrOffstsWriter->finalizeSection(Unit, DIEBlder);
+ if (!SplitCU)
+ StrOffstsWriter->finalizeSection(Unit, DIEBlder);
} else if (SplitCU) {
RangesBase = LegacyRangesSectionWriter.get()->getSectionOffset();
}
>From 15f7ebcf6409a133f6bd1ca3b9ed5d7abd0e6f52 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 26 Jul 2024 13:03:38 -0700
Subject: [PATCH 4/5] Remove redundant function
---
bolt/include/bolt/Core/DebugData.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 8437e24b1bbb4..638f9a62dd72e 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -503,10 +503,6 @@ class DebugStrOffsetsWriter {
return StrOffsetSectionWasModified;
}
- DenseSet<uint64_t> &getDebugStrOffsetFinalized() {
- return DebugStrOffsetFinalized;
- }
-
private:
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
>From 5f5815d84953e180844513b653e3e20b86cb171a Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 26 Jul 2024 14:28:26 -0700
Subject: [PATCH 5/5] Updates
---
bolt/include/bolt/Core/DebugData.h | 4 ++++
bolt/lib/Core/DIEBuilder.cpp | 2 ++
bolt/lib/Core/DebugData.cpp | 4 ++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 638f9a62dd72e..3f30bd4d4c9c1 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -503,6 +503,10 @@ class DebugStrOffsetsWriter {
return StrOffsetSectionWasModified;
}
+ DenseSet<uint64_t> &getDebugStrOffsetsFinalized() {
+ return DebugStrOffsetFinalized;
+ }
+
private:
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp
index b0f550fd77318..dba85eb4adec6 100644
--- a/bolt/lib/Core/DIEBuilder.cpp
+++ b/bolt/lib/Core/DIEBuilder.cpp
@@ -77,6 +77,8 @@ static void addStringHelper(DebugStrOffsetsWriter &StrOffstsWriter,
DIEValue &DIEAttrInfo, StringRef Str) {
uint32_t NewOffset = StrWriter.addString(Str);
if (Unit.getVersion() >= 5) {
+ assert(StrOffstsWriter.getDebugStrOffsetsFinalized().count(Unit.getOffset()) == 0 &&
+ "debug_str_offsets was already finalized for this CU.");
StrOffstsWriter.updateAddressMap(DIEAttrInfo.getDIEInteger().getValue(),
NewOffset);
return;
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 1c84feda86182..fe4922d3e00d4 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -906,8 +906,8 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
}
StrOffsetSectionWasModified = false;
- assert(DebugStrOffsetFinalized.insert(Unit.getOffset()).second == true &&
- "debug_str_offsets was already finalized.");
+ assert(DebugStrOffsetFinalized.insert(Unit.getOffset()).second &&
+ "debug_str_offsets was already finalized for this CU.");
clear();
}
More information about the llvm-commits
mailing list