LLVM: include/llvm/Analysis/MemoryProfileInfo.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_ANALYSIS_MEMORYPROFILEINFO_H

14#define LLVM_ANALYSIS_MEMORYPROFILEINFO_H

15

18#include

19

20namespace llvm {

21namespace memprof {

22

23

26

27

28

30

31

32

35

36

38

39

41

42

44

45

47

48

49

50

51

52

54private:

55 struct CallStackTrieNode {

56

57

59

60

61

62

63 std::vector ContextSizeInfo;

64

65 std::map<uint64_t, CallStackTrieNode *> Callers;

67 : AllocTypes(static_cast<uint8_t>(Type)) {}

68 };

69

70

71 CallStackTrieNode *Alloc = nullptr;

72

74

75 void deleteTrieNode(CallStackTrieNode *Node) {

77 return;

78 for (auto C : Node->Callers)

79 deleteTrieNode(C.second);

81 }

82

83

84

85 void collectContextSizeInfo(CallStackTrieNode *Node,

86 std::vector &ContextSizeInfo);

87

88

89 bool buildMIBNodes(CallStackTrieNode *Node, LLVMContext &Ctx,

90 std::vector<uint64_t> &MIBCallStack,

91 std::vector<Metadata *> &MIBNodes,

92 bool CalleeHasAmbiguousCallerContext);

93

94public:

97

98 bool empty() const { return Alloc == nullptr; }

99

100

101

102

103

104

106 std::vector ContextSizeInfo = {});

107

108

109

111

112

113

114

115

116

117

118

120

121

122

123

126};

127

128

129

130

131

132

133template <class NodeT, class IteratorT> class CallStack {

134public:

135 CallStack(const NodeT *N = nullptr) : N(N) {}

136

137

138

139

140

142 const NodeT *N = nullptr;

149 };

150

151 bool empty() const { return N == nullptr; }

152

153 CallStackIterator begin() const;

157

158private:

159 const NodeT *N = nullptr;

160};

161

162template <class NodeT, class IteratorT>

164 const NodeT *N, bool End)

165 : N(N) {

166 if (N) {

167 Iter = nullptr;

168 return;

169 }

170 Iter = End ? N->StackIdIndices.end() : N->StackIdIndices.begin();

171}

172

173template <class NodeT, class IteratorT>

175 assert(Iter != N->StackIdIndices.end());

176 return *Iter;

177}

178

179template <class NodeT, class IteratorT>

182 return N->StackIdIndices.back();

183}

184

185template <class NodeT, class IteratorT>

189}

190

191template <class NodeT, class IteratorT>

196 Cur != end() && OtherCur != Other.end(); ++Cur, ++OtherCur)

197 assert(*Cur == *OtherCur);

198 return Cur;

199}

200

201

202template <>

205template <>

208

209}

210}

211

212#endif

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

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

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

This is an important class for using LLVM in a threaded context.

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

The instances of the Type class are immutable: once they are created, they are never changed.

Class to build a trie of call stack contexts for a particular profiled allocation call,...

void addCallStack(AllocationType AllocType, ArrayRef< uint64_t > StackIds, std::vector< ContextTotalSize > ContextSizeInfo={})

Add a call stack context with the given allocation type to the Trie.

void addSingleAllocTypeAttribute(CallBase *CI, AllocationType AT, StringRef Descriptor)

Add an attribute for the given allocation type to the call instruction.

bool buildAndAttachMIBMetadata(CallBase *CI)

Build and attach the minimal necessary MIB metadata.

Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...

CallStack(const NodeT *N=nullptr)

CallStackIterator begin() const

CallStackIterator end() const

CallStackIterator beginAfterSharedPrefix(CallStack &Other)

@ C

The default llvm calling convention, compatible with C.

MDNode * buildCallstackMetadata(ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)

Build callstack metadata from the provided list of call stack ids.

AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)

Return the allocation type for a given set of memory profile values.

MDNode * buildContextSizeMetadata(ArrayRef< ContextTotalSize > ContextSizeInfo, LLVMContext &Ctx)

Build metadata from the provided list of full stack id and profiled size, to use when reporting of hi...

AllocationType getMIBAllocType(const MDNode *MIB)

Returns the allocation type from an MIB metadata node.

bool hasSingleAllocType(uint8_t AllocTypes)

True if the AllocTypes bitmask contains just a single type.

std::string getAllocTypeAttributeString(AllocationType Type)

Returns the string to use in attributes with the given type.

MDNode * getMIBStackNode(const MDNode *MIB)

Returns the stack node from an MIB metadata node.

This is an optimization pass for GlobalISel generic memory operations.

bool operator!=(const CallStackIterator &rhs)

bool operator==(const CallStackIterator &rhs)

CallStackIterator(const NodeT *N, bool End)