This is an archive of the discontinued LLVM Phabricator instance.

[llvm-mca][RISCV] vsetivli and vsetvli act as instruments
ClosedPublic

Authored by michaelmaitland on Jul 5 2023, 10:14 AM.

Details

Summary

Since the LMUL data that is needed to create an instrument is
avaliable statically from vsetivli and vsetvli instructions,
LMUL instruments can be automatically generated so that clients
of the tool do no need to manually insert instrument comments.

Instrument comments may be placed after a vset{i}vli instruction,
which will override instrument that was automatically inserted.
As a result, clients of llvm-mca instruments do not need to update
their existing instrument comments. However, if the instrument
has the same LMUL as the vset{i}vli, then it is reccomended to
remove the instrument comment as it becomes redundant.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 10:14 AM
michaelmaitland requested review of this revision.Jul 5 2023, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 10:14 AM
andreadb added inline comments.Jul 5 2023, 1:25 PM
llvm/tools/llvm-mca/CodeRegionGenerator.h
121–127

Have you considered different approaches? Regions are already available from the base class. We don't need two references to the same data.

131

You can remove this comment.

135

Please remove this.

myhsu added inline comments.Jul 5 2023, 1:41 PM
llvm/include/llvm/MCA/CustomBehaviour.h
166

I feel like the comment here (and maybe that of createInstrument(StringRef,StringRef)) can hint that there are two ways to create Instruments -- by string description + data or from MCInst

llvm/tools/llvm-mca/CodeRegionGenerator.h
135

please remove this or put into LLVM_DEBUG

136

we can use Instruments returned earlier rather than create a new one

michaelmaitland marked 4 inline comments as done.
  • Avoid duplicate store of CodeRegions and InstrumentRegions in InstrumentMCStreamer
  • Remove errs()
  • Remove duplicate call to createInstruments
michaelmaitland added inline comments.Jul 5 2023, 2:09 PM
llvm/include/llvm/MCA/CustomBehaviour.h
166

I've added this hint on both functions.

llvm/tools/llvm-mca/CodeRegionGenerator.h
121–127

I've updated this to avoid duplicate reference.

michaelmaitland marked an inline comment as done.Jul 5 2023, 2:10 PM

Use virtual functions to avoid downcast

  • Revert Regions pointer back to Regions reference

Much better thanks!

Patch looks good to me. If @myhsu is also happy with it, then feel free to commit it.

myhsu accepted this revision.Jul 6 2023, 3:01 PM

LGTM thanks!

This revision is now accepted and ready to land.Jul 6 2023, 3:01 PM