Add --output-format option for the llvm-profdata show command to select the type of output. The existing --text flag is used to emit text encoded profiles. To avoid confusion, --output-format=text-encoding indicates that the output will be profiles encoded in the text format, and --output-format=text indicates the default text output that doesn't necessarily represent a profile.
--output-format=json is an alias for --json and --output-format=yaml will be used in D134770.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
60 | Should this be OutputFormat instead? Then you can use a different name for the variable... |
- the CommandLine documentation file needs to be updated.
- what is the use case of splitting text and text-encoding?
- Please also add test cases.
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
2742 | fix typo "test-encoding' |
The existing --text option for the show command is used to emit the profile in the text-encoded format. I thought it would be confusing use --output-format=text to mean this, since I would expect this to mean "print normal text output". So I decided on the following flags:
- --output-format=text
- The show command will print text that is useful to the user
- --output-format=text-encoding
- Will emit the profile in the text-encoded format without additional output. This is identical to the --text flag.
I know this is a bit weird. So I'm wondering if it's better to leave the --text flag alone and only have --output-format=<json|yaml>. Let me know what you think!
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
60 | I thought the name OutputFormat would be confusing because one might think it had the meaning of ProfileFormat above. ProfileFormat specifies which profile format we should output, while ShowOutputFormat only specifies the output for the show command. We don't currently have YAML or JSON profile formats. |
I decided to just stick with --output-format=<json|yaml> and removed changes to the --text option to make things cleaner.
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
60 | OutputFormat is indeed confusing. Before you make show output format selectable, output format has one to one mapping with profile format, so output format and profile format were interchangeable.. And we have this line: cl::opt<ProfileFormat> OutputFormat We tried to hold an invariant -- all file outputs are valid profile, non-profile output are all for stdout (users can redirect to file). Can we try to hold that invariant still? Can we disambiguate them by variable names as well as switch name? i.e. --show-format for show command, and --output-format for merge command. If you separate them in difference space, --show-format=text and --output-format=text could also co-exist if needed. |
Should this be OutputFormat instead? Then you can use a different name for the variable...