This is an archive of the discontinued LLVM Phabricator instance.

[CodeLayout] Add unittest for cache-directed sort
ClosedPublic

Authored by MaskRay on Sep 17 2023, 4:09 PM.

Details

Summary

The function reordering algorithm added by https://reviews.llvm.org/D152834 and
used by BOLT (https://reviews.llvm.org/D153039) is untested.

Add some tests at the appropriate layer.

Depends on D159526

Diff Detail

Event Timeline

MaskRay created this revision.Sep 17 2023, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2023, 4:09 PM
Herald added a subscriber: pengfei. · View Herald Transcript
MaskRay requested review of this revision.Sep 17 2023, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2023, 4:09 PM

Another example would be where the algorithm stops merging functions (with call edges) because the temporal locality degrades too much, but this can be done in a separate patch.

llvm/unittests/Transforms/Utils/CodeLayoutTest.cpp
15

I might be missing something. Isn't this supposed to be the same size as Counts?

spupyrev added inline comments.Sep 26 2023, 6:29 AM
llvm/unittests/Transforms/Utils/CodeLayoutTest.cpp
15

I agree. Does it make sense to add an assertion to catch such problems?

MaskRay marked 2 inline comments as done.Sep 26 2023, 6:43 PM
MaskRay added inline comments.
llvm/unittests/Transforms/Utils/CodeLayoutTest.cpp
15

I think the code is correct. The https://en.cppreference.com/w/cpp/container/vector/vector (3) overload (size_type count, const T& value) is picked. Sizes.size() == std::size(Counts).

spupyrev accepted this revision.Sep 27 2023, 6:26 AM

I'd suggest to explicitly initialize Sizes for each element to improve readability and avoid confusion.

This revision is now accepted and ready to land.Sep 27 2023, 6:26 AM
MaskRay updated this revision to Diff 557410.Sep 27 2023, 10:49 AM
MaskRay marked an inline comment as done.

Use std::size to avoid referencing vector size by integer literals

This revision was landed with ongoing or failed builds.Sep 27 2023, 10:52 AM
This revision was automatically updated to reflect the committed changes.