@@ -374,32 +374,17 @@ DominatorTree &FunctionPropertiesUpdater::getUpdatedDominatorTree(
374
374
auto &DT =
375
375
FAM.getResult <DominatorTreeAnalysis>(const_cast <Function &>(Caller));
376
376
377
- SetVector<const BasicBlock *> NewSucc;
378
- NewSucc.insert (succ_begin (&CallSiteBB), succ_end (&CallSiteBB));
379
-
380
- // tell the DomTree about the new edges
381
- std::deque<const BasicBlock *> Worklist;
382
- Worklist.push_back (&CallSiteBB);
383
-
384
- // Build the list of edges to actually remove. Those are those edges in the
385
- // DomTreeUpdates that cannot be found in the CFG anymore.
386
377
SmallVector<DominatorTree::UpdateType, 2 > FinalDomTreeUpdates;
387
- while (!Worklist.empty ()) {
388
- auto *BB = Worklist.front ();
389
- Worklist.pop_front ();
390
- assert (DT.getNode (BB));
391
378
392
- for (auto *Succ : NewSucc) {
393
- if (!DT.getNode (Succ))
394
- Worklist.push_back (Succ);
379
+ for (auto &Upd : DomTreeUpdates)
380
+ FinalDomTreeUpdates.push_back (Upd);
381
+
382
+ DenseSet<const BasicBlock *> Inserted;
383
+ for (auto *Succ : successors (&CallSiteBB))
384
+ if (Inserted.insert (Succ).second )
395
385
FinalDomTreeUpdates.push_back ({DominatorTree::UpdateKind::Insert,
396
- const_cast <BasicBlock *>(BB ),
386
+ const_cast <BasicBlock *>(&CallSiteBB ),
397
387
const_cast <BasicBlock *>(Succ)});
398
- }
399
- }
400
- for (auto &Upd : DomTreeUpdates)
401
- if (!llvm::is_contained (successors (Upd.getFrom ()), Upd.getTo ()))
402
- FinalDomTreeUpdates.push_back (Upd);
403
388
404
389
DT.applyUpdates (FinalDomTreeUpdates);
405
390
#ifdef EXPENSIVE_CHECKS
0 commit comments