[PATCH] Fix a comparison function to actually be a SWO so that it conforms to the spec required by std::sort and friends.

Chandler Carruth chandlerc at gmail.com
Wed Mar 11 14:18:41 PDT 2015


Hi ruiu,

Ordering things this way also dramatically simplifies the code as
short-circuit ensures we can skip all of the negative tests.

I've left one FIXME where we're establishing a fairly arbitrary
ordering. Previously, the function compared all types as equal except
for the ones it explicitly handled, but it didn't delegate correctly to
the atomflags when doing so, and so it would fail to be a SWO. The two
possible fixes are to stop comparing the atom flags entirely, or to
establish some arbitrary ordering of the types.

Since it was pure luck which ordering of unequal types we ended up with
previously (the caller was std::sort, not std::stable_sort) I chose to
make the ordering explicit and guaranteed. This seems like the best
conservative approach as I suspect we would want to switch to
stable_sort otherwise in order to have deterministic output.

http://reviews.llvm.org/D8266

Files:
  lib/ReaderWriter/ELF/SegmentChunks.h
  test/elf/phdr.test
  test/elf/rosegment.test

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8266.21766.patch
Type: text/x-patch
Size: 4289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150311/aed431e0/attachment.bin>


More information about the llvm-commits mailing list