Ellis Hoag 9f4e8bca03
[lld][BP] Fix nondeterministic function order by using MapVector (#179841)
There are two places where the nondeterministic iteration order of
`DenseMap` (the original type of `startupSectionIdxUNs`) causes the
output function order to be nondeterministic.


16e2e7f591/lld/include/lld/Common/BPSectionOrdererBase.inc (L240-L245)


16e2e7f591/lld/include/lld/Common/BPSectionOrdererBase.inc (L267-L268)

The fix is to use `MapVector` whose iteration order is guaranteed to be
deterministic.

To test, I built a large binary several times and observed this value no
longer changes.

16e2e7f591/lld/include/lld/Common/BPSectionOrdererBase.inc (L410-L411)

It seems that this regresses linktime by a few seconds, but I believe
the tradeoff is worthwhile.
2026-02-06 09:49:37 -08:00
..