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) {
75char TailDuplicateLegacy::ID;
76char EarlyTailDuplicateLegacy::ID;
86bool TailDuplicateBaseLegacy::runOnMachineFunction(
MachineFunction &MF) {
87 if (skipFunction(MF.getFunction()))
90 auto MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
91 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
92 auto *MBFI = (PSI && PSI->hasProfileSummary()) ?
93 &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() :
96 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
97 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
100 bool MadeChange =
false;
101 while (Duplicator.tailDuplicateBlocks())
107template <
typename DerivedT,
bool PreRegAlloc>
114 .getCachedResult<ProfileSummaryAnalysis>(
116 auto *MBFI = (PSI && PSI->hasProfileSummary()
120 MBFIW = std::make_unique<MBFIWrapper>(*MBFI);
123 Duplicator.
initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() :
nullptr, PSI,
125 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.
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 LLVM_ABI 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.
LLVM_ABI char & TailDuplicateLegacyID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI void initializeTailDuplicateLegacyPass(PassRegistry &)
LLVM_ABI char & EarlyTailDuplicateLegacyID
Duplicate blocks with unconditional branches into tails of their predecessors.
LLVM_ABI void initializeEarlyTailDuplicateLegacyPass(PassRegistry &)