Skip to content

Commit 9dcc2eb

Browse files
Do not use zlib compression when it isn't available.
1 parent 96011d7 commit 9dcc2eb

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
@@ -1901,13 +1901,17 @@ struct DIEDataWriter : public DataWriter {
19011901
/// is described by some DIEAbbrevRef block.
19021902
struct DistinctDataWriter : public DataWriter {
19031903
Expected<DIEDistinctDataRef> getCASNode(MCCASBuilder &CASBuilder) {
1904+
#if LLVM_ENABLE_ZLIB
19041905
SmallVector<uint8_t> CompressedBuff;
19051906
compression::zlib::compress(arrayRefFromStringRef(toStringRef(Data)),
19061907
CompressedBuff);
19071908
// Reserve 8 bytes for ULEB to store the size of the uncompressed data.
19081909
CompressedBuff.append(8, 0);
19091910
encodeULEB128(Data.size(), CompressedBuff.end() - 8, 8 /*Pad to*/);
19101911
return DIEDistinctDataRef::create(CASBuilder, toStringRef(CompressedBuff));
1912+
#else
1913+
return DIEDistinctDataRef::create(CASBuilder, toStringRef(Data));
1914+
#endif
19111915
}
19121916
};
19131917

@@ -3404,16 +3408,19 @@ Error mccasformats::v1::visitDebugInfo(
34043408
return LoadedTopRef.takeError();
34053409

34063410
StringRef DistinctData = LoadedTopRef->DistinctData.getData();
3411+
#if LLVM_ENABLE_ZLIB
34073412
ArrayRef<uint8_t> BuffRef = arrayRefFromStringRef(DistinctData);
34083413
auto UncompressedSize = decodeULEB128(BuffRef.data() + BuffRef.size() - 8);
34093414
BuffRef = BuffRef.drop_back(8);
34103415
SmallVector<uint8_t> OutBuff;
34113416
if (auto E =
34123417
compression::zlib::decompress(BuffRef, OutBuff, UncompressedSize))
34133418
return E;
3414-
auto UncompressedDistinctData = toStringRef(OutBuff);
3415-
BinaryStreamReader DistinctReader(UncompressedDistinctData,
3416-
endianness::little);
3419+
DistinctData = toStringRef(OutBuff);
3420+
BinaryStreamReader DistinctReader(DistinctData, endianness::little);
3421+
#else
3422+
BinaryStreamReader DistinctReader(DistinctData, endianness::little);
3423+
#endif
34173424
ArrayRef<char> HeaderData;
34183425

34193426
auto BeginOffset = DistinctReader.getOffset();
@@ -3435,15 +3442,9 @@ Error mccasformats::v1::visitDebugInfo(
34353442
HeaderCallback(toStringRef(HeaderData));
34363443

34373444
append_range(TotAbbrevEntries, LoadedTopRef->AbbrevEntries);
3438-
DIEVisitor Visitor{DwarfVersion,
3439-
{},
3440-
TotAbbrevEntries,
3441-
DistinctReader,
3442-
UncompressedDistinctData,
3443-
HeaderCallback,
3444-
StartTagCallback,
3445-
AttrCallback,
3446-
EndTagCallback,
3445+
DIEVisitor Visitor{DwarfVersion, {}, TotAbbrevEntries,
3446+
DistinctReader, DistinctData, HeaderCallback,
3447+
StartTagCallback, AttrCallback, EndTagCallback,
34473448
NewBlockCallback};
34483449
return Visitor.visitDIERef(LoadedTopRef->RootDIE);
34493450
}

0 commit comments

Comments
 (0)