Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0e5f4b

Browse files
Merge pull request swiftlang#7938 from rastogishubham/zlibstuffstable
Cherry-pick PR swiftlang#7929 into stable/20230725
2 parents 8cc8bcb + 57740eb commit a0e5f4b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

llvm/lib/MCCAS/MCCASObjectV1.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,13 +1894,17 @@ struct DIEDataWriter : public DataWriter {
18941894
/// is described by some DIEAbbrevRef block.
18951895
struct DistinctDataWriter : public DataWriter {
18961896
Expected<DIEDistinctDataRef> getCASNode(MCCASBuilder &CASBuilder) {
1897+
#if LLVM_ENABLE_ZLIB
18971898
SmallVector<uint8_t> CompressedBuff;
18981899
compression::zlib::compress(arrayRefFromStringRef(toStringRef(Data)),
18991900
CompressedBuff);
19001901
// Reserve 8 bytes for ULEB to store the size of the uncompressed data.
19011902
CompressedBuff.append(8, 0);
19021903
encodeULEB128(Data.size(), CompressedBuff.end() - 8, 8 /*Pad to*/);
19031904
return DIEDistinctDataRef::create(CASBuilder, toStringRef(CompressedBuff));
1905+
#else
1906+
return DIEDistinctDataRef::create(CASBuilder, toStringRef(Data));
1907+
#endif
19041908
}
19051909
};
19061910

@@ -3392,16 +3396,19 @@ Error mccasformats::v1::visitDebugInfo(
33923396
return LoadedTopRef.takeError();
33933397

33943398
StringRef DistinctData = LoadedTopRef->DistinctData.getData();
3399+
#if LLVM_ENABLE_ZLIB
33953400
ArrayRef<uint8_t> BuffRef = arrayRefFromStringRef(DistinctData);
33963401
auto UncompressedSize = decodeULEB128(BuffRef.data() + BuffRef.size() - 8);
33973402
BuffRef = BuffRef.drop_back(8);
33983403
SmallVector<uint8_t> OutBuff;
33993404
if (auto E =
34003405
compression::zlib::decompress(BuffRef, OutBuff, UncompressedSize))
34013406
return E;
3402-
auto UncompressedDistinctData = toStringRef(OutBuff);
3403-
BinaryStreamReader DistinctReader(UncompressedDistinctData,
3404-
support::endianness::little);
3407+
DistinctData = toStringRef(OutBuff);
3408+
BinaryStreamReader DistinctReader(DistinctData, support::endianness::little);
3409+
#else
3410+
BinaryStreamReader DistinctReader(DistinctData, support::endianness::little);
3411+
#endif
34053412
ArrayRef<char> HeaderData;
34063413

34073414
auto BeginOffset = DistinctReader.getOffset();
@@ -3423,15 +3430,9 @@ Error mccasformats::v1::visitDebugInfo(
34233430
HeaderCallback(toStringRef(HeaderData));
34243431

34253432
append_range(TotAbbrevEntries, LoadedTopRef->AbbrevEntries);
3426-
DIEVisitor Visitor{DwarfVersion,
3427-
{},
3428-
TotAbbrevEntries,
3429-
DistinctReader,
3430-
UncompressedDistinctData,
3431-
HeaderCallback,
3432-
StartTagCallback,
3433-
AttrCallback,
3434-
EndTagCallback,
3433+
DIEVisitor Visitor{DwarfVersion, {}, TotAbbrevEntries,
3434+
DistinctReader, DistinctData, HeaderCallback,
3435+
StartTagCallback, AttrCallback, EndTagCallback,
34353436
NewBlockCallback};
34363437
return Visitor.visitDIERef(LoadedTopRef->RootDIE);
34373438
}

0 commit comments

Comments
 (0)