[PATCH] D33769: [SelectionDAG] Get rid of recursion in CalcNodeSethiUllmanNumber
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 20:21:43 PDT 2017
reames added a comment.
Argument accepted, minor comment below.
================
Comment at: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp:1864
CalcNodeSethiUllmanNumber(const SUnit *SU, std::vector<unsigned> &SUNumbers) {
- unsigned &SethiUllmanNumber = SUNumbers[SU->NodeNum];
- if (SethiUllmanNumber != 0)
- return SethiUllmanNumber;
-
- unsigned Extra = 0;
- for (const SDep &Pred : SU->Preds) {
- if (Pred.isCtrl()) continue; // ignore chain preds
- SUnit *PredSU = Pred.getSUnit();
- unsigned PredSethiUllman = CalcNodeSethiUllmanNumber(PredSU, SUNumbers);
- if (PredSethiUllman > SethiUllmanNumber) {
- SethiUllmanNumber = PredSethiUllman;
- Extra = 0;
- } else if (PredSethiUllman == SethiUllmanNumber)
- ++Extra;
- }
+ if (SUNumbers[SU->NodeNum] == 0) {
+ // Use WorkList to avoid stack overflow on excessively large IRs.
----------------
Reduce nesting by inverting conditional or using impl helper pattern.
https://reviews.llvm.org/D33769
More information about the llvm-commits
mailing list