@@ -893,52 +893,22 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
893
893
}
894
894
InfoObj->CSSummaryBuilder = nullptr ;
895
895
896
- const size_t MemProfOffset = BackPatchStartOffset + sizeof (uint64_t );
897
- const size_t BinaryIdOffset = MemProfOffset + sizeof (uint64_t );
898
- const size_t TemporalProfTracesOffset = BinaryIdOffset + sizeof (uint64_t );
899
- const size_t VTableNamesOffset = TemporalProfTracesOffset + sizeof (uint64_t );
900
- if (!WritePrevVersion) {
901
- // Now do the final patch:
902
- PatchItem PatchItems[] = {
903
- // Patch the Header.HashOffset field.
904
- {BackPatchStartOffset, &HashTableStart, 1 },
905
- // Patch the Header.MemProfOffset (=0 for profiles without MemProf
906
- // data).
907
- {MemProfOffset, &MemProfSectionStart, 1 },
908
- // Patch the Header.BinaryIdSectionOffset.
909
- {BinaryIdOffset, &BinaryIdSectionStart, 1 },
910
- // Patch the Header.TemporalProfTracesOffset (=0 for profiles without
911
- // traces).
912
- {TemporalProfTracesOffset, &TemporalProfTracesSectionStart, 1 },
913
- {VTableNamesOffset, &VTableNamesSectionStart, 1 },
914
- // Patch the summary data.
915
- {SummaryOffset, reinterpret_cast <uint64_t *>(TheSummary.get ()),
916
- (int )(SummarySize / sizeof (uint64_t ))},
917
- {CSSummaryOffset, reinterpret_cast <uint64_t *>(TheCSSummary.get ()),
918
- (int )CSSummarySize}};
919
-
920
- OS.patch (PatchItems);
921
- } else {
922
- // Now do the final patch:
923
- PatchItem PatchItems[] = {
924
- // Patch the Header.HashOffset field.
925
- {BackPatchStartOffset, &HashTableStart, 1 },
926
- // Patch the Header.MemProfOffset (=0 for profiles without MemProf
927
- // data).
928
- {MemProfOffset, &MemProfSectionStart, 1 },
929
- // Patch the Header.BinaryIdSectionOffset.
930
- {BinaryIdOffset, &BinaryIdSectionStart, 1 },
931
- // Patch the Header.TemporalProfTracesOffset (=0 for profiles without
932
- // traces).
933
- {TemporalProfTracesOffset, &TemporalProfTracesSectionStart, 1 },
934
- // Patch the summary data.
935
- {SummaryOffset, reinterpret_cast <uint64_t *>(TheSummary.get ()),
936
- (int )(SummarySize / sizeof (uint64_t ))},
937
- {CSSummaryOffset, reinterpret_cast <uint64_t *>(TheCSSummary.get ()),
938
- (int )CSSummarySize}};
939
-
940
- OS.patch (PatchItems);
941
- }
896
+ SmallVector<uint64_t , 8 > HeaderOffsets = {HashTableStart, MemProfSectionStart,
897
+ BinaryIdSectionStart,
898
+ TemporalProfTracesSectionStart};
899
+ if (!WritePrevVersion)
900
+ HeaderOffsets.push_back (VTableNamesSectionStart);
901
+
902
+ PatchItem PatchItems[] = {
903
+ // Patch the Header fields
904
+ {BackPatchStartOffset, HeaderOffsets.data (), (int )HeaderOffsets.size ()},
905
+ // Patch the summary data.
906
+ {SummaryOffset, reinterpret_cast <uint64_t *>(TheSummary.get ()),
907
+ (int )(SummarySize / sizeof (uint64_t ))},
908
+ {CSSummaryOffset, reinterpret_cast <uint64_t *>(TheCSSummary.get ()),
909
+ (int )CSSummarySize}};
910
+
911
+ OS.patch (PatchItems);
942
912
943
913
for (const auto &I : FunctionData)
944
914
for (const auto &F : I.getValue ())
0 commit comments