31#define DEBUG_TYPE "tailduplication"
37 std::unique_ptr<MBFIWrapper> MBFIW;
40 TailDuplicateBaseLegacy(
char &PassID,
bool PreRegAlloc)
54class TailDuplicateLegacy :
public TailDuplicateBaseLegacy {
57 TailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
false) {}
60class EarlyTailDuplicateLegacy :
public TailDuplicateBaseLegacy {
63 EarlyTailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
true) {}
72char TailDuplicateLegacy::ID;
73char EarlyTailDuplicateLegacy::ID;
83bool TailDuplicateBaseLegacy::runOnMachineFunction(
MachineFunction &MF) {
84 if (skipFunction(MF.getFunction()))
87 auto MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
88 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
89 auto *MBFI = (PSI && PSI->hasProfileSummary()) ?
90 &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() :
93 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
94 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
97 bool MadeChange =
false;
98 while (Duplicator.tailDuplicateBlocks())
104template <
typename DerivedT,
bool PreRegAlloc>
111 .getCachedResult<ProfileSummaryAnalysis>(
113 auto *MBFI = (PSI && PSI->hasProfileSummary()
117 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
120 Duplicator.
initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
122 bool MadeChange =
false;
===- LazyMachineBlockFrequencyInfo.h - Lazy Block Frequency -*- C++ -*–===//
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
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.
Properties which a MachineFunction may have at a given point in time.
Function & getFunction()
Return the LLVM function that this machine code represents.
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.
LLVM_ABI 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.
LLVM_ABI bool tailDuplicateBlocks()
Look for small blocks that are unconditionally branched to and do not fall through.
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
LLVM_ABI char & TailDuplicateLegacyID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI char & EarlyTailDuplicateLegacyID
Duplicate blocks with unconditional branches into tails of their predecessors.