[PATCH] D104972: [llvm][Inliner] Templatize PriorityInlineOrder
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 13:26:10 PDT 2021
kazu added inline comments.
================
Comment at: llvm/lib/Transforms/IPO/Inliner.cpp:857-861
+ auto IsMoreDesirable = [](int S1, int S2) { return S1 < S2; };
+ auto Evaluate = [](CallBase *CB) {
+ Function *Callee = CB->getCalledFunction();
+ return (int)Callee->getInstructionCount();
+ };
----------------
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);
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104972/new/
https://reviews.llvm.org/D104972
More information about the llvm-commits
mailing list