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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

33

34using namespace llvm;

35

36#define DEBUG_TYPE "static-data-splitter"

37

38STATISTIC(NumHotJumpTables, "Number of hot jump tables seen");

39STATISTIC(NumColdJumpTables, "Number of cold jump tables seen");

41 "Number of jump tables with unknown hotness. Option "

42 "-static-data-default-hotness specifies the hotness.");

43

45 "static-data-default-hotness", cl::Hidden,

46 cl::desc("This option specifies the hotness of static data when profile "

47 "information is unavailable"),

48 cl::init(MachineFunctionDataHotness::Hot),

50 clEnumValN(MachineFunctionDataHotness::Cold, "cold", "Cold")));

51

56

57

59

60

61 bool splitJumpTablesWithProfiles(const MachineFunction &MF,

63

64public:

65 static char ID;

66

69 }

70

72

78 }

79

81};

82

84 MBPI = &getAnalysis().getMBPI();

85 MBFI = &getAnalysis().getMBFI();

86 PSI = &getAnalysis().getPSI();

87

88 return splitJumpTables(MF);

89}

90

91bool StaticDataSplitter::splitJumpTablesWithProfiles(

93 int NumChangedJumpTables = 0;

94

95

96

97

98

99

100 for (const auto &MBB : MF) {

103 if (Op.isJTI())

104 continue;

105 const int JTI = Op.getIndex();

106

107 if (JTI == -1)

108 continue;

109

110 auto Hotness = MachineFunctionDataHotness::Hot;

111

112

113

114

116 Hotness = MachineFunctionDataHotness::Cold;

117

119 ++NumChangedJumpTables;

120 }

121 }

122 }

123 return NumChangedJumpTables > 0;

124}

125

126bool StaticDataSplitter::splitJumpTables(MachineFunction &MF) {

129 return false;

130

131 const bool ProfileAvailable = PSI && PSI->hasProfileSummary() && MBFI &&

135 return;

136

137 if (!ProfileAvailable) {

139 return;

140 }

141

142 for (size_t JTI = 0; JTI < MJTI->getJumpTables().size(); JTI++) {

143 auto Hotness = MJTI->getJumpTables()[JTI].Hotness;

144 if (Hotness == MachineFunctionDataHotness::Hot) {

145 ++NumHotJumpTables;

146 } else {

147 assert(Hotness == MachineFunctionDataHotness::Cold &&

148 "A jump table is either hot or cold when profile information is "

149 "available.");

150 ++NumColdJumpTables;

151 }

152 }

153 });

154

155

156 if (ProfileAvailable)

157 return splitJumpTablesWithProfiles(MF, *MJTI);

158

159

160

161

165

166 return true;

167}

168

170

172 false, false)

178

181}

#define clEnumValN(ENUMVAL, FLAGNAME, DESC)

This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...

#define INITIALIZE_PASS_DEPENDENCY(depName)

#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)

#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...

static cl::opt< MachineFunctionDataHotness > StaticDataDefaultHotness("static-data-default-hotness", cl::Hidden, cl::desc("This option specifies the hotness of static data when profile " "information is unavailable"), cl::init(MachineFunctionDataHotness::Hot), cl::values(clEnumValN(MachineFunctionDataHotness::Hot, "hot", "Hot"), clEnumValN(MachineFunctionDataHotness::Cold, "cold", "Cold")))

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...

#define STATISTIC(VARNAME, DESC)

StringRef getPassName() const override

getPassName - Return a nice clean name for a pass.

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

bool runOnMachineFunction(MachineFunction &MF) override

runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

This class represents an Operation in the Expression.

bool hasProfileData(bool IncludeSynthetic=false) const

Return true if the function is annotated with profile data.

MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...

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.

Function & getFunction()

Return the LLVM function that this machine code represents.

const MachineJumpTableInfo * getJumpTableInfo() const

getJumpTableInfo - Return the jump table info object for the current function.

Representation of each machine instruction.

bool updateJumpTableEntryHotness(size_t JTI, MachineFunctionDataHotness Hotness)

const std::vector< MachineJumpTableEntry > & getJumpTables() const

MachineOperand class - Representation of each machine instruction operand.

static PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.

Analysis providing profile information.

bool hasProfileSummary() const

Returns true if profile summary is available.

bool isColdBlock(const BBType *BB, BFIT *BFI) const

Returns true if BasicBlock BB is considered cold.

StringRef - Represent a constant reference to a string, i.e.

ValuesClass values(OptsTy... Options)

Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)

MachineFunctionPass * createStaticDataSplitterPass()

createStaticDataSplitterPass - This pass partitions a static data section into a hot and cold section...

bool AreStatisticsEnabled()

Check if statistics are enabled.

void initializeStaticDataSplitterPass(PassRegistry &)