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 473fa35bfeec..3d324d91f10f 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(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(ProfileKind & InstrProfKind::IRInstrumentation)) Header.Version |= VARIANT_MASK_IR_PROF; if (static_cast(ProfileKind & InstrProfKind::ContextSensitive)) @@ -435,7 +432,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) { if (static_cast(ProfileKind & InstrProfKind::MemProf)) Header.Version |= VARIANT_MASK_MEMPROF; if (static_cast(ProfileKind & InstrProfKind::TemporalProfile)) - Header.Version |= VARIANT_MASK_TEMPORAL_PROF; + return make_error(instrprof_error::invalid_prof); Header.Unused = 0; Header.HashType = static_cast(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,19 +579,6 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) { OS.writeByte(0); } - uint64_t TemporalProfTracesSectionStart = 0; - if (static_cast(ProfileKind & InstrProfKind::TemporalProfile)) { - TemporalProfTracesSectionStart = OS.tell(); - OS.write(TemporalProfTraces.size()); - OS.write(TemporalProfTraceStreamSize); - for (auto &Trace : TemporalProfTraces) { - OS.write(Trace.Weight); - OS.write(Trace.FunctionNameRefs.size()); - for (auto &NameRef : Trace.FunctionNameRefs) - OS.write(NameRef); - } - } - // Allocate space for data to be serialized out. std::unique_ptr TheSummary = IndexedInstrProf::allocSummary(SummarySize); @@ -625,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(TheSummary.get()), (int)(SummarySize / sizeof(uint64_t))},