LLVM: lib/Analysis/OptimizationRemarkEmitter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

23#include

24

25using namespace llvm;

26

28 : F(F), BFI(nullptr) {

29 if (!F->getContext().getDiagnosticsHotnessRequested())

30 return;

31

32

35

36

39

40

42

43

44 OwnedBFI = std::make_unique(*F, BPI, LI);

45 BFI = OwnedBFI.get();

46}

47

50 FunctionAnalysisManager::Invalidator &Inv) {

51 if (OwnedBFI) {

52 OwnedBFI.reset();

53 BFI = nullptr;

54 }

55

56

58 return true;

59

60

61 return false;

62}

63

64std::optional<uint64_t>

65OptimizationRemarkEmitter::computeHotness(const Value *V) {

66 if (!BFI)

67 return std::nullopt;

68

70}

71

72void OptimizationRemarkEmitter::computeHotness(

75 if (V)

76 OptDiag.setHotness(computeHotness(V));

77}

78

82 computeHotness(OptDiag);

83

84

85 if (OptDiag.getHotness().value_or(0) <

86 F->getContext().getDiagnosticsHotnessThreshold()) {

87 return;

88 }

89

90 F->getContext().diagnose(OptDiag);

91}

92

95

98

100 if (Context.getDiagnosticsHotnessRequested()) {

102

103 if (Context.isDiagnosticsHotnessThresholdSetFromPSI()) {

106 Context.setDiagnosticsHotnessThreshold(

107 PSI->getOrCompHotCountThreshold());

108 }

109 } else

110 BFI = nullptr;

111

112 ORE = std::make_unique(&Fn, BFI);

113 return false;

114}

115

122

123AnalysisKey OptimizationRemarkEmitterAnalysis::Key;

124

129 auto &Context = F.getContext();

130

131 if (Context.getDiagnosticsHotnessRequested()) {

133

134 if (Context.isDiagnosticsHotnessThresholdSetFromPSI()) {

138 Context.setDiagnosticsHotnessThreshold(

139 PSI->getOrCompHotCountThreshold());

140 }

141 } else

142 BFI = nullptr;

143

145}

146

148static const char ore_name[] = "Optimization Remark Emitter";

149#define ORE_NAME "opt-remark-emitter"

150

152 false, true)

#define INITIALIZE_PASS_DEPENDENCY(depName)

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

#define INITIALIZE_PASS_BEGIN(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()

void setPreservesAll()

Set by analyses that do not transform their input at all.

Analysis pass which computes BlockFrequencyInfo.

BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...

LLVM_ABI std::optional< uint64_t > getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic=false) const

Returns the estimated profile count of BB.

Analysis providing branch probability information.

Common features for diagnostics dealing with optimization remarks that are used by IR passes.

const BasicBlock * getCodeRegion() const

Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...

void setHotness(std::optional< uint64_t > H)

std::optional< uint64_t > getHotness() const

void recalculate(ParentType &Func)

recalculate - compute a dominator tree for the given function

Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.

LLVMContext & getContext() const

getContext - Return a reference to the LLVMContext associated with this function.

static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)

Helper for client passes to set up the analysis usage on behalf of this pass.

void analyze(const DominatorTreeBase< BlockT, false > &DomTree)

Create the loop forest using a stable algorithm.

AnalysisType & getAnalysis() const

getAnalysis() - This function is used by subclasses to get to the analysis information ...

A set of analyses that are preserved following a run of a transformation pass.

An analysis pass based on the new PM to deliver ProfileSummaryInfo.

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

Analysis providing profile information.

LLVM Value Representation.

This is an optimization pass for GlobalISel generic memory operations.

OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy

Provide the ModuleAnalysisManager to Function proxy.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

A special type used by analysis passes to provide an address that identifies that particular analysis...