[PATCH] D107536: [BitcodeAnalyzer] allow a motivated user to dump BLOCKINFO
William Woodruff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 4 22:15:39 PDT 2021
woodruffw created this revision.
woodruffw added a reviewer: pcc.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware, hiraditya.
woodruffw requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107536
Files:
llvm/include/llvm/Bitcode/BitcodeAnalyzer.h
llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Index: llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
===================================================================
--- llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -41,6 +41,10 @@
static cl::opt<bool> Dump("dump", cl::desc("Dump low level bitcode trace"));
+static cl::opt<bool> DumpBlockinfo("dump-blockinfo",
+ cl::desc("Include BLOCKINFO details in low"
+ " level dump"));
+
//===----------------------------------------------------------------------===//
// Bitcode specific analysis.
//===----------------------------------------------------------------------===//
@@ -101,6 +105,7 @@
O.Histogram = !NoHistogram;
O.Symbolic = !NonSymbolic;
O.ShowBinaryBlobs = ShowBinaryBlobs;
+ O.DumpBlockinfo = DumpBlockinfo;
ExitOnErr(BA.analyze(
Dump ? Optional<BCDumpOptions>(O) : Optional<BCDumpOptions>(None),
Index: llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
@@ -744,8 +744,8 @@
// BLOCKINFO is a special part of the stream.
bool DumpRecords = O.hasValue();
if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
- if (O)
- O->OS << Indent << "<BLOCKINFO_BLOCK/>\n";
+ if (O && !O->DumpBlockinfo)
+ O->OS << Indent << "<BLOCKINFO_BLOCK \n";
Expected<Optional<BitstreamBlockInfo>> MaybeNewBlockInfo =
Stream.ReadBlockInfoBlock(/*ReadBlockInfoNames=*/true);
if (!MaybeNewBlockInfo)
@@ -758,8 +758,8 @@
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;
Index: llvm/include/llvm/Bitcode/BitcodeAnalyzer.h
===================================================================
--- llvm/include/llvm/Bitcode/BitcodeAnalyzer.h
+++ llvm/include/llvm/Bitcode/BitcodeAnalyzer.h
@@ -42,6 +42,8 @@
bool Symbolic = false;
/// Print binary blobs using hex escapes.
bool ShowBinaryBlobs = false;
+ /// Print BLOCKINFO block details.
+ bool DumpBlockinfo = false;
BCDumpOptions(raw_ostream &OS) : OS(OS) {}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107536.364346.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/c55220f0/attachment.bin>
More information about the llvm-commits
mailing list