This is an archive of the discontinued LLVM Phabricator instance.

[llvm-mca] Fix JSON output for multiple regions
ClosedPublic

Authored by markoshorro on Jul 8 2021, 2:30 AM.

Details

Summary

Instead of printing each region individually when using JSON format, this patch creates a JSON object which is updated with the values of each region and prints at the end.
This patch also adds a new test considering 2 nested regions.

Diff Detail

Event Timeline

markoshorro requested review of this revision.Jul 8 2021, 2:30 AM
markoshorro created this revision.

This patch also adds a new test considering 2 nested regions.

Hi,

I only see changes to Views.s. Did you forget to upload the new test?

Forgot to update the patch with the new test.

andreadb added inline comments.Jul 8 2021, 6:12 AM
llvm/test/tools/llvm-mca/JSON/X86/views-multiple-region.s
54–73

It is unfortunate how "Resources" is now duplicated for every code region.

I understand that we get this point because "Resources" is contributed by a view (so, it is printed once per code region).

Ideally, there should be only one top-level instance.

Do you know if there is an easy way to avoid duplicating "Resources"?
In retrospect, the idea of printing that info from a view only makes sense if there is a single code region.

andreadb added inline comments.Jul 8 2021, 6:39 AM
llvm/tools/llvm-mca/llvm-mca.cpp
601

remove tab.

675–683

Add braces for this then block.

681

remove tab.

markoshorro marked 3 inline comments as done.

"Resources" is now at top-level in the output. I have specialized a bit the InstructionView for printing only once the "Resources" key at top level even when having multiple regions.

I have some doubts about the coding style when having

if (condition) {
     stmt;
     stmt;
} else
      stmtelse;

I have put braces surrounding else stmtelse, but I am not sure if that is correct...

andreadb accepted this revision.Jul 9 2021, 8:49 AM

LGTM

"Resources" is now at top-level in the output. I have specialized a bit the InstructionView for printing only once the "Resources" key at top level even when having multiple regions.

I have some doubts about the coding style when having

if (condition) {
     stmt;
     stmt;
} else
      stmtelse;

I have put braces surrounding else stmtelse, but I am not sure if that is correct...

That's fine. Thanks!

This revision is now accepted and ready to land.Jul 9 2021, 8:49 AM
This revision was landed with ongoing or failed builds.Jul 9 2021, 9:09 AM
This revision was automatically updated to reflect the committed changes.