[PATCH] llvm-bcanalyzer: print percentages without scientific notation

Hello,

llvm-bcanalyzer told me that the size of the BLOCKINFO_BLOCK of my
file is "1.345017e+01" percent of the whole file. This is not very
readable.

The attached patch prints the percentage without scientific notation
so we get something bit more readable:

Block ID #0 (BLOCKINFO_BLOCK):
    Num Instances: 1
       Total Size: 637b/79.62B/19W
        % of file: 13.450169
    Num SubBlocks: 0
      Num Abbrevs: 0
      Num Records: 0

best regards,
Timo Lindfors

llvm-bcanalyzer-format-percentage1.patch (944 Bytes)

Hi,

Andreas Neustifter <astifter-llvm@gmx.at> writes:

Maybe you can use the already available "include/llvm/Support/Format.h"?

Thanks, that simplifies the patch a lot. See the attached patch.

Btw, llvm-bcanalyzer.cpp seems to also use fprintf -- does mixing it
with errs() cause problems and should it be converted to use format()?

best regards,
Timo Lindfors

llvm-bcanalyzer-format-percentage2.patch (1.39 KB)

Hi,

Andreas Neustifter <astifter-llvm@gmx.at> writes:

Maybe you can use the already available "include/llvm/Support/Format.h"?

Thanks, that simplifies the patch a lot. See the attached patch.

It looks like something similar got applied back in r82772 on 9/25.

Btw, llvm-bcanalyzer.cpp seems to also use fprintf -- does mixing it
with errs() cause problems and should it be converted to use format()?

It would be nice to switch everything to use errs().

-Chris

Chris Lattner <clattner@apple.com> writes:

It looks like something similar got applied back in r82772 on 9/25.

Aha, great. I did not realize llvm was moving _that_ fast and was
still working with r82620.

It would be nice to switch everything to use errs().

There seem to be several hundred references to *printf in
llvm. Unfortunately I don't feel confident enough in the codebase to
start rewriting all those just yet :wink: