This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 4/4] gold: Fix non-deterministic behaviour of Mips gold.

> Changelog -
>     * (Mips_got_entry::hash): Delete.
>     (class Mips_got_entry_hash): Likewise.
>     (struct Got_page_entry_hash): Likewise.
>     (Mips_got_entry::equals): Change to compare_less.
>     (class Mips_got_entry_eq): Change to Mips_got_entry_compare_less.
>     (struct Got_page_entry_eq): Change to Got_page_entry_compare_less.
>     (Got_entry_set): Change from Unordered_set to std::set.
>     (Got_page_entry_set): Likewise.
>     (global_got_symbols_): Likewise.
>     (Mips_output_data_mips_stubs::symbols_): Likewise.
>     (Mips_output_data_la25_stub::symbols_): Likewise.
>     (Mips_got_info::record_got_entry): Don't use find before insert.
>     (Mips_got_info::record_got_page_entry): Likewise.

It's usually better to sort at the end rather than maintain a sorted
list throughout. Since you can't sort an unordered set, however, you
may want to try putting the (pointers to) entries into a vector, with
an unordered set of pointers on the side. At the end, you could then
sort the vector and throw away the set.

Or, you could build the unordered set just as you do now, then at the
end copy the pointers into a vector for sorting. (With the advantage
that you can size the vector beforehand, halving the cost of building
the vector.)

I don't know which approach will be better in this case, so it may be
worth benchmarking.

If you've done the measurements, or are confident that std::set is the
right thing to use, let me know and I'll approve this patch.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]