This is an archive of the discontinued LLVM Phabricator instance.

[ModuleInliner] Factor out common code in InlineOrder.cpp (NFC)
ClosedPublic

Authored by kazu on Sep 18 2022, 3:15 PM.

Details

Summary

This patch factors out common code in InlineOrder.cpp.

Without this patch, the model is to ask classes like SizePriority and
CostPriority to compare a pair of call sites:

bool hasLowerPriority(const CallBase *L, const CallBase *R) const override {

while these priority classes have their own caches of priorities:

DenseMap<const CallBase *, PriorityT> Priorities;

This model results in a lot of duplicate code like hasLowerPriority
and updateAndCheckDecreased.

This patch changes the model so that priority classes just have two
methods to compute a priority for a given call site and to compare two
previously computed priorities (as opposed to call sites).

Facilities like hasLowerPriority and updateAndCheckDecreased move to
PriorityInlineOrder along with the map from call sites to their
priorities. PriorityInlineOrder becomes a template class so that it
can accommodate different priority classes.

Diff Detail

Event Timeline

kazu created this revision.Sep 18 2022, 3:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2022, 3:15 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
kazu requested review of this revision.Sep 18 2022, 3:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2022, 3:15 PM
kazu added a comment.Sep 20 2022, 8:50 AM

Please take look. Thanks!

taolq accepted this revision.Sep 21 2022, 8:27 AM

LGTM.
Thanks for the job.

This revision is now accepted and ready to land.Sep 21 2022, 8:27 AM
This revision was landed with ongoing or failed builds.Sep 21 2022, 8:50 AM
This revision was automatically updated to reflect the committed changes.
kazu added a comment.Sep 21 2022, 8:59 AM

LGTM.
Thanks for the job.

Thanks Liqiang for the review!