[PATCH] D107536: [BitcodeAnalyzer] allow a motivated user to dump BLOCKINFO

William Woodruff via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 9 14:17:01 PDT 2021


woodruffw added inline comments.


================
Comment at: llvm/test/tools/llvm-bcanalyzer/dump-blockinfo.test:1
+# RUN: llvm-stress | llvm-as - | llvm-bcanalyzer --dump --dump-blockinfo | FileCheck %s
+
----------------
tejohnson wrote:
> woodruffw wrote:
> > mehdi_amini wrote:
> > > tejohnson wrote:
> > > > woodruffw wrote:
> > > > > N.B.: Please let me know if using `llvm-stress` like this isn't advisable; I can check in a test input instead if that's preferred.
> > > > Can you make this a small .ll test instead (see examples in other test directories) and just run it through opt to get a bitcode and then run llvm-bcanalyzer on that?
> > > > 
> > > > And then is it possible to check some of the expected contents of the blockinfo section?
> > > What Theresa suggests makes sense to me.
> > Done!
> Generally we avoid using bitcode directly as a test input, because the format can change. What I would suggest is to llvm-dis that bitcode into a .ll file. Then just make that the test file with the command and tests in it. I.e. rather than a .test extension like this, have something like a llvm/test/tools/llvm-bcanalyzer/dump-blockinfo.ll test that contains your llvm-dis'ed bitcode file, then add commands in it like:
> 
> ; RUN: llvm-as < %s | llvm-bcanalyzer --dump --dump-blockinfo | FileCheck %s
> 
> ; CHECK: ...
Unfortunately, I think we need the direct bitcode input here: LLVM's bitcode writer is allowed to make arbitrary abbreviation decisions in the `BLOCKINFO_BLOCK`, so round-tripping through the textual form isn't guaranteed to produce the same records in `BLOCKINFO_BLOCK` (or even a `BLOCKINFO_BLOCK` at all). 

(Separately, the test input I'm using here isn't valid LLVM IR, since it's just a bitstream fragment. I copied it from `llvm/test/Other/Inputs` per @xgupta's example, where it was already separately checked in.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107536/new/

https://reviews.llvm.org/D107536



More information about the llvm-commits mailing list