This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by chandlerc on Mar 11 2015, 2:18 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc updated this revision to Diff 21766.Mar 11 2015, 2:18 PM
chandlerc retitled this revision from to Fix a comparison function to actually be a SWO so that it conforms to the spec required by std::sort and friends..
chandlerc updated this object.
chandlerc edited the test plan for this revision. (Show Details)
chandlerc added a reviewer: ruiu.
chandlerc added a subscriber: Unknown Object (MLST).
ruiu accepted this revision.Mar 11 2015, 2:25 PM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Mar 11 2015, 2:25 PM
This revision was automatically updated to reflect the committed changes.