31#define DEBUG_TYPE "tailduplication"
37 std::unique_ptr<MBFIWrapper> MBFIW;
40 TailDuplicateBaseLegacy(
char &PassID,
bool PreRegAlloc)
53class TailDuplicateLegacy :
public TailDuplicateBaseLegacy {
56 TailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
false) {
61class EarlyTailDuplicateLegacy :
public TailDuplicateBaseLegacy {
64 EarlyTailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
true) {
70 .
set(MachineFunctionProperties::Property::NoPHIs);
76char TailDuplicateLegacy::ID;
77char EarlyTailDuplicateLegacy::ID;
87bool TailDuplicateBaseLegacy::runOnMachineFunction(
MachineFunction &MF) {
88 if (skipFunction(MF.getFunction()))
91 auto MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
92 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
93 auto *MBFI = (PSI && PSI->hasProfileSummary()) ?
94 &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() :
97 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
98 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
101 bool MadeChange =
false;
102 while (Duplicator.tailDuplicateBlocks())
108template <
typename DerivedT,
bool PreRegAlloc>
115 .getCachedResult<ProfileSummaryAnalysis>(
117 auto *MBFI = (PSI && PSI->hasProfileSummary()
121 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
124 Duplicator.
initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
126 bool MadeChange =
false;
===- LazyMachineBlockFrequencyInfo.h - Lazy Block Frequency -*- C++ -*–===//
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
early Early Tail Duplication
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
Module * getParent()
Get the module that this global value is contained inside of...
This is an alternative analysis pass to MachineBlockFrequencyInfo.
An RAII based helper class to modify MachineFunctionProperties when running pass.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
Function & getFunction()
Return the LLVM function that this machine code represents.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Utility class to perform tail duplication.
void initMF(MachineFunction &MF, bool PreRegAlloc, const MachineBranchProbabilityInfo *MBPI, MBFIWrapper *MBFI, ProfileSummaryInfo *PSI, bool LayoutMode, unsigned TailDupSize=0)
Prepare to run on a specific machine function.
bool tailDuplicateBlocks()
Look for small blocks that are unconditionally branched to and do not fall through.
Pass manager infrastructure for declaring and invalidating analyses.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
This is an optimization pass for GlobalISel generic memory operations.
char & TailDuplicateLegacyID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
void initializeTailDuplicateLegacyPass(PassRegistry &)
PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
void initializeEarlyTailDuplicateLegacyPass(PassRegistry &)
char & EarlyTailDuplicateLegacyID
Duplicate blocks with unconditional branches into tails of their predecessors.