-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[BOLT][DWARF] Skip processing DWO files with ID 0 #154749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[BOLT][DWARF] Skip processing DWO files with ID 0 #154749
Conversation
@llvm/pr-subscribers-bolt Author: Jinjie Huang (Jinjie-Huang) ChangesDWOs with a DWOId of 0 are considered invalid. Currently, createRangeLocListAddressWriters() is called before these invalid DWOs are skipped, which seems unnecessary. Perhaps we can check the DWOId beforehand? BTW, this may lead to an assertion failure inside createRangeLocListAddressWriters("RangeLists writer for DWO unit already exists.), when a duplicate DWO ID of 0 is encountered. I hit this case when using the compiler built prior to this commit with -fsplit-dwarf-inlining enabled, which generates a large number of Compile Units with a DWO ID == 0. I'm not sure if other scenarios could also trigger this issue. Full diff: https://github.com/llvm/llvm-project/pull/154749.diff 1 Files Affected:
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 0c1a1bac6c72e..e8f6189eb5a69 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -729,13 +729,13 @@ void DWARFRewriter::updateDebugInfo() {
ThreadPoolInterface &ThreadPool =
ParallelUtilities::getThreadPool(ThreadCount);
for (DWARFUnit *CU : DIEBlder.getProcessedCUs()) {
- createRangeLocListAddressWriters(*CU);
std::optional<DWARFUnit *> SplitCU;
std::optional<uint64_t> DWOId = CU->getDWOId();
if (DWOId)
SplitCU = BC.getDWOCU(*DWOId);
if (!SplitCU)
continue;
+ createRangeLocListAddressWriters(*CU);
DebugAddrWriter &AddressWriter =
*AddressWritersByCU[CU->getOffset()].get();
DebugRangesSectionWriter &TempRangesSectionWriter =
|
7e2e637
to
b6c3f3c
Compare
That sounds like a broken DWARF. Maybe better approach is to detect it and not to update debug information at all. |
bb17368
to
8851f2e
Compare
39145c2
to
1acbf66
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
1acbf66
to
5a9460a
Compare
@ayermolo Thanks for the review. This kind of dwarf can reproduced via thinlto + split-dwarf + "-fsplit-dwarf-inlining" with clang prior to this commit.
The compiler generates DWARF for the cross-CU callee source file, and there can be multiple CUs with a dwoid of 0. This DWARF seems structurally normal, except that the dwoid is left at its initial value of '0'. I’m not sure whether this counts as a 'broken DWARF', or whether it can be effectively detected. The current implementation of this patch skips processing duplicates with a dwoid of 0, is this reasonable? |
Before BOLT it has multiple DWO IDs that are the same, zero. Which should make llvm-dwp abort. After BOLT it will definitely will be broken because those dwo cus will be referring to the structure of the binary before BOLT. If we do want to support partial update maybe a better way is not to include those CUs in final output? |
Perhaps we can skip mapping the RangeListsWriters for those DWOs with a DWOId of 0, since currently "0" is considered invalid?
Btw, multiple DWOIds of 0 may lead to an assertion failure inside createRangeLocListAddressWriters("RangeLists writer for DWO unit already exists"). I hit this case when using the compiler built prior to this commit with -fsplit-dwarf-inlining enabled, which generates a large number of Compile Units with a DWO ID == 0. I'm not sure if there are other cases could also trigger this issue.