LLVM: lib/CodeGen/TailDuplication.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

28

29using namespace llvm;

30

31#define DEBUG_TYPE "tailduplication"

32

33namespace {

34

37 std::unique_ptr MBFIW;

38 bool PreRegAlloc;

39public:

40 TailDuplicateBaseLegacy(char &PassID, bool PreRegAlloc)

42

44

45 void getAnalysisUsage(AnalysisUsage &AU) const override {

50 }

51};

52

53class TailDuplicateLegacy : public TailDuplicateBaseLegacy {

54public:

55 static char ID;

56 TailDuplicateLegacy() : TailDuplicateBaseLegacy(ID, false) {

58 }

59};

60

61class EarlyTailDuplicateLegacy : public TailDuplicateBaseLegacy {

62public:

63 static char ID;

64 EarlyTailDuplicateLegacy() : TailDuplicateBaseLegacy(ID, true) {

66 }

67

70 }

71};

72

73}

74

75char TailDuplicateLegacy::ID;

76char EarlyTailDuplicateLegacy::ID;

77

80

82 false)

85

86bool TailDuplicateBaseLegacy::runOnMachineFunction(MachineFunction &MF) {

87 if (skipFunction(MF.getFunction()))

88 return false;

89

90 auto MBPI = &getAnalysis().getMBPI();

91 auto *PSI = &getAnalysis().getPSI();

92 auto *MBFI = (PSI && PSI->hasProfileSummary()) ?

93 &getAnalysis().getBFI() :

94 nullptr;

95 if (MBFI)

96 MBFIW = std::make_unique(*MBFI);

97 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() : nullptr, PSI,

98 false);

99

100 bool MadeChange = false;

101 while (Duplicator.tailDuplicateBlocks())

102 MadeChange = true;

103

104 return MadeChange;

105}

106

107template <typename DerivedT, bool PreRegAlloc>

111

114 .getCachedResult(

116 auto *MBFI = (PSI && PSI->hasProfileSummary()

118 : nullptr);

119 if (MBFI)

120 MBFIW = std::make_unique(*MBFI);

121

123 Duplicator.initMF(MF, PreRegAlloc, MBPI, MBFI ? MBFIW.get() : nullptr, PSI,

124 false);

125 bool MadeChange = false;

127 MadeChange = true;

128

129 if (!MadeChange)

132}

133

===- 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.

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)

Definition TailDuplication.cpp:108

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.

Definition TailDuplication.cpp:78

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

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.

Definition TailDuplication.cpp:79

LLVM_ABI void initializeEarlyTailDuplicateLegacyPass(PassRegistry &)