llvm.org GIT mirror llvm / 1745e24
[Dominators] Improve reachability verification Summary: This patch improves verification by making `verifyReachablility` look for CFG not found in the DomTree. It also makes the verification work with postdominators by handling virtual root. Reviewers: dberlin, davide, grosser, sanjoy Reviewed By: dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35279 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307936 91177308-0d34-0410-b5e6-96231b3b80d8 Jakub Kuderski 3 years ago
2 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
442442 const_cast(B));
443443 }
444444
445 bool isVirtualRoot(const DomTreeNodeBase *A) const {
446 return isPostDominator() && !A->getBlock();
447 }
448
445449 //===--------------------------------------------------------------------===//
446450 // API to update (Post)DominatorTree information based on modifications to
447451 // the CFG...
297297 for (auto &NodeToTN : DT.DomTreeNodes) {
298298 const TreeNodePtr TN = NodeToTN.second.get();
299299 const NodePtr BB = TN->getBlock();
300 if (!BB) continue;
300
301 // Virtual root has a corresponding virtual CFG node.
302 if (DT.isVirtualRoot(TN)) continue;
301303
302304 if (NodeToInfo.count(BB) == 0) {
303305 errs() << "DomTree node ";
304306 PrintBlockOrNullptr(errs(), BB);
305307 errs() << " not found by DFS walk!\n";
308 errs().flush();
309
310 return false;
311 }
312 }
313
314 for (const NodePtr N : NumToNode) {
315 if (N && !DT.getNode(N)) {
316 errs() << "CFG node ";
317 PrintBlockOrNullptr(errs(), N);
318 errs() << " not found in the DomTree!\n";
306319 errs().flush();
307320
308321 return false;
362375 assert(ToTN);
363376
364377 const NodePtr NCD = DT.findNearestCommonDominator(From, To);
365 const TreeNodePtr NCDTN = NCD ? DT.getNode(NCD) : nullptr;
378 const TreeNodePtr NCDTN = DT.getNode(NCD);
366379 const TreeNodePtr ToIDom = ToTN->getIDom();
367380 if (NCDTN != ToTN && NCDTN != ToIDom) {
368381 errs() << "NearestCommonDominator verification failed:\n\tNCD(From:";