diff options
author | Qiu Chaofan <qiucofan@cn.ibm.com> | 2020-01-12 13:10:04 +0800 |
---|---|---|
committer | Qiu Chaofan <qiucofan@cn.ibm.com> | 2020-01-12 13:10:04 +0800 |
commit | f33fd43a7c91f1774a9512bbdb78c367cd23d233 (patch) | |
tree | 8d6c373b09ba4e20d8b4303591a6208b385abec5 /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | d692f0f6c8c12316d559b9a638a2cb9fbd0c263d (diff) | |
download | llvm-f33fd43a7c91f1774a9512bbdb78c367cd23d233.zip llvm-f33fd43a7c91f1774a9512bbdb78c367cd23d233.tar.gz llvm-f33fd43a7c91f1774a9512bbdb78c367cd23d233.tar.bz2 |
[NFC] Refactor memory ops cluster method
Current implementation of BaseMemOpsClusterMutation is a little bit
obscure. This patch directly uses a map from store chain ID to set of
memory instrs to make it simpler, so that future improvements are easier
to read, update and review.
Reviewed By: evandro
Differential Revision: https://reviews.llvm.org/D72070
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 52855ce..a148a89 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -1598,10 +1598,8 @@ void BaseMemOpClusterMutation::clusterNeighboringMemOps( /// Callback from DAG postProcessing to create cluster edges for loads. void BaseMemOpClusterMutation::apply(ScheduleDAGInstrs *DAG) { - // Map DAG NodeNum to store chain ID. - DenseMap<unsigned, unsigned> StoreChainIDs; - // Map each store chain to a set of dependent MemOps. - SmallVector<SmallVector<SUnit*,4>, 32> StoreChainDependents; + // Map DAG NodeNum to a set of dependent MemOps in store chain. + DenseMap<unsigned, SmallVector<SUnit *, 4>> StoreChains; for (SUnit &SU : DAG->SUnits) { if ((IsLoad && !SU.getInstr()->mayLoad()) || (!IsLoad && !SU.getInstr()->mayStore())) @@ -1614,19 +1612,14 @@ void BaseMemOpClusterMutation::apply(ScheduleDAGInstrs *DAG) { break; } } - // Check if this chain-like pred has been seen - // before. ChainPredID==MaxNodeID at the top of the schedule. - unsigned NumChains = StoreChainDependents.size(); - std::pair<DenseMap<unsigned, unsigned>::iterator, bool> Result = - StoreChainIDs.insert(std::make_pair(ChainPredID, NumChains)); - if (Result.second) - StoreChainDependents.resize(NumChains + 1); - StoreChainDependents[Result.first->second].push_back(&SU); + // Insert the SU to corresponding store chain. + auto &Chain = StoreChains.FindAndConstruct(ChainPredID).second; + Chain.push_back(&SU); } // Iterate over the store chains. - for (auto &SCD : StoreChainDependents) - clusterNeighboringMemOps(SCD, DAG); + for (auto &SCD : StoreChains) + clusterNeighboringMemOps(SCD.second, DAG); } //===----------------------------------------------------------------------===// |