diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2020-06-24 10:32:55 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2020-07-06 21:58:11 +0200 |
commit | f987ba3cf9af1a2fa168c5a707863b28efd61d73 (patch) | |
tree | c3bf11176ba8fda189a886125891fbd4bf66349c /llvm | |
parent | dfcc68c528269a3e0b1cbe7ef22cc92cdfdf7eba (diff) | |
download | llvm-f987ba3cf9af1a2fa168c5a707863b28efd61d73.zip llvm-f987ba3cf9af1a2fa168c5a707863b28efd61d73.tar.gz llvm-f987ba3cf9af1a2fa168c5a707863b28efd61d73.tar.bz2 |
DomTree: add private create{Child,Node} helpers
Summary:
Aside from unifying the code a bit, this change smooths the
transition to use of future "opaque generic block references"
in the type-erased dominator tree base class.
Change-Id: If924b092cc8561c4b6a7450fe79bc96df0e12472
Reviewers: arsenm, RKSimon, mehdi_amini, courbet
Subscribers: wdng, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83086
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Support/GenericDomTree.h | 18 | ||||
-rw-r--r-- | llvm/include/llvm/Support/GenericDomTreeConstruction.h | 16 |
2 files changed, 18 insertions, 16 deletions
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 407a060..10e591a 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -590,8 +590,7 @@ protected: DomTreeNodeBase<NodeT> *IDomNode = getNode(DomBB); assert(IDomNode && "Not immediate dominator specified for block!"); DFSInfoValid = false; - return (DomTreeNodes[BB] = IDomNode->addChild( - std::make_unique<DomTreeNodeBase<NodeT>>(BB, IDomNode))).get(); + return createChild(BB, IDomNode); } /// Add a new node to the forward dominator tree and make it a new root. @@ -604,8 +603,7 @@ protected: assert(!this->isPostDominator() && "Cannot change root of post-dominator tree"); DFSInfoValid = false; - DomTreeNodeBase<NodeT> *NewNode = (DomTreeNodes[BB] = - std::make_unique<DomTreeNodeBase<NodeT>>(BB, nullptr)).get(); + DomTreeNodeBase<NodeT> *NewNode = createNode(BB); if (Roots.empty()) { addRoot(BB); } else { @@ -786,6 +784,18 @@ public: protected: void addRoot(NodeT *BB) { this->Roots.push_back(BB); } + DomTreeNodeBase<NodeT> *createChild(NodeT *BB, DomTreeNodeBase<NodeT> *IDom) { + return (DomTreeNodes[BB] = IDom->addChild( + std::make_unique<DomTreeNodeBase<NodeT>>(BB, IDom))) + .get(); + } + + DomTreeNodeBase<NodeT> *createNode(NodeT *BB) { + return (DomTreeNodes[BB] = + std::make_unique<DomTreeNodeBase<NodeT>>(BB, nullptr)) + .get(); + } + // NewBB is split and now it has one successor. Update dominator tree to // reflect this change. template <class N> diff --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/llvm/include/llvm/Support/GenericDomTreeConstruction.h index bde59ff..464de4e 100644 --- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h +++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h @@ -187,9 +187,7 @@ struct SemiNCAInfo { // Add a new tree node for this NodeT, and link it as a child of // IDomNode - return (DT.DomTreeNodes[BB] = IDomNode->addChild( - std::make_unique<DomTreeNodeBase<NodeT>>(BB, IDomNode))) - .get(); + return DT.createChild(BB, IDomNode); } static bool AlwaysDescend(NodePtr, NodePtr) { return true; } @@ -587,9 +585,7 @@ struct SemiNCAInfo { // all real exits (including multiple exit blocks, infinite loops). NodePtr Root = IsPostDom ? nullptr : DT.Roots[0]; - DT.RootNode = (DT.DomTreeNodes[Root] = - std::make_unique<DomTreeNodeBase<NodeT>>(Root, nullptr)) - .get(); + DT.RootNode = DT.createNode(Root); SNCA.attachNewSubtree(DT, DT.RootNode); } @@ -610,8 +606,7 @@ struct SemiNCAInfo { // Add a new tree node for this BasicBlock, and link it as a child of // IDomNode. - DT.DomTreeNodes[W] = IDomNode->addChild( - std::make_unique<DomTreeNodeBase<NodeT>>(W, IDomNode)); + DT.createChild(W, IDomNode); } } @@ -661,10 +656,7 @@ struct SemiNCAInfo { // The unreachable node becomes a new root -- a tree node for it. TreeNodePtr VirtualRoot = DT.getNode(nullptr); - FromTN = - (DT.DomTreeNodes[From] = VirtualRoot->addChild( - std::make_unique<DomTreeNodeBase<NodeT>>(From, VirtualRoot))) - .get(); + FromTN = DT.createChild(From, VirtualRoot); DT.Roots.push_back(From); } |