X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FGenericDomTreeConstruction.h;h=7c065f939256bf8fbf5aff51517a062d891db069;hb=00552e3875ee5f382db6c98286a241a7d0efe1b8;hp=7a651b188570d772a641ea153a60ea5e699e346b;hpb=00e08fcaa02286dd7da9cf9a8d158545532ab832;p=oota-llvm.git diff --git a/include/llvm/Support/GenericDomTreeConstruction.h b/include/llvm/Support/GenericDomTreeConstruction.h index 7a651b18857..7c065f93925 100644 --- a/include/llvm/Support/GenericDomTreeConstruction.h +++ b/include/llvm/Support/GenericDomTreeConstruction.h @@ -125,7 +125,7 @@ Eval(DominatorTreeBase& DT, typename GraphT::NodeType* VAncestor = DT.Vertex[VInfo.Parent]; // Process Ancestor first - if (Visited.insert(VAncestor) && VInfo.Parent >= LastLinked) { + if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) { Work.push_back(VAncestor); continue; } @@ -251,15 +251,18 @@ void Calculate(DominatorTreeBase::NodeType>& DT, // an infinite loop. typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : nullptr; - DT.DomTreeNodes[Root] = DT.RootNode = - new DomTreeNodeBase(Root, nullptr); + DT.RootNode = + (DT.DomTreeNodes[Root] = + llvm::make_unique>( + Root, nullptr)).get(); // Loop over all of the reachable blocks in the function... for (unsigned i = 2; i <= N; ++i) { typename GraphT::NodeType* W = DT.Vertex[i]; - DomTreeNodeBase *BBNode = DT.DomTreeNodes[W]; - if (BBNode) continue; // Haven't calculated this node yet? + // Don't replace this with 'count', the insertion side effect is important + if (DT.DomTreeNodes[W]) + continue; // Haven't calculated this node yet? typename GraphT::NodeType* ImmDom = DT.getIDom(W); @@ -271,15 +274,16 @@ void Calculate(DominatorTreeBase::NodeType>& DT, // Add a new tree node for this BasicBlock, and link it as a child of // IDomNode - DomTreeNodeBase *C = - new DomTreeNodeBase(W, IDomNode); - DT.DomTreeNodes[W] = IDomNode->addChild(C); + DT.DomTreeNodes[W] = IDomNode->addChild( + llvm::make_unique>( + W, IDomNode)); } // Free temporary memory used to construct idom's DT.IDoms.clear(); DT.Info.clear(); - std::vector().swap(DT.Vertex); + DT.Vertex.clear(); + DT.Vertex.shrink_to_fit(); DT.updateDFSNumbers(); }