Skip to content

Commit 0f73fb1

Browse files
committed
Revert "[memprof] Extend the index prof format to include memory profiles."
This reverts commit 43c2348. Buildbots are failing with an error on reading memprof testdata. "Inputs/basic.profraw: profile uses zlib compression but the profile reader was built without zlib support" https://lab.llvm.org/buildbot/#/builders/16/builds/24490
1 parent 6291454 commit 0f73fb1

File tree

19 files changed

+35
-651
lines changed

19 files changed

+35
-651
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
650650
/* Raw profile format version (start from 1). */
651651
#define INSTR_PROF_RAW_VERSION 8
652652
/* Indexed profile format version (start from 1). */
653-
#define INSTR_PROF_INDEX_VERSION 8
653+
#define INSTR_PROF_INDEX_VERSION 7
654654
/* Coverage mapping format version (start from 0). */
655655
#define INSTR_PROF_COVMAP_VERSION 5
656656

@@ -662,7 +662,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
662662
* The 59th bit indicates whether to use debug info to correlate profiles.
663663
* The 60th bit indicates single byte coverage instrumentation.
664664
* The 61st bit indicates function entry instrumentation only.
665-
* The 62nd bit indicates whether memory profile information is present.
666665
*/
667666
#define VARIANT_MASKS_ALL 0xff00000000000000ULL
668667
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
@@ -672,7 +671,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
672671
#define VARIANT_MASK_DBG_CORRELATE (0x1ULL << 59)
673672
#define VARIANT_MASK_BYTE_COVERAGE (0x1ULL << 60)
674673
#define VARIANT_MASK_FUNCTION_ENTRY_ONLY (0x1ULL << 61)
675-
#define VARIANT_MASK_MEMPROF (0x1ULL << 62)
676674
#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
677675
#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
678676
#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ enum class InstrProfKind {
287287
CS = 0x8, // A context sensitive IR-level profile.
288288
SingleByteCoverage = 0x10, // Use single byte probes for coverage.
289289
FunctionEntryOnly = 0x20, // Only instrument the function entry basic block.
290-
MemProf = 0x40, // A memory profile collected using -fmemory-profile.
291-
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/MemProf)
290+
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/FunctionEntryOnly)
292291
};
293292

294293
const std::error_category &instrprof_category();
@@ -1012,9 +1011,7 @@ enum ProfVersion {
10121011
Version6 = 6,
10131012
// An additional counter is added around logical operators.
10141013
Version7 = 7,
1015-
// An additional (optional) memory profile type is added.
1016-
Version8 = 8,
1017-
// The current version is 8.
1014+
// The current version is 7.
10181015
CurrentVersion = INSTR_PROF_INDEX_VERSION
10191016
};
10201017
const uint64_t Version = ProfVersion::CurrentVersion;
@@ -1031,7 +1028,6 @@ struct Header {
10311028
uint64_t Unused; // Becomes unused since version 4
10321029
uint64_t HashType;
10331030
uint64_t HashOffset;
1034-
uint64_t MemProfOffset;
10351031
// New fields should only be added at the end to ensure that the size
10361032
// computation is correct. The methods below need to be updated to ensure that
10371033
// the new field is read correctly.

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
650650
/* Raw profile format version (start from 1). */
651651
#define INSTR_PROF_RAW_VERSION 8
652652
/* Indexed profile format version (start from 1). */
653-
#define INSTR_PROF_INDEX_VERSION 8
653+
#define INSTR_PROF_INDEX_VERSION 7
654654
/* Coverage mapping format version (start from 0). */
655655
#define INSTR_PROF_COVMAP_VERSION 5
656656

@@ -662,7 +662,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
662662
* The 59th bit indicates whether to use debug info to correlate profiles.
663663
* The 60th bit indicates single byte coverage instrumentation.
664664
* The 61st bit indicates function entry instrumentation only.
665-
* The 62nd bit indicates whether memory profile information is present.
666665
*/
667666
#define VARIANT_MASKS_ALL 0xff00000000000000ULL
668667
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
@@ -672,7 +671,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
672671
#define VARIANT_MASK_DBG_CORRELATE (0x1ULL << 59)
673672
#define VARIANT_MASK_BYTE_COVERAGE (0x1ULL << 60)
674673
#define VARIANT_MASK_FUNCTION_ENTRY_ONLY (0x1ULL << 61)
675-
#define VARIANT_MASK_MEMPROF (0x1ULL << 62)
676674
#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
677675
#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
678676
#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias

llvm/include/llvm/ProfileData/InstrProfReader.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/IR/ProfileSummary.h"
2020
#include "llvm/ProfileData/InstrProf.h"
2121
#include "llvm/ProfileData/InstrProfCorrelator.h"
22-
#include "llvm/ProfileData/MemProf.h"
2322
#include "llvm/Support/Endian.h"
2423
#include "llvm/Support/Error.h"
2524
#include "llvm/Support/LineIterator.h"
@@ -472,9 +471,6 @@ struct InstrProfReaderIndexBase {
472471
using OnDiskHashTableImplV3 =
473472
OnDiskIterableChainedHashTable<InstrProfLookupTrait>;
474473

475-
using MemProfHashTable =
476-
OnDiskIterableChainedHashTable<memprof::MemProfRecordLookupTrait>;
477-
478474
template <typename HashTableImpl>
479475
class InstrProfReaderItaniumRemapper;
480476

@@ -560,11 +556,6 @@ class IndexedInstrProfReader : public InstrProfReader {
560556
std::unique_ptr<ProfileSummary> Summary;
561557
/// Context sensitive profile summary data.
562558
std::unique_ptr<ProfileSummary> CS_Summary;
563-
/// MemProf profile schema (if available).
564-
memprof::MemProfSchema Schema;
565-
/// MemProf profile data on-disk indexed via llvm::md5(FunctionName).
566-
std::unique_ptr<MemProfHashTable> MemProfTable;
567-
568559
// Index to the current record in the record array.
569560
unsigned RecordIndex;
570561

@@ -618,11 +609,6 @@ class IndexedInstrProfReader : public InstrProfReader {
618609
Expected<InstrProfRecord> getInstrProfRecord(StringRef FuncName,
619610
uint64_t FuncHash);
620611

621-
/// Return the memprof records for the function identified by
622-
/// llvm::md5(Name).
623-
Expected<ArrayRef<memprof::MemProfRecord>>
624-
getMemProfRecord(uint64_t FuncNameHash);
625-
626612
/// Fill Counts with the profile data for the given function name.
627613
Error getFunctionCounts(StringRef FuncName, uint64_t FuncHash,
628614
std::vector<uint64_t> &Counts);

llvm/include/llvm/ProfileData/InstrProfWriter.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "llvm/ADT/DenseMap.h"
1818
#include "llvm/ADT/StringMap.h"
1919
#include "llvm/ProfileData/InstrProf.h"
20-
#include "llvm/ProfileData/MemProf.h"
2120
#include "llvm/Support/Endian.h"
2221
#include "llvm/Support/Error.h"
2322
#include "llvm/Support/MemoryBuffer.h"
@@ -38,11 +37,6 @@ class InstrProfWriter {
3837
private:
3938
bool Sparse;
4039
StringMap<ProfilingData> FunctionData;
41-
42-
// A map to hold memprof data per function. The lower 64 bits obtained from
43-
// the md5 hash of the function name is used to index into the map.
44-
memprof::FunctionMemProfMap MemProfData;
45-
4640
// An enum describing the attributes of the profile.
4741
InstrProfKind ProfileKind = InstrProfKind::Unknown;
4842
// Use raw pointer here for the incomplete type object.
@@ -63,9 +57,6 @@ class InstrProfWriter {
6357
addRecord(std::move(I), 1, Warn);
6458
}
6559

66-
void addRecord(const ::llvm::memprof::MemProfRecord &MR,
67-
function_ref<void(Error)> Warn);
68-
6960
/// Merge existing function counts from the given writer.
7061
void mergeRecordsFromWriter(InstrProfWriter &&IPW,
7162
function_ref<void(Error)> Warn);
@@ -121,8 +112,6 @@ class InstrProfWriter {
121112
return Error::success();
122113
}
123114

124-
InstrProfKind getProfileKind() const { return ProfileKind; }
125-
126115
// Internal interface for testing purpose only.
127116
void setValueProfDataEndianness(support::endianness Endianness);
128117
void setOutputSparse(bool Sparse);

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 6 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <string>
66
#include <vector>
77

8-
#include "llvm/ADT/DenseMap.h"
98
#include "llvm/ADT/SmallVector.h"
109
#include "llvm/ProfileData/MemProfData.inc"
1110
#include "llvm/ProfileData/ProfileCommon.h"
@@ -135,65 +134,25 @@ struct PortableMemInfoBlock {
135134
};
136135

137136
struct MemProfRecord {
138-
// Describes a call frame for a dynamic allocation context. The contents of
139-
// the frame are populated by symbolizing the stack depot call frame from the
140-
// compiler runtime.
141-
PACKED(struct Frame {
142-
// A uuid (uint64_t) identifying the function. It is obtained by
143-
// llvm::md5(FunctionName) which returns the lower 64 bits.
144-
GlobalValue::GUID Function;
145-
// The source line offset of the call from the beginning of parent function.
137+
struct Frame {
138+
std::string Function;
146139
uint32_t LineOffset;
147-
// The source column number of the call to help distinguish multiple calls
148-
// on the same line.
149140
uint32_t Column;
150-
// Whether the current frame is inlined.
151141
bool IsInlineFrame;
152142

153-
Frame(uint64_t Hash, uint32_t Off, uint32_t Col, bool Inline)
154-
: Function(Hash), LineOffset(Off), Column(Col), IsInlineFrame(Inline) {}
143+
Frame(std::string Str, uint32_t Off, uint32_t Col, bool Inline)
144+
: Function(std::move(Str)), LineOffset(Off), Column(Col),
145+
IsInlineFrame(Inline) {}
146+
};
155147

156-
bool operator==(const Frame &Other) const {
157-
return Other.Function == Function && Other.LineOffset == LineOffset &&
158-
Other.Column == Column && Other.IsInlineFrame == IsInlineFrame;
159-
}
160-
161-
bool operator!=(const Frame &Other) const { return !operator==(Other); }
162-
163-
// Write the contents of the frame to the ostream \p OS.
164-
void write(raw_ostream & OS) const {
165-
using namespace support;
166-
167-
endian::Writer LE(OS, little);
168-
169-
// If the type of the GlobalValue::GUID changes, then we need to update
170-
// the reader and the writer.
171-
static_assert(std::is_same<GlobalValue::GUID, uint64_t>::value,
172-
"Expect GUID to be uint64_t.");
173-
LE.write<uint64_t>(Function);
174-
175-
LE.write<uint32_t>(LineOffset);
176-
LE.write<uint32_t>(Column);
177-
LE.write<bool>(IsInlineFrame);
178-
}
179-
});
180-
181-
// The dynamic calling context for the allocation.
182148
std::vector<Frame> CallStack;
183-
// The statistics obtained from the runtime for the allocation.
184149
PortableMemInfoBlock Info;
185150

186151
void clear() {
187152
CallStack.clear();
188153
Info.clear();
189154
}
190155

191-
size_t serializedSize() const {
192-
return sizeof(uint64_t) + // The number of frames to serialize.
193-
sizeof(Frame) * CallStack.size() + // The contents of the frames.
194-
PortableMemInfoBlock::serializedSize(); // The size of the payload.
195-
}
196-
197156
// Prints out the contents of the memprof record in YAML.
198157
void print(llvm::raw_ostream &OS) const {
199158
OS << " Callstack:\n";
@@ -209,138 +168,6 @@ struct MemProfRecord {
209168

210169
Info.printYAML(OS);
211170
}
212-
213-
bool operator==(const MemProfRecord &Other) const {
214-
if (Other.Info != Info)
215-
return false;
216-
217-
if (Other.CallStack.size() != CallStack.size())
218-
return false;
219-
220-
for (size_t I = 0; I < Other.CallStack.size(); I++) {
221-
if (Other.CallStack[I] != CallStack[I])
222-
return false;
223-
}
224-
return true;
225-
}
226-
};
227-
228-
// Serializes the memprof records in \p Records to the ostream \p OS based on
229-
// the schema provided in \p Schema.
230-
void serializeRecords(const ArrayRef<MemProfRecord> Records,
231-
const MemProfSchema &Schema, raw_ostream &OS);
232-
233-
// Deserializes memprof records from the Buffer
234-
SmallVector<MemProfRecord, 4> deserializeRecords(const MemProfSchema &Schema,
235-
const unsigned char *Buffer);
236-
237-
// Reads a memprof schema from a buffer. All entries in the buffer are
238-
// interpreted as uint64_t. The first entry in the buffer denotes the number of
239-
// ids in the schema. Subsequent entries are integers which map to memprof::Meta
240-
// enum class entries. After successfully reading the schema, the pointer is one
241-
// byte past the schema contents.
242-
Expected<MemProfSchema> readMemProfSchema(const unsigned char *&Buffer);
243-
244-
using FunctionMemProfMap =
245-
DenseMap<uint64_t, SmallVector<memprof::MemProfRecord, 4>>;
246-
247-
/// Trait for lookups into the on-disk hash table for memprof format in the
248-
/// indexed profile.
249-
class MemProfRecordLookupTrait {
250-
public:
251-
using data_type = ArrayRef<MemProfRecord>;
252-
using internal_key_type = uint64_t;
253-
using external_key_type = uint64_t;
254-
using hash_value_type = uint64_t;
255-
using offset_type = uint64_t;
256-
257-
MemProfRecordLookupTrait() = delete;
258-
MemProfRecordLookupTrait(const MemProfSchema &S) : Schema(S) {}
259-
260-
static bool EqualKey(uint64_t A, uint64_t B) { return A == B; }
261-
static uint64_t GetInternalKey(uint64_t K) { return K; }
262-
static uint64_t GetExternalKey(uint64_t K) { return K; }
263-
264-
hash_value_type ComputeHash(uint64_t K) { return K; }
265-
266-
static std::pair<offset_type, offset_type>
267-
ReadKeyDataLength(const unsigned char *&D) {
268-
using namespace support;
269-
270-
offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
271-
offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
272-
return std::make_pair(KeyLen, DataLen);
273-
}
274-
275-
uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
276-
using namespace support;
277-
return endian::readNext<external_key_type, little, unaligned>(D);
278-
}
279-
280-
data_type ReadData(uint64_t K, const unsigned char *D,
281-
offset_type /*Unused*/) {
282-
Records = deserializeRecords(Schema, D);
283-
return Records;
284-
}
285-
286-
private:
287-
// Holds the memprof schema used to deserialize records.
288-
MemProfSchema Schema;
289-
// Holds the records from one function deserialized from the indexed format.
290-
llvm::SmallVector<MemProfRecord, 4> Records;
291-
};
292-
293-
class MemProfRecordWriterTrait {
294-
public:
295-
using key_type = uint64_t;
296-
using key_type_ref = uint64_t;
297-
298-
using data_type = ArrayRef<MemProfRecord>;
299-
using data_type_ref = ArrayRef<MemProfRecord>;
300-
301-
using hash_value_type = uint64_t;
302-
using offset_type = uint64_t;
303-
304-
// Pointer to the memprof schema to use for the generator. Unlike the reader
305-
// we must use a default constructor with no params for the writer trait so we
306-
// have a public member which must be initialized by the user.
307-
MemProfSchema *Schema = nullptr;
308-
309-
MemProfRecordWriterTrait() = default;
310-
311-
static hash_value_type ComputeHash(key_type_ref K) { return K; }
312-
313-
static std::pair<offset_type, offset_type>
314-
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
315-
using namespace support;
316-
317-
endian::Writer LE(Out, little);
318-
319-
offset_type N = sizeof(K);
320-
LE.write<offset_type>(N);
321-
322-
offset_type M = 0;
323-
324-
M += sizeof(uint64_t);
325-
for (const auto &Record : V) {
326-
M += Record.serializedSize();
327-
}
328-
329-
LE.write<offset_type>(M);
330-
return std::make_pair(N, M);
331-
}
332-
333-
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
334-
using namespace support;
335-
endian::Writer LE(Out, little);
336-
LE.write<uint64_t>(K);
337-
}
338-
339-
void EmitData(raw_ostream &Out, key_type_ref /*Unused*/, data_type_ref V,
340-
offset_type /*Unused*/) {
341-
assert(Schema != nullptr && "MemProf schema is not initialized!");
342-
serializeRecords(V, *Schema, Out);
343-
}
344171
};
345172

346173
} // namespace memprof

llvm/include/llvm/ProfileData/MemProfData.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef MEMPROF_DATA_INC
2-
#define MEMPROF_DATA_INC
1+
#ifndef LLVM_PROFILEDATA_MEMPROFDATA_INC
2+
#define LLVM_PROFILEDATA_MEMPROFDATA_INC
33
/*===-- MemProfData.inc - MemProf profiling runtime structures -*- C++ -*-=== *\
44
|*
55
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

llvm/include/llvm/ProfileData/RawMemProfReader.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class RawMemProfReader {
6666
return Iterator(this);
6767
}
6868

69-
// The RawMemProfReader only holds memory profile information.
70-
InstrProfKind getProfileKind() const { return InstrProfKind::MemProf; }
71-
7269
// Constructor for unittests only.
7370
RawMemProfReader(std::unique_ptr<llvm::symbolize::SymbolizableModule> Sym,
7471
llvm::SmallVectorImpl<SegmentEntry> &Seg,

0 commit comments

Comments
 (0)