This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Add DomTreeUpdater constructor from DT* and PDT*
ClosedPublic

Authored by NutshellySima on Jul 4 2018, 2:22 AM.

Details

Summary

Previously, if a function accepts an optional DT pointer,

void Foo (.., DominatorTree * DT = nullptr) {
  ...
  if(DT)
    DomTreeUpdater(*DT, ...).insertEdge(A, B);
  if(DT){
    DomTreeUpdater DTU(*DT, ...);
    ... // Construct the update vector and applyUpdates
  }
  ...
  if(DT){
    DomTreeUpdater DTU(*DT, ...);
    ... // Construct the update vector and applyUpdates
  }
}

After this patch, it can be simplified as

void Foo (.., DominatorTree * DT = nullptr) {
  DomTreeUpdater DTU(DT, ...);
  ...
  DTU.insertEdge(A, B);
  if(DT){
    ... // Construct the update vector and applyUpdates
  }
  ...
  if(DT){
    ... // Construct the update vector and applyUpdates
  }
}

Diff Detail

Event Timeline

NutshellySima created this revision.Jul 4 2018, 2:22 AM
kuhar accepted this revision.Jul 4 2018, 10:51 AM

LGTM. Should make life easier.

This revision is now accepted and ready to land.Jul 4 2018, 10:51 AM
This revision was automatically updated to reflect the committed changes.