Bug 1827533 - Partially revert recent clang trunk profdata changes. r=firefox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D175197
This commit is contained in:
Mike Hommey 2023-04-14 08:25:53 +00:00
Родитель 9ba02d6644
Коммит fab8f1730b
3 изменённых файлов: 183 добавлений и 1 удалений

Просмотреть файл

@ -5,8 +5,9 @@
"unpoison-thread-stacks_clang_10.patch",
"downgrade-mangling-error_clang_12.patch",
"fuzzing_ccov_build_clang_12.patch",
"partial-revert-llvmorg-17-init-7686-g244be0b0de19.patch",
"revert-llvmorg-17-init-4120-g02e8eb1a438b.patch",
"partial-revert-llvmorg-16-init-15775-g1ae7d83803e4.patch",
"partial-revert-llvmorg-16-init-15775-g1ae7d83803e4_clang_17.patch",
"revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_17.patch",
"revert-llvmorg-16-init-9324-g01859da84bad_clang_17.patch",
"revert-llvmorg-16-init-7598-g54bfd0484615.patch",

Просмотреть файл

@ -0,0 +1,106 @@
The change in https://github.com/llvm/llvm-project/commit/1ae7d83803e45f6053ec6a606f259653846926b8
makes rustc unable to read the profiles that `llvm-profdata merge` outputs,
further causing some problems (e.g. bug 1811960).
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index af3c27ebac76..a6da1e0f3aec 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -291,10 +291,6 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
for (auto &Func : I.getValue())
addRecord(I.getKey(), Func.first, std::move(Func.second), 1, Warn);
- BinaryIds.reserve(BinaryIds.size() + IPW.BinaryIds.size());
- for (auto &I : IPW.BinaryIds)
- addBinaryIds(I);
-
MemProfFrameData.reserve(IPW.MemProfFrameData.size());
for (auto &I : IPW.MemProfFrameData) {
// If we weren't able to add the frame mappings then it doesn't make sense
@@ -339,7 +335,6 @@ static void setSummary(IndexedInstrProf::Summary *TheSummary,
Error InstrProfWriter::writeImpl(ProfOStream &OS) {
using namespace IndexedInstrProf;
- using namespace support;
OnDiskChainedHashTableGenerator<InstrProfRecordWriterTrait> Generator;
@@ -356,7 +351,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// Write the header.
IndexedInstrProf::Header Header;
Header.Magic = IndexedInstrProf::Magic;
- Header.Version = IndexedInstrProf::ProfVersion::Version9;
+ Header.Version = IndexedInstrProf::ProfVersion::Version8;
if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
Header.Version |= VARIANT_MASK_IR_PROF;
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
@@ -396,12 +389,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// profile contains memory profile information.
OS.write(0);
- // Save the location of binary ids section.
- uint64_t BinaryIdSectionOffset = OS.tell();
- // Reserve space for the BinaryIdOffset field to be patched later if this
- // profile contains binary ids.
- OS.write(0);
-
// Reserve space to write profile summary data.
uint32_t NumEntries = ProfileSummaryBuilder::DefaultCutoffs.size();
uint32_t SummarySize = Summary::getSize(Summary::NumKinds, NumEntries);
@@ -478,43 +465,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
OS.patch(PatchItems, 3);
}
- // BinaryIdSection has two parts:
- // 1. uint64_t BinaryIdsSectionSize
- // 2. list of binary ids that consist of:
- // a. uint64_t BinaryIdLength
- // b. uint8_t BinaryIdData
- // c. uint8_t Padding (if necessary)
- uint64_t BinaryIdSectionStart = OS.tell();
- // Calculate size of binary section.
- uint64_t BinaryIdsSectionSize = 0;
-
- // Remove duplicate binary ids.
- llvm::sort(BinaryIds);
- BinaryIds.erase(std::unique(BinaryIds.begin(), BinaryIds.end()),
- BinaryIds.end());
-
- for (auto BI : BinaryIds) {
- // Increment by binary id length data type size.
- BinaryIdsSectionSize += sizeof(uint64_t);
- // Increment by binary id data length, aligned to 8 bytes.
- BinaryIdsSectionSize += alignToPowerOf2(BI.size(), sizeof(uint64_t));
- }
- // Write binary ids section size.
- OS.write(BinaryIdsSectionSize);
-
- for (auto BI : BinaryIds) {
- uint64_t BILen = BI.size();
- // Write binary id length.
- OS.write(BILen);
- // Write binary id data.
- for (unsigned K = 0; K < BILen; K++)
- OS.writeByte(BI[K]);
- // Write padding if necessary.
- uint64_t PaddingSize = alignToPowerOf2(BILen, sizeof(uint64_t)) - BILen;
- for (unsigned K = 0; K < PaddingSize; K++)
- OS.writeByte(0);
- }
-
// Allocate space for data to be serialized out.
std::unique_ptr<IndexedInstrProf::Summary> TheSummary =
IndexedInstrProf::allocSummary(SummarySize);
@@ -537,11 +487,8 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
PatchItem PatchItems[] = {
// Patch the Header.HashOffset field.
{HashTableStartFieldOffset, &HashTableStart, 1},
- // Patch the Header.MemProfOffset (=0 for profiles without MemProf
- // data).
+ // Patch the Header.MemProfOffset (=0 for profiles without MemProf data).
{MemProfSectionOffset, &MemProfSectionStart, 1},
- // Patch the Header.BinaryIdSectionOffset.
- {BinaryIdSectionOffset, &BinaryIdSectionStart, 1},
// Patch the summary data.
{SummaryOffset, reinterpret_cast<uint64_t *>(TheSummary.get()),
(int)(SummarySize / sizeof(uint64_t))},

Просмотреть файл

@ -0,0 +1,75 @@
Revert profdata changes from https://github.com/llvm/llvm-project/commit/244be0b0de198fbe8a0861bb8f75509f610b57a4
that make rustc unable to read the profiles that `llvm-profdata merge`
outputs, further causing some problems (e.g. bug 1811960).
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index e181228adb63..fe1e9b1bd50e 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -356,9 +356,6 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
for (auto &I : IPW.BinaryIds)
addBinaryIds(I);
- addTemporalProfileTraces(std::move(IPW.TemporalProfTraces),
- IPW.TemporalProfTraceStreamSize);
-
MemProfFrameData.reserve(IPW.MemProfFrameData.size());
for (auto &I : IPW.MemProfFrameData) {
// If we weren't able to add the frame mappings then it doesn't make sense
@@ -420,7 +417,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// Write the header.
IndexedInstrProf::Header Header;
Header.Magic = IndexedInstrProf::Magic;
- Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion;
+ Header.Version = IndexedInstrProf::ProfVersion::Version9;
if (static_cast<bool>(ProfileKind & InstrProfKind::IRInstrumentation))
Header.Version |= VARIANT_MASK_IR_PROF;
if (static_cast<bool>(ProfileKind & InstrProfKind::ContextSensitive))
@@ -435,7 +432,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
if (static_cast<bool>(ProfileKind & InstrProfKind::MemProf))
Header.Version |= VARIANT_MASK_MEMPROF;
if (static_cast<bool>(ProfileKind & InstrProfKind::TemporalProfile))
- Header.Version |= VARIANT_MASK_TEMPORAL_PROF;
+ return make_error<InstrProfError>(instrprof_error::invalid_prof);
Header.Unused = 0;
Header.HashType = static_cast<uint64_t>(IndexedInstrProf::HashType);
@@ -469,9 +466,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// profile contains binary ids.
OS.write(0);
- uint64_t TemporalProfTracesOffset = OS.tell();
- OS.write(0);
-
// Reserve space to write profile summary data.
uint32_t NumEntries = ProfileSummaryBuilder::DefaultCutoffs.size();
uint32_t SummarySize = Summary::getSize(Summary::NumKinds, NumEntries);
@@ -585,18 +579,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
OS.writeByte(0);
}
- uint64_t TemporalProfTracesSectionStart = 0;
- if (static_cast<bool>(ProfileKind & InstrProfKind::TemporalProfile)) {
- TemporalProfTracesSectionStart = OS.tell();
- OS.write(TemporalProfTraces.size());
- OS.write(TemporalProfTraceStreamSize);
- for (auto &Trace : TemporalProfTraces) {
- OS.write(Trace.size());
- for (auto &NameRef : Trace)
- OS.write(NameRef);
- }
- }
-
// Allocate space for data to be serialized out.
std::unique_ptr<IndexedInstrProf::Summary> TheSummary =
IndexedInstrProf::allocSummary(SummarySize);
@@ -624,9 +606,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
{MemProfSectionOffset, &MemProfSectionStart, 1},
// Patch the Header.BinaryIdSectionOffset.
{BinaryIdSectionOffset, &BinaryIdSectionStart, 1},
- // Patch the Header.TemporalProfTracesOffset (=0 for profiles without
- // traces).
- {TemporalProfTracesOffset, &TemporalProfTracesSectionStart, 1},
// Patch the summary data.
{SummaryOffset, reinterpret_cast<uint64_t *>(TheSummary.get()),
(int)(SummarySize / sizeof(uint64_t))},