llvm.org GIT mirror llvm / 1bd3f5a
[SelectionDAG] CreateTopologicalOrder - don't use iterator We shouldn't use an iterator to loop across a std::vector when the same loop is adding elements to that std::vector Found by cppcheck git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359900 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 4 months ago
1 changed file(s) with 6 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
82388238 }
82398239 }
82408240
8241
8242 void SelectionDAG::CreateTopologicalOrder(std::vector*>& Order) {
8241 void SelectionDAG::CreateTopologicalOrder(std::vector *> &Order) {
82438242 DenseMap Degree;
82448243 Order.reserve(AllNodes.size());
8245 for (auto & N : allnodes()) {
8244 for (auto &N : allnodes()) {
82468245 unsigned NOps = N.getNumOperands();
82478246 Degree[&N] = NOps;
82488247 if (0 == NOps)
82498248 Order.push_back(&N);
82508249 }
8251 for (std::vector::iterator I = Order.begin();
8252 I!=Order.end();++I) {
8253 SDNode * N = *I;
8250 for (size_t I = 0; I != Order.size(); ++I) {
8251 SDNode *N = Order[I];
82548252 for (auto U : N->uses()) {
82558253 unsigned &UnsortedOps = Degree[U];
82568254 if (0 == --UnsortedOps)
82608258 }
82618259
82628260 #ifndef NDEBUG
8263 void SelectionDAG::VerifyDAGDiverence()
8264 {
8265 std::vector TopoOrder;
8261 void SelectionDAG::VerifyDAGDiverence() {
8262 std::vector TopoOrder;
82668263 CreateTopologicalOrder(TopoOrder);
82678264 const TargetLowering &TLI = getTargetLoweringInfo();
82688265 DenseMap DivergenceMap;
82878284 }
82888285 }
82898286 #endif
8290
82918287
82928288 /// ReplaceAllUsesOfValuesWith - Replace any uses of From with To, leaving
82938289 /// uses of other values produced by From.getNode() alone. The same value