This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Forward ranges::sort to instantiations in the dylib
ClosedPublic

Authored by philnik on Jan 1 2023, 12:11 PM.

Details

Summary

This patch removes _WrapAlgPolicy and related functionality. Instead, we explicitly forward to __sort now if we have an instantiation inside the dylib. If we don't we just call __introsort.

Diff Detail

Event Timeline

philnik created this revision.Jan 1 2023, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2023, 12:11 PM
philnik requested review of this revision.Jan 1 2023, 12:11 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik edited the summary of this revision. (Show Details)Jan 2 2023, 4:08 PM
philnik updated this revision to Diff 485891.Jan 2 2023, 4:21 PM

Try to fix CI

philnik updated this revision to Diff 485896.Jan 2 2023, 5:16 PM

Next try

ldionne requested changes to this revision.Jan 19 2023, 9:56 AM

I generally like this change, but I think we want to clean up the situation with __sort5 and friends before we do it.

libcxx/src/algorithm.cpp
14–27

Basically, don't rely on the (way too subtle) trick where you're avoiding deadly recursion because you're passing the third template argument to __sort.

46–47

I don't think these symbols could actually be called previously, because they are only used from __sort, which is in the dylib as well.

I would actually start with that patch since it'll simplify the rest of this patch. I would not ship this in LLVM 16 though, to give us a bit of time to find potential issues with it.

This revision now requires changes to proceed.Jan 19 2023, 9:56 AM
philnik updated this revision to Diff 490740.Jan 20 2023, 12:39 AM
philnik marked 2 inline comments as done.

Address comments

ldionne accepted this revision.Feb 1 2023, 9:24 AM

This is awesome! This is a big simplification, thanks for working on it!

libcxx/include/__algorithm/sort.h
110–111
840–842
libcxx/src/algorithm.cpp
35–36

I would keep them aligned cause it's just a list of things, and use // clang-format off if needed.

This revision is now accepted and ready to land.Feb 1 2023, 9:24 AM
This revision was landed with ongoing or failed builds.Feb 1 2023, 11:10 AM
This revision was automatically updated to reflect the committed changes.
philnik marked 3 inline comments as done.

@philnik Thank you for the clean-up!