LLVM: include/llvm/CGData/StableFunctionMap.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_CGDATA_STABLEFUNCTIONMAP_H

17#define LLVM_CGDATA_STABLEFUNCTIONMAP_H

18

24#include

25#include <unordered_map>

26

27namespace llvm {

28

31

32

33

54

56

77

80

81

82

83

85

86

87

89

90 private:

91

92

93

94

95

97 std::once_flag LazyLoadFlag;

100 };

101

102

103

104

106

107

109

110

112

113

114

116

117

119

120

121

122

124

125

127

128

130

131

132

133 bool contains(HashFuncsMapType::key_type FunctionHash) const {

134 return HashToFuncs.count(FunctionHash) > 0;

135 }

136

137

138

139

140

142 at(HashFuncsMapType::key_type FunctionHash) const;

143

150

151

152

154

155

157

158private:

159

160

161

162 void insert(std::unique_ptr FuncEntry) {

163 assert(!Finalized && "Cannot insert after finalization");

164 HashToFuncs[FuncEntry->Hash].Entries.emplace_back(std::move(FuncEntry));

165 }

166

167 void deserializeLazyLoadingEntry(HashFuncsMapType::iterator It) const;

168

169

170 void deserializeLazyLoadingEntries() const;

171

172 bool isLazilyLoaded() const { return (bool)Buffer; }

173

174

176

177 SmallVectorstd::string IdToName;

178

179 StringMap NameToId;

180

181 bool Finalized = false;

182

183

184

185

186 std::shared_ptr Buffer;

187

188 bool ReadStableFunctionMapNames = true;

189

191};

192

193}

194

195#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file defines the StringMap class.

#define LLVM_ABI_FOR_TEST

This file defines the DenseMap class.

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

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

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.

Assignment Tracking (at).

This is an optimization pass for GlobalISel generic memory operations.

uint64_t stable_hash

An opaque object representing a stable hash code.

SmallVector< IndexPairHash > IndexOperandHashVecType

Definition StableFunctionMap.h:30

std::pair< IndexPair, stable_hash > IndexPairHash

Definition StableFunctionMap.h:29

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.

In addition to the deserialized StableFunctionEntry, the struct stores the offsets of corresponding s...

Definition StableFunctionMap.h:84

StableFunctionEntries Entries

The actual storage of deserialized stable function entries.

Definition StableFunctionMap.h:88

friend struct StableFunctionMap

Definition StableFunctionMap.h:98

friend struct StableFunctionMapRecord

Definition StableFunctionMap.h:99

StableFunctionEntry(stable_hash Hash, unsigned FunctionNameId, unsigned ModuleNameId, unsigned InstCount, std::unique_ptr< IndexOperandHashMapType > IndexOperandHashMap)

Definition StableFunctionMap.h:69

stable_hash Hash

The combined stable hash of the function.

Definition StableFunctionMap.h:59

std::unique_ptr< IndexOperandHashMapType > IndexOperandHashMap

A map from an IndexPair to a stable_hash which was skipped.

Definition StableFunctionMap.h:67

unsigned InstCount

The number of instructions.

Definition StableFunctionMap.h:65

unsigned FunctionNameId

Id of the function name.

Definition StableFunctionMap.h:61

unsigned ModuleNameId

Id of the module name.

Definition StableFunctionMap.h:63

Definition StableFunctionMap.h:55

std::unordered_map< stable_hash, EntryStorage > HashFuncsMapType

Definition StableFunctionMap.h:105

SmallVector< std::unique_ptr< StableFunctionEntry > > StableFunctionEntries

Definition StableFunctionMap.h:78

LLVM_ABI size_t size(SizeType Type=UniqueHashCount) const

bool empty() const

Definition StableFunctionMap.h:129

LLVM_ABI void insert(const StableFunction &Func)

Insert a StableFunction object into the function map.

ArrayRef< std::string > getNames() const

Get the NameToId vector for serialization.

Definition StableFunctionMap.h:111

LLVM_ABI void merge(const StableFunctionMap &OtherMap)

Merge a OtherMap into this function map.

LLVM_ABI std::optional< std::string > getNameForId(unsigned Id) const

Get the name associated with a given ID.

LLVM_ABI_FOR_TEST const HashFuncsMapType & getFunctionMap() const

Get the HashToFuncs map for serialization.

LLVM_ABI unsigned getIdOrCreateForName(StringRef Name)

Get an existing ID associated with the given name or create a new ID if it doesn't exist.

friend struct StableFunctionMapRecord

Definition StableFunctionMap.h:190

bool contains(HashFuncsMapType::key_type FunctionHash) const

Definition StableFunctionMap.h:133

SizeType

Definition StableFunctionMap.h:144

@ MergeableFunctionCount

Definition StableFunctionMap.h:147

@ UniqueHashCount

Definition StableFunctionMap.h:145

@ TotalFunctionCount

Definition StableFunctionMap.h:146

A stable function is a function with a stable hash while tracking the locations of ignored operands a...

Definition StableFunctionMap.h:34

unsigned InstCount

The number of instructions.

Definition StableFunctionMap.h:42

StableFunction(stable_hash Hash, const std::string FunctionName, const std::string ModuleName, unsigned InstCount, IndexOperandHashVecType &&IndexOperandHashes)

Definition StableFunctionMap.h:46

stable_hash Hash

The combined stable hash of the function.

Definition StableFunctionMap.h:36

IndexOperandHashVecType IndexOperandHashes

A vector of pairs of IndexPair and operand hash which was skipped.

Definition StableFunctionMap.h:44

std::string FunctionName

The name of the function.

Definition StableFunctionMap.h:38

std::string ModuleName

The name of the module the function is in.

Definition StableFunctionMap.h:40