diff options
author | Amir Ayupov <aaupov@fb.com> | 2022-05-05 00:07:42 +0300 |
---|---|---|
committer | Amir Ayupov <aaupov@fb.com> | 2022-05-05 00:08:06 +0300 |
commit | f8d2d8b587db6255bbb8ca7b87091dabb9dbecf0 (patch) | |
tree | 7198531bf72560ec78edc3bff50fb1289aa81567 /bolt | |
parent | 2ad1c7540eb0e07047911a39d12a12d062d4bbf4 (diff) |
[BOLT][NFC] Move getInliningInfo out of Inliner class
`getInliningInfo` is useful in other passes that need to check inlining
eligibility for some function. Move the declaration and InliningInfo definition
out of Inliner class. Prepare for subsequent use in ICP.
Reviewed By: rafauler
Differential Revision: https://reviews.llvm.org/D124899
Diffstat (limited to 'bolt')
-rw-r--r-- | bolt/include/bolt/Passes/Inliner.h | 31 | ||||
-rw-r--r-- | bolt/lib/Passes/Inliner.cpp | 7 |
2 files changed, 18 insertions, 20 deletions
diff --git a/bolt/include/bolt/Passes/Inliner.h b/bolt/include/bolt/Passes/Inliner.h index c6a9b891e68a..711eae69d1c9 100644 --- a/bolt/include/bolt/Passes/Inliner.h +++ b/bolt/include/bolt/Passes/Inliner.h @@ -18,22 +18,24 @@ namespace llvm { namespace bolt { -class Inliner : public BinaryFunctionPass { -private: - enum InliningType : char { - INL_NONE = 0, /// Cannot inline - INL_TAILCALL, /// Can inline at tail call site - INL_ANY /// Can inline at any call site - }; +enum InliningType : char { + INL_NONE = 0, /// Cannot inline + INL_TAILCALL, /// Can inline at tail call site + INL_ANY /// Can inline at any call site +}; + +struct InliningInfo { + InliningType Type{INL_NONE}; + uint64_t SizeAfterInlining{0}; + uint64_t SizeAfterTailCallInlining{0}; - struct InliningInfo { - InliningType Type{INL_NONE}; - uint64_t SizeAfterInlining{0}; - uint64_t SizeAfterTailCallInlining{0}; + InliningInfo(InliningType Type = INL_NONE) : Type(Type) {} +}; - InliningInfo(InliningType Type = INL_NONE) : Type(Type) {} - }; +/// Check if the inliner can handle inlining of \p BF. +InliningInfo getInliningInfo(const BinaryFunction &BF); +class Inliner : public BinaryFunctionPass { std::unordered_map<const BinaryFunction *, InliningInfo> InliningCandidates; /// Count total amount of bytes inlined for all instances of Inliner. @@ -74,9 +76,6 @@ private: inlineCall(BinaryBasicBlock &CallerBB, BinaryBasicBlock::iterator CallInst, const BinaryFunction &Callee); - /// Check if the inliner can handle inlining of \p BF. - InliningInfo getInliningInfo(const BinaryFunction &BF) const; - public: explicit Inliner(const cl::opt<bool> &PrintPass) : BinaryFunctionPass(PrintPass) {} diff --git a/bolt/lib/Passes/Inliner.cpp b/bolt/lib/Passes/Inliner.cpp index 595d08191584..85b8c16f174b 100644 --- a/bolt/lib/Passes/Inliner.cpp +++ b/bolt/lib/Passes/Inliner.cpp @@ -167,10 +167,7 @@ uint64_t Inliner::getSizeOfTailCallInst(const BinaryContext &BC) { return SizeOfTailCallInst; } -Inliner::InliningInfo Inliner::getInliningInfo(const BinaryFunction &BF) const { - if (!shouldOptimize(BF)) - return INL_NONE; - +InliningInfo getInliningInfo(const BinaryFunction &BF) { const BinaryContext &BC = BF.getBinaryContext(); bool DirectSP = false; bool HasCFI = false; @@ -250,6 +247,8 @@ Inliner::InliningInfo Inliner::getInliningInfo(const BinaryFunction &BF) const { void Inliner::findInliningCandidates(BinaryContext &BC) { for (const auto &BFI : BC.getBinaryFunctions()) { const BinaryFunction &Function = BFI.second; + if (!shouldOptimize(Function)) + continue; const InliningInfo InlInfo = getInliningInfo(Function); if (InlInfo.Type != INL_NONE) InliningCandidates[&Function] = InlInfo; |