30#define DEBUG_TYPE "tailduplication"
36 std::unique_ptr<MBFIWrapper> MBFIW;
39 TailDuplicateBaseLegacy(
char &PassID,
bool PreRegAlloc)
52class TailDuplicateLegacy :
public TailDuplicateBaseLegacy {
55 TailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
false) {}
58class EarlyTailDuplicateLegacy :
public TailDuplicateBaseLegacy {
61 EarlyTailDuplicateLegacy() : TailDuplicateBaseLegacy(
ID,
true) {}
70char TailDuplicateLegacy::ID;
71char EarlyTailDuplicateLegacy::ID;
81bool TailDuplicateBaseLegacy::runOnMachineFunction(
MachineFunction &MF) {
82 if (skipFunction(MF.getFunction()))
85 auto MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
86 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
87 auto *MBFI = (PSI && PSI->hasProfileSummary()) ?
88 &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() :
91 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
92 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
95 bool MadeChange =
false;
96 while (Duplicator.tailDuplicateBlocks())
102template <
typename DerivedT,
bool PreRegAlloc>
109 .getCachedResult<ProfileSummaryAnalysis>(
111 auto *MBFI = (PSI && PSI->hasProfileSummary()
115 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
118 Duplicator.
initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
120 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()
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.
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.
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.