This is an archive of the discontinued LLVM Phabricator instance.

[llvm][Inliner] Templatize PriorityInlineOrder
ClosedPublic

Authored by taolq on Jun 26 2021, 1:47 AM.

Details

Summary

The patch templatize PriorityInlinerOrder so that it can accept any type priority metric.

Diff Detail

Event Timeline

taolq created this revision.Jun 26 2021, 1:47 AM
taolq requested review of this revision.Jun 26 2021, 1:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2021, 1:47 AM
taolq retitled this revision from templatize priorityinlineorder to [llvm][Inliner] Templatize PriorityInlineOrder.Jun 26 2021, 1:53 AM
taolq edited the summary of this revision. (Show Details)
taolq added reviewers: mtrofin, kazu, teemperor.
ormris removed a subscriber: ormris.Jun 29 2021, 10:19 AM
kazu added inline comments.Jun 30 2021, 1:26 PM
llvm/lib/Transforms/IPO/Inliner.cpp
873–877

How about packaging the type int, isMoraDesirable, and evaluate into one class?

class Priority {
public:
  static bool isMoreDesirable(const Priority &S1, const Priority &S2) {
    return S1.size < S2.size;
  }
  static Priority evaluate(CallBase *CB) {
    ...
  }
  int size;
};

This way, we don't have to pass individual components to PriorityInlineOrder.

Once you do this, you should be able to your original definition of cmp more or less restore like so:

static bool cmp(const T &P1, const T &P2) {
  return Priority::isMoreDesirable(P2.second, P1.second);
}
taolq updated this revision to Diff 355803.Jul 1 2021, 2:23 AM
taolq marked an inline comment as done.
taolq edited the summary of this revision. (Show Details)
This comment was removed by taolq.
taolq updated this revision to Diff 355805.Jul 1 2021, 2:24 AM
  • pack one class Priority
taolq updated this revision to Diff 355806.Jul 1 2021, 2:27 AM
  • renaming
taolq updated this revision to Diff 356070.Jul 1 2021, 6:35 PM
  • renaming size -> Size
kazu accepted this revision.Jul 7 2021, 4:25 PM

Thank you for revising the patch!

This revision is now accepted and ready to land.Jul 7 2021, 4:25 PM
This revision was automatically updated to reflect the committed changes.