This is an archive of the discontinued LLVM Phabricator instance.

[MIScheduler] Print top/down cycle in the SUnit dump.
ClosedPublic

Authored by fpetrogalli on Jan 9 2023, 8:07 AM.

Details

Summary

Add an extra command line option to llc that allows checking at what cycle an instruction has been scheduled by the machine scheduler.

Diff Detail

Event Timeline

fpetrogalli created this revision.Jan 9 2023, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 8:07 AM
fpetrogalli requested review of this revision.Jan 9 2023, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 8:07 AM
fpetrogalli edited the summary of this revision. (Show Details)Jan 9 2023, 8:08 AM
fhahn added inline comments.Jan 10 2023, 9:34 AM
llvm/test/CodeGen/AArch64/sched-print-cycle.mir
19

Should this not check for the expected cycles?

fpetrogalli marked an inline comment as done.Jan 10 2023, 1:07 PM
fpetrogalli added inline comments.
llvm/test/CodeGen/AArch64/sched-print-cycle.mir
19

I could, but what I am really interested in checking is the fact that we get 2 extra numbers with the option, not their values (for now). The scheduler tests will take care of checking the actual values. Is it OK if I live it as it is?

fpetrogalli marked an inline comment as done.Jan 10 2023, 1:56 PM
fpetrogalli added inline comments.
llvm/test/CodeGen/AArch64/sched-print-cycle.mir
19

To be more precise, I do not want to check for specific value because I do not want to bother updating the test in case they change. All I care is that the two extra numbers are there when -sched-print-cycles=true

fhahn added inline comments.Jan 12 2023, 4:33 AM
llvm/lib/CodeGen/ScheduleDAG.cpp
366 ↗(On Diff #487446)

Hmm, is there a reason for including it in the name and not including them among the attributes (SUnit::dumpAttributes)? There it would also be possible to print a name associated with the values.

llvm/test/CodeGen/AArch64/sched-print-cycle.mir
19

If you fix the CPU (-mcpu=xxx) to an older one, it's unlikely that the latencies for ADD will change? It seems better to check that the correct values are printed IMO , rather than matching any value.

I have specified -mcpu in the test and the resulting values printed in the SUnit dump.

fpetrogalli marked an inline comment as done.Jan 12 2023, 6:30 AM
fpetrogalli added inline comments.
llvm/test/CodeGen/AArch64/sched-print-cycle.mir
19

You win :)

fpetrogalli marked 2 inline comments as done.Jan 12 2023, 6:44 AM
fpetrogalli added inline comments.
llvm/lib/CodeGen/ScheduleDAG.cpp
366 ↗(On Diff #487446)

It is because we want the information to be printed by void ScheduleDAGMI::dumpSchedule() const, so that we can check the last bits of the debug info of the machine scheduler right after the string *** Final schedule for %bb.0 ***.

As far as I understand SUnit::dumpAttributes is printed before the scheduler does its job. We need to check the two extra values when the scheduler has finished.

fpetrogalli marked an inline comment as done.

Specify -mtriple in the invocation of llc in the test to prevent it fail on targets that do not support the cpu specified.

Matt added a subscriber: Matt.Jan 16 2023, 12:55 PM
fpetrogalli edited the summary of this revision. (Show Details)Jan 17 2023, 3:48 AM

Based on offline feedback from @fhahn, I have:

  1. moved the implementation out of dumpNodeName into ScheduleDAGInstrs::dumpNode(const SUnit &SU)
  2. printed the meaning of the values.

Update the example in the test to have non-zero values printed for both TopReadyCycle and BottomReadyCycle.

fhahn accepted this revision.Jan 17 2023, 6:51 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jan 17 2023, 6:51 AM
This revision was landed with ongoing or failed builds.Jan 17 2023, 6:56 AM
This revision was automatically updated to reflect the committed changes.