[llvm] [BOLT][DWARF] Sort GDBIndexTUEntryVector (PR #101264)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 16:56:10 PDT 2024
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/101264
>From 4189dc1ca4b2d911da2409ce44e62365be9e9d9c Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 30 Jul 2024 16:54:38 -0700
Subject: [PATCH] [BOLT][DWARF] Sort GDBIndexTUEntryVector
---
bolt/include/bolt/Core/GDBIndex.h | 8 ++++++++
bolt/lib/Core/GDBIndex.cpp | 3 +--
.../X86/dwarf4-split-gdb-index-types-gdb-generated.test | 8 ++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/bolt/include/bolt/Core/GDBIndex.h b/bolt/include/bolt/Core/GDBIndex.h
index 6604c2a11472d..0ebcf4ecfe99e 100644
--- a/bolt/include/bolt/Core/GDBIndex.h
+++ b/bolt/include/bolt/Core/GDBIndex.h
@@ -53,6 +53,14 @@ class GDBIndex {
const GDBIndexTUEntryType &getGDBIndexTUEntryVector() const {
return GDBIndexTUEntryVector;
}
+
+ /// Sorts entries in GDBIndexTUEntryVector according to the TypeHash.
+ void sortGDBIndexTUEntryVector() {
+ llvm::stable_sort(GDBIndexTUEntryVector, [](const GDBIndexTUEntry &LHS,
+ const GDBIndexTUEntry &RHS) {
+ return LHS.TypeHash > RHS.TypeHash;
+ });
+ }
};
} // namespace bolt
diff --git a/bolt/lib/Core/GDBIndex.cpp b/bolt/lib/Core/GDBIndex.cpp
index 9e6d24167d559..c7fb4889646b4 100644
--- a/bolt/lib/Core/GDBIndex.cpp
+++ b/bolt/lib/Core/GDBIndex.cpp
@@ -23,7 +23,6 @@ void GDBIndex::updateGdbIndexSection(
DebugARangesSectionWriter &ARangesSectionWriter) {
if (!BC.getGdbIndexSection())
return;
-
// See https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
// for .gdb_index section format.
@@ -141,7 +140,7 @@ void GDBIndex::updateGdbIndexSection(
write64le(Buffer + 8, CUInfo.second.Length + 4);
Buffer += 16;
}
-
+ sortGDBIndexTUEntryVector();
// Rewrite TU CU List, since abbrevs can be different.
// Entry example:
// 0: offset = 0x00000000, type_offset = 0x0000001e, type_signature =
diff --git a/bolt/test/X86/dwarf4-split-gdb-index-types-gdb-generated.test b/bolt/test/X86/dwarf4-split-gdb-index-types-gdb-generated.test
index c9b12574caa3a..6caf5870fca02 100644
--- a/bolt/test/X86/dwarf4-split-gdb-index-types-gdb-generated.test
+++ b/bolt/test/X86/dwarf4-split-gdb-index-types-gdb-generated.test
@@ -17,10 +17,10 @@
# POSTCHECK-NEXT: 0: Offset = 0x0, Length = 0x34
# POSTCHECK-NEXT: 1: Offset = 0x34, Length = 0x34
# POSTCHECK: Types CU list offset = 0x38, has 4 entries
-# POSTCHECK-NEXT: 0: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x675d23e4f33235f2
-# POSTCHECK-NEXT: 1: offset = 0x0000004a, type_offset = 0x0000001e, type_signature = 0x49dc260088be7e56
-# POSTCHECK-NEXT: 2: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x104ec427d2ebea6f
-# POSTCHECK-NEXT: 3: offset = 0x0000004a, type_offset = 0x0000001e, type_signature = 0xb4580bc1535df1e4
+# POSTCHECK-NEXT: 0: offset = 0x0000004a, type_offset = 0x0000001e, type_signature = 0xb4580bc1535df1e4
+# POSTCHECK-NEXT: 1: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x675d23e4f33235f2
+# POSTCHECK-NEXT: 2: offset = 0x0000004a, type_offset = 0x0000001e, type_signature = 0x49dc260088be7e56
+# POSTCHECK-NEXT: 3: offset = 0x00000000, type_offset = 0x0000001e, type_signature = 0x104ec427d2ebea6f
# POSTCHECK: Address area offset = 0x98, has 2 entries
# POSTCHECK-NEXT: Low/High address = [0x[[#%.4x,ADDR:]],
# POSTCHECK-SAME: 0x[[#ADDR + 0x7a]]) (Size: 0x7a), CU id = 0
More information about the llvm-commits
mailing list