19#define DEBUG_TYPE "stable-function-map-record"
32 IO.mapRequired(
"InstIndex", Key.first.first);
33 IO.mapRequired(
"OpndIndex", Key.first.second);
34 IO.mapRequired(
"OpndHash", Key.second);
40 IO.mapRequired(
"Hash", Func.Hash);
41 IO.mapRequired(
"FunctionName", Func.FunctionName);
42 IO.mapRequired(
"ModuleName", Func.ModuleName);
43 IO.mapRequired(
"InstCount", Func.InstCount);
44 IO.mapRequired(
"IndexOperandHashes", Func.IndexOperandHashes);
56 for (
auto &Func :
P.second)
60 FuncEntries.
begin(), FuncEntries.
end(), [&](
auto &
A,
auto &
B) {
61 return std::tuple(A->Hash, SFM.getNameForId(A->ModuleNameId),
62 SFM.getNameForId(A->FunctionNameId)) <
63 std::tuple(B->Hash, SFM.getNameForId(B->ModuleNameId),
64 SFM.getNameForId(B->FunctionNameId));
77 return IndexOperandHashes;
92 for (
auto &
Name : Names) {
94 ByteSize +=
Name.size() + 1;
105 for (
const auto *FuncRef : FuncEntries) {
115 for (
auto &IndexOperandHash : IndexOperandHashes) {
128 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
132 for (
unsigned I = 0;
I < NumNames; ++
I) {
142 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
143 for (
unsigned I = 0;
I < NumFuncs; ++
I) {
145 endian::readNext<stable_hash, endianness::little, unaligned>(
Ptr);
146 auto FunctionNameId =
147 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
149 "FunctionNameId out of range");
151 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
153 "ModuleNameId out of range");
155 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
158 auto NumIndexOperandHashes =
159 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
160 auto IndexOperandHashMap = std::make_unique<IndexOperandHashMapType>();
161 for (
unsigned J = 0; J < NumIndexOperandHashes; ++J) {
163 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
165 endian::readNext<uint32_t, endianness::little, unaligned>(
Ptr);
167 endian::readNext<stable_hash, endianness::little, unaligned>(
Ptr);
168 assert(InstIndex < InstCount &&
"InstIndex out of range");
170 IndexOperandHashMap->try_emplace({InstIndex, OpndIndex}, OpndHash);
174 auto FuncEntry = std::make_unique<StableFunctionMap::StableFunctionEntry>(
175 Hash, FunctionNameId, ModuleNameId, InstCount,
176 std::move(IndexOperandHashMap));
185 for (
const auto *FuncEntry : FuncEntries) {
188 FuncEntry->Hash, *
FunctionMap->getNameForId(FuncEntry->FunctionNameId),
189 *
FunctionMap->getNameForId(FuncEntry->ModuleNameId),
190 FuncEntry->InstCount, std::move(IndexOperandHashes));
197 std::vector<StableFunction> Funcs;
199 for (
auto &Func : Funcs)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static IndexOperandHashVecType getStableIndexOperandHashes(const StableFunctionMap::StableFunctionEntry *FuncEntry)
static SmallVector< const StableFunctionMap::StableFunctionEntry * > getStableFunctionEntries(const StableFunctionMap &SFM)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
reference emplace_back(ArgTypes &&... Args)
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.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
std::pair< IndexPair, stable_hash > IndexPairHash
void sort(IteratorTy Start, IteratorTy End)
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
uintptr_t alignAddr(const void *Addr, Align Alignment)
Aligns Addr to Alignment bytes, rounding up.
This struct is a compact representation of a valid (non-zero power of two) alignment.
void deserialize(const unsigned char *&Ptr)
Deserialize the stable function map from a raw_ostream.
std::unique_ptr< StableFunctionMap > FunctionMap
static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap)
A static helper function to serialize the stable function map without owning the stable function map.
void deserializeYAML(yaml::Input &YIS)
Deserialize the stable function map from a YAML stream.
void serializeYAML(yaml::Output &YOS) const
Serialize the stable function map to a YAML stream.
An efficient form of StableFunction for fast look-up.
std::unique_ptr< IndexOperandHashMapType > IndexOperandHashMap
A map from an IndexPair to a stable_hash which was skipped.
const HashFuncsMapType & getFunctionMap() const
Get the HashToFuncs map for serialization.
A stable function is a function with a stable hash while tracking the locations of ignored operands a...
Adapter to write values to a stream in a particular byte order.
void write(ArrayRef< value_type > Val)
static void mapping(IO &IO, IndexPairHash &Key)
static void mapping(IO &IO, StableFunction &Func)