From e7fc254875ca9e82b899d5354fae9b5b779ff485 Mon Sep 17 00:00:00 2001 From: william woodruff Date: Sun, 10 Oct 2021 09:40:22 +0530 Subject: [BitcodeAnalyzer] allow a motivated user to dump BLOCKINFO This adds the `--dump-blockinfo` flag to `llvm-bcanalyzer`, allowing a sufficiently motivated user to dump (parts of) the `BLOCKINFO_BLOCK` block. The default behavior is unchanged, and `--dump-blockinfo` only takes effect in the same context as other flags that control dump behavior (i.e., requires that `--dump` is also passed). Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D107536 --- llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index f577d3886e01..7777c5d9b1dc 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -744,7 +744,7 @@ 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); @@ -758,8 +758,8 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, 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; -- cgit v1.2.3