From 4b6eb0e63c698094db5506763df44cc83c19f643 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 20 Mar 2022 12:40:34 +0100 Subject: Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks (cherry picked from commit 349cc55c9796c4596a5b9904cd3281af295f878f) --- .../llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 62 +++++++++------------- 1 file changed, 26 insertions(+), 36 deletions(-) (limited to 'contrib/llvm-project/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp') diff --git a/contrib/llvm-project/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/contrib/llvm-project/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index f577d3886e01..2723105b092f 100644 --- a/contrib/llvm-project/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/contrib/llvm-project/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -529,10 +529,9 @@ Error BitcodeAnalyzer::decodeMetadataStringsBlob(StringRef Indent, if (R.AtEndOfStream()) return reportError("bad length"); - Expected MaybeSize = R.ReadVBR(6); - if (!MaybeSize) - return MaybeSize.takeError(); - uint32_t Size = MaybeSize.get(); + uint32_t Size; + if (Error E = R.ReadVBR(6).moveInto(Size)) + return E; if (Strings.size() < Size) return reportError("truncated chars"); @@ -555,11 +554,8 @@ BitcodeAnalyzer::BitcodeAnalyzer(StringRef Buffer, Error BitcodeAnalyzer::analyze(Optional O, Optional CheckHash) { - Expected MaybeType = analyzeHeader(O, Stream); - if (!MaybeType) - return MaybeType.takeError(); - else - CurStreamType = *MaybeType; + if (Error E = analyzeHeader(O, Stream).moveInto(CurStreamType)) + return E; Stream.setBlockInfo(&BlockInfo); @@ -567,9 +563,8 @@ Error BitcodeAnalyzer::analyze(Optional O, // The block info must be a top-level block. if (BlockInfoStream) { BitstreamCursor BlockInfoCursor(*BlockInfoStream); - Expected H = analyzeHeader(O, BlockInfoCursor); - if (!H) - return H.takeError(); + if (Error E = analyzeHeader(O, BlockInfoCursor).takeError()) + return E; while (!BlockInfoCursor.AtEndOfStream()) { Expected MaybeCode = BlockInfoCursor.ReadCode(); @@ -582,12 +577,11 @@ Error BitcodeAnalyzer::analyze(Optional O, if (!MaybeBlockID) return MaybeBlockID.takeError(); if (MaybeBlockID.get() == bitc::BLOCKINFO_BLOCK_ID) { - Expected> MaybeNewBlockInfo = - BlockInfoCursor.ReadBlockInfoBlock(/*ReadBlockInfoNames=*/true); - if (!MaybeNewBlockInfo) - return MaybeNewBlockInfo.takeError(); - Optional NewBlockInfo = - std::move(MaybeNewBlockInfo.get()); + Optional NewBlockInfo; + if (Error E = + BlockInfoCursor.ReadBlockInfoBlock(/*ReadBlockInfoNames=*/true) + .moveInto(NewBlockInfo)) + return E; if (!NewBlockInfo) return reportError("Malformed BlockInfoBlock in block info file"); BlockInfo = std::move(*NewBlockInfo); @@ -744,22 +738,20 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, // BLOCKINFO is a special part of the stream. bool DumpRecords = O.hasValue(); if (BlockID == bitc::BLOCKINFO_BLOCK_ID) { - if (O) + if (O && !O->DumpBlockinfo) O->OS << Indent << "\n"; - Expected> MaybeNewBlockInfo = - Stream.ReadBlockInfoBlock(/*ReadBlockInfoNames=*/true); - if (!MaybeNewBlockInfo) - return MaybeNewBlockInfo.takeError(); - Optional NewBlockInfo = - std::move(MaybeNewBlockInfo.get()); + Optional NewBlockInfo; + if (Error E = Stream.ReadBlockInfoBlock(/*ReadBlockInfoNames=*/true) + .moveInto(NewBlockInfo)) + return E; if (!NewBlockInfo) return reportError("Malformed BlockInfoBlock"); BlockInfo = std::move(*NewBlockInfo); if (Error Err = Stream.JumpToBit(BlockBitStart)) return Err; // It's not really interesting to dump the contents of the blockinfo - // block. - DumpRecords = false; + // block, so only do it if the user explicitly requests it. + DumpRecords = O && O->DumpBlockinfo; } unsigned NumWords = 0; @@ -796,11 +788,10 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, uint64_t RecordStartBit = Stream.GetCurrentBitNo(); - Expected MaybeEntry = - Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs); - if (!MaybeEntry) - return MaybeEntry.takeError(); - BitstreamEntry Entry = MaybeEntry.get(); + BitstreamEntry Entry; + if (Error E = Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs) + .moveInto(Entry)) + return E; switch (Entry.Kind) { case BitstreamEntry::Error: @@ -847,10 +838,9 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, StringRef Blob; uint64_t CurrentRecordPos = Stream.GetCurrentBitNo(); - Expected MaybeCode = Stream.readRecord(Entry.ID, Record, &Blob); - if (!MaybeCode) - return MaybeCode.takeError(); - unsigned Code = MaybeCode.get(); + unsigned Code; + if (Error E = Stream.readRecord(Entry.ID, Record, &Blob).moveInto(Code)) + return E; // Increment the # occurrences of this code. if (BlockStats.CodeFreq.size() <= Code) -- cgit v1.2.3