[llvm] [BOLT][DWARF] Fix debug info update issue with dwarf4 dwp (PR #155619)
Jinjie Huang via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 05:48:34 PDT 2025
https://github.com/Jinjie-Huang updated https://github.com/llvm/llvm-project/pull/155619
>From 6a9cd5414fc11daea05c1c9b05322e436ba7f7d6 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Wed, 27 Aug 2025 20:58:34 +0800
Subject: [PATCH 1/2] fix dwarf4 dwp crash
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 0c1a1bac6c72e..6eefa5155298b 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -504,9 +504,7 @@ static void emitDWOBuilder(const std::string &DWOName,
}
emitUnit(DWODIEBuilder, *Streamer, SplitCU);
} else {
- for (std::unique_ptr<llvm::DWARFUnit> &CU :
- SplitCU.getContext().dwo_compile_units())
- emitUnit(DWODIEBuilder, *Streamer, *CU);
+ emitUnit(DWODIEBuilder, *Streamer, SplitCU);
// emit debug_types sections for dwarf4
for (DWARFUnit *CU : DWODIEBuilder.getDWARF4TUVector())
>From 1405795aac73bd199ebf1bd414acd36f4d975caa Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 2 Sep 2025 20:47:43 +0800
Subject: [PATCH 2/2] add test
---
bolt/test/X86/dwarf4-dwp.test | 41 +++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 bolt/test/X86/dwarf4-dwp.test
diff --git a/bolt/test/X86/dwarf4-dwp.test b/bolt/test/X86/dwarf4-dwp.test
new file mode 100644
index 0000000000000..6c619ed55233b
--- /dev/null
+++ b/bolt/test/X86/dwarf4-dwp.test
@@ -0,0 +1,41 @@
+# REQUIRES: system-linux
+
+# RUN: rm -rf %t && mkdir -p %t && cd %t
+# RUN: split-file %s %t
+# RUN: %clangxx -g -gdwarf-4 -gsplit-dwarf %t/main.cpp %t/callee.cpp -o main.exe
+# RUN: llvm-dwp -e %t/main.exe -o %t/main.exe.dwp
+# RUN: llvm-bolt %t/main.exe -o %t/main.exe.bolt -update-debug-sections 2>&1 | FileCheck %s
+
+# CHECK-NOT: Assertion
+
+
+#--- main.cpp
+int hotFunction(int x);
+
+int main(int argc, char **argv) {
+ int sum = 0;
+ for (int i = 0; i < 50000000; ++i) { // 让运行时间更久
+ sum += hotFunction(i);
+ }
+ if (sum)
+ return 0;
+ else
+ return 1;
+}
+
+#--- callee.cpp
+int hotFunction(int x) {
+ if ((x & 1) == 0) {
+ x = x * 3 + 1;
+ if (x % 5 == 0) {
+ x += 7;
+ }
+ } else {
+ x = x * x;
+ if (x % 3 == 0) {
+ x -= 4;
+ }
+ }
+ return x;
+}
+
More information about the llvm-commits
mailing list