This is an archive of the discontinued LLVM Phabricator instance.

[llvm][CodeGen] Prevent endless loop when running the post-RA-sched pass.
Needs ReviewPublic

Authored by csstormq on Mar 9 2023, 1:35 AM.

Details

Reviewers
atrick
myhsu
Summary

Skip the stage that no functional units are required in ScoreboardHazardRecognizer::getHazardType. If not, this function will always return Hazard by default, leading to endless loop when running the post-RA-sched pass.

Originally, I defined an itinerary like this:

InstrItinData<
  IIC_MOVI,
  [
    InstrStage<1, []>,
    InstrStage<1, [FU_ALU]>
  ]>,

indicates that the second stage occupies FU_ALU for 1 cycle and that this stage starts 2 cycles from the issue point.

In our case, we also make use of the TargetInstrInfo::getInstrLatency to compute the instruction latency of a given instruction. Then, the SchedulePostRATDList::ListScheduleTopDown will never exit once it is called.

Later, I have modified this itinerary like this:

InstrItinData<
  IIC_MOVI,
  [
    InstrStage<0, [], 1>,
    InstrStage<1, [FU_ALU]>
  ]>,

Then, the SchedulePostRATDList::ListScheduleTopDown works well.

So, whether this problem described above is really a problem? Maybe it's my falult.

Diff Detail

Event Timeline

csstormq created this revision.Mar 9 2023, 1:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2023, 1:35 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
csstormq requested review of this revision.Mar 9 2023, 1:35 AM
myhsu added a reviewer: myhsu.Mar 9 2023, 9:10 AM
myhsu added a subscriber: myhsu.

I believe we also write tests for timeout bugs, for instance https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/InstCombine/phi-timeout.ll. Could you also add one?

csstormq edited the summary of this revision. (Show Details)Mar 9 2023, 10:06 PM
csstormq edited the summary of this revision. (Show Details)Mar 13 2023, 1:31 AM

Thanks, @myhsu . I'm sorry that I have no idea how to add some test case like phi-timeout.ll. For more clarity, I have updated the summary above with more information.