[llvm] [DWARFLinker] Fix matching logic to remove type 1 missing offsets (PR #149618)
Peter Rong via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 09:38:07 PDT 2025
================
@@ -2297,8 +2297,133 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
// Create a map of stmt sequence offsets to original row indices.
DenseMap<uint64_t, unsigned> SeqOffToOrigRow;
- for (const DWARFDebugLine::Sequence &Seq : LT->Sequences)
- SeqOffToOrigRow[Seq.StmtSeqOffset] = Seq.FirstRowIndex;
+ DenseMap<uint64_t, unsigned> LineTableMapping;
+ // The DWARF parser's discovery of sequences can be incomplete. To
+ // ensure all DW_AT_LLVM_stmt_sequence attributes can be patched, we
+ // build a map from both the parser's results and a manual
+ // reconstruction.
+ if (!LT->Rows.empty()) {
+ // First, trust the sequences that the DWARF parser did identify.
+ for (const DWARFDebugLine::Sequence &Seq : LT->Sequences) {
+ LineTableMapping[Seq.StmtSeqOffset] = Seq.FirstRowIndex;
+ }
+
+ // Second, manually find sequence boundaries and match them to the
+ // sorted attributes to handle sequences the parser might have missed.
+ auto StmtAttrs = Unit.getStmtSeqListAttributes();
+ llvm::sort(StmtAttrs,
+ [](const PatchLocation &A, const PatchLocation &B) {
+ return A.get() < B.get();
+ });
+
+ std::vector<size_t> SeqStartRows;
+ SeqStartRows.push_back(0);
+ for (size_t i = 0; i < LT->Rows.size() - 1; ++i)
----------------
DataCorrupted wrote:
I don't think i can iter the object and index at the same time. `auto [...]` tried to unpack `Row` and raised an error
https://github.com/llvm/llvm-project/pull/149618
More information about the llvm-commits
mailing list