[Scheduler][NFC] Don't use set to track visited nodes (#190480)
The visited set can grow rather large and we can use an unused field in SDNode to store the same information without the use of a hash set. This improves compile times: stage2-O3 -0.14%.
This commit is contained in:
parent
cdbb1f5014
commit
a105f27f61
@ -689,10 +689,14 @@ private:
|
||||
/// Return a pointer to the specified value type.
|
||||
LLVM_ABI static const EVT *getValueTypeList(MVT VT);
|
||||
|
||||
/// Index in worklist of DAGCombiner, or negative if the node is not in the
|
||||
/// worklist. -1 = not in worklist; -2 = not in worklist, but has already been
|
||||
/// combined at least once.
|
||||
int CombinerWorklistIndex = -1;
|
||||
union {
|
||||
/// Index in worklist of DAGCombiner, or negative if the node is not in the
|
||||
/// worklist. -1 = not in worklist; -2 = not in worklist, but has already
|
||||
/// been combined at least once.
|
||||
int CombinerWorklistIndex = -1;
|
||||
/// Visited state in ScheduleDAGSDNodes::BuildSchedUnits.
|
||||
bool SchedulerWorklistVisited;
|
||||
};
|
||||
|
||||
uint32_t CFIType = 0;
|
||||
|
||||
@ -795,6 +799,14 @@ public:
|
||||
/// Set worklist index for DAGCombiner
|
||||
void setCombinerWorklistIndex(int Index) { CombinerWorklistIndex = Index; }
|
||||
|
||||
/// Get visited state for ScheduleDAGSDNodes::BuildSchedUnits.
|
||||
bool getSchedulerWorklistVisited() const { return SchedulerWorklistVisited; }
|
||||
|
||||
/// Set visited state for ScheduleDAGSDNodes::BuildSchedUnits.
|
||||
void setSchedulerWorklistVisited(bool Visited) {
|
||||
SchedulerWorklistVisited = Visited;
|
||||
}
|
||||
|
||||
/// Return the node ordering.
|
||||
unsigned getIROrder() const { return IROrder; }
|
||||
|
||||
|
||||
@ -329,6 +329,7 @@ void ScheduleDAGSDNodes::BuildSchedUnits() {
|
||||
unsigned NumNodes = 0;
|
||||
for (SDNode &NI : DAG->allnodes()) {
|
||||
NI.setNodeId(-1);
|
||||
NI.setSchedulerWorklistVisited(false);
|
||||
++NumNodes;
|
||||
}
|
||||
|
||||
@ -343,16 +344,19 @@ void ScheduleDAGSDNodes::BuildSchedUnits() {
|
||||
SmallVector<SDNode*, 64> Worklist;
|
||||
SmallPtrSet<SDNode*, 32> Visited;
|
||||
Worklist.push_back(DAG->getRoot().getNode());
|
||||
Visited.insert(DAG->getRoot().getNode());
|
||||
DAG->getRoot().getNode()->setSchedulerWorklistVisited(true);
|
||||
|
||||
SmallVector<SUnit*, 8> CallSUnits;
|
||||
while (!Worklist.empty()) {
|
||||
SDNode *NI = Worklist.pop_back_val();
|
||||
|
||||
// Add all operands to the worklist unless they've already been added.
|
||||
for (const SDValue &Op : NI->op_values())
|
||||
if (Visited.insert(Op.getNode()).second)
|
||||
Worklist.push_back(Op.getNode());
|
||||
for (const SDValue &Op : NI->op_values()) {
|
||||
if (Op.getNode()->getSchedulerWorklistVisited())
|
||||
continue;
|
||||
Op.getNode()->setSchedulerWorklistVisited(true);
|
||||
Worklist.push_back(Op.getNode());
|
||||
}
|
||||
|
||||
if (isPassiveNode(NI)) // Leaf node, e.g. a TargetImmediate.
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user