llvm-project
0a8663b1 - [DWARFLinker][Determinism] Clear the string offsets map of a unit that is cloned again (#240432)

Commit
11 days ago
[DWARFLinker][Determinism] Clear the string offsets map of a unit that is cloned again (#240432) While trying to optimize the parallel linker, I found that the output wasn't always deterministic. Tracking it down with an agent, I found this edge case where maybeResetToLoadedStage() doesn't clear the .debug_str_offsets. Context from agent: When the parallel linker finds that an already cloned compile unit is referenced by another unit, it resets the unit with maybeResetToLoadedStage() and clones it again. The reset cleared the abbreviations, the address index map and the output sections, but not the map from strings to their .debug_str_offsets indexes. The second cloning therefore kept the indexes assigned by the first one, and those depend on whether, and how far, the unit had been cloned when it was found to be referenced. With DWARF 5 inputs, the DW_FORM_strx indexes, the .debug_str_offsets contents and the order of .debug_str could change from one run to the next. Clear the map with the rest of the per-cloning state. The new test links a unit that is referenced by a later unit, so it is cloned twice with one thread, and checks that its string indexes match a single cloning. Assisted-by: Claude
Author
Parents
Loading