Index: include/llvm/CodeGen/ScheduleDAG.h =================================================================== --- include/llvm/CodeGen/ScheduleDAG.h +++ include/llvm/CodeGen/ScheduleDAG.h @@ -738,6 +738,11 @@ /// current node \p M. void RemovePred(SUnit *M, SUnit *N); + /// Maps SUnits to indexes of a topological ordering. + /// The index is between 0 and SUnits.count()-1. + /// Boundary SUnits are not mapped. + int getSUTopoIndex(SUnit &SU); + typedef std::vector::iterator iterator; typedef std::vector::const_iterator const_iterator; iterator begin() { return Index2Node.begin(); } Index: lib/CodeGen/ScheduleDAG.cpp =================================================================== --- lib/CodeGen/ScheduleDAG.cpp +++ lib/CodeGen/ScheduleDAG.cpp @@ -682,6 +682,12 @@ return HasLoop; } +int ScheduleDAGTopologicalSort::getNodeTopoIndex(SUnit &SU) +{ + assert(!SU.isBoundaryNode()); + return Node2Index[SU.NodeNum]; +} + void ScheduleDAGTopologicalSort::Allocate(int n, int index) { Node2Index[n] = index; Index2Node[index] = n;