[llvm-mca][JSON] Teach the PipelinePrinter how to deal with anonymous code regions...
authorAndrea Di Biagio <andrea.dibiagio@sony.com>
Sat, 10 Jul 2021 12:50:29 +0000 (13:50 +0100)
committerAndrea Di Biagio <andrea.dibiagio@sony.com>
Sat, 10 Jul 2021 12:57:52 +0000 (13:57 +0100)
commit4fe0fcd1c032091f60cabc70ee72a3b0f529a875
tree163109f5deba3409dcc0187ad0481fab2d873e7a
parentd919bca87556548555af0a7aa1239ea64ba4f3e8
[llvm-mca][JSON] Teach the PipelinePrinter how to deal with anonymous code regions (PR51008)

This patch addresses the last remaining problems reported in PR51008.

Previous fixes for PR51008 worked under the wrong assumption that code regions
are always named (except maybe for the default region, which was automatically
named "main").

In reality, it is quite common for users to declare multiple anonymous regions.
So we cannot really use the region name as the key string of a JSON object.  In
practice, code region names are completely optional.

Using "main" for the default region was also problematic because there can be
another region with that same name.

This patch fixes these issues by introducing a json::array of regions.  Each
region has a "Name" field, which would default to the empty string for anonymous
regions.

Added a few more tests to verify that the JSON file format is still valid, and
that multiple anonymous regions all appear in the final output.
llvm/test/tools/llvm-mca/JSON/X86/instruction-tables-multiple-anonymous-regions.s [new file with mode: 0644]
llvm/test/tools/llvm-mca/JSON/X86/instruction-tables-multiple-regions.s
llvm/test/tools/llvm-mca/JSON/X86/views-multiple-anonymous-regions.s [new file with mode: 0644]
llvm/test/tools/llvm-mca/JSON/X86/views-multiple-region.s
llvm/test/tools/llvm-mca/JSON/X86/views.s
llvm/tools/llvm-mca/PipelinePrinter.cpp