[PATCH] D103951: [NFC][Scheduler] Refactor tryCandidate to return boolean

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 9 03:07:26 PDT 2021


qiucf created this revision.
qiucf added reviewers: PowerPC, foad, fhahn, evandro, arsenm, rampitec, dmgreen, nemanjai, jsji.
Herald added subscribers: ecnelises, steven.zhang, javed.absar, kbarton, hiraditya, MatzeB.
qiucf requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

This patch changes return type of `tryCandidate` from `void` to `bool`. Because:

- Method in some targets already follows this convention. (`SIMachineScheduler`)
- This will help if some target wants to re-use generic code. (see PowerPC change part)
- This looks more intuitive - //why `tryLess/tryGreater` returns bool while `tryCandidate` returns nothing//?

Here all branches simply return true if they got compared. We may change this logic further: return true only if `TopCand.Reason` is set (not `NoCand` anymore), so that we can:

  if (tryCandidate(Cand, TopCand, nullptr)) {
    Cand.setBest(TopCand);
    // ...
  }

Any comments are welcome. Thanks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103951

Files:
  llvm/include/llvm/CodeGen/MachineScheduler.h
  llvm/lib/CodeGen/MachineScheduler.cpp
  llvm/lib/Target/PowerPC/PPCMachineScheduler.cpp
  llvm/lib/Target/PowerPC/PPCMachineScheduler.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103951.350836.patch
Type: text/x-patch
Size: 15694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210609/6209384a/attachment.bin>


More information about the llvm-commits mailing list