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

1

2

3

4

5

6

7

8

9

10

11

12

18

19using namespace llvm;

20

21

22template

23void SyntheticCountsUtils::propagateFromSCC(

24 const SccTy &SCC, GetProfCountTy GetProfCount, AddCountTy AddCount) {

25

28

29

30

31 for (const auto &Node : SCCNodes) {

33 if (SCCNodes.count(CGT::edge_dest(E)))

35 else

37 }

38 }

39

40

41

42

43

44

45

46

47

49 for (auto &E : SCCEdges) {

50 auto OptProfCount = GetProfCount(E.first, E.second);

51 if (!OptProfCount)

52 continue;

53 auto Callee = CGT::edge_dest(E.second);

54 AdditionalCounts[Callee] += *OptProfCount;

55 }

56

57

58 for (auto &Entry : AdditionalCounts)

59 AddCount(Entry.first, Entry.second);

60

61

62 for (auto &E : NonSCCEdges) {

63 auto OptProfCount = GetProfCount(E.first, E.second);

64 if (!OptProfCount)

65 continue;

66 auto Callee = CGT::edge_dest(E.second);

67 AddCount(Callee, *OptProfCount);

68 }

69}

70

71

72

73

74

75

76

77

78

79template

83 std::vector SCCs;

84

85

86 for (auto I = scc_begin(CG); I.isAtEnd(); ++I)

87 SCCs.push_back(*I);

88

89

90

91

92 for (auto &SCC : reverse(SCCs))

93 propagateFromSCC(SCC, GetProfCount, AddCount);

94}

95

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...

This file defines the DenseSet and SmallDenseSet classes.

ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...

This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...

Implements a dense probed hash-table based set.

reference emplace_back(ArgTypes &&... Args)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

Class with methods to propagate synthetic entry counts.

function_ref< std::optional< Scaled64 >(NodeRef, EdgeRef)> GetProfCountTy

function_ref< void(NodeRef, Scaled64)> AddCountTy

static void propagate(const CallGraphType &CG, GetProfCountTy GetProfCount, AddCountTy AddCount)

Propgate synthetic entry counts on a callgraph CG.

Definition SyntheticCountsUtils.cpp:80

This is an optimization pass for GlobalISel generic memory operations.

constexpr from_range_t from_range

scc_iterator< T > scc_begin(const T &G)

Construct the begin iterator for a deduced graph type T.

auto reverse(ContainerTy &&C)

iterator_range< typename GraphTraits< GraphType >::ChildEdgeIteratorType > children_edges(const typename GraphTraits< GraphType >::NodeRef &G)