If dominator tree has no roots, the pass that calculates it is
likely to be skipped, it occures for instance in the case of
entities with linkage available_externally. Do not run tree
verification in such case.
Details
Diff Detail
- Build Status
Buildable 3242 Build 3242: arc lint + arc unit
Event Timeline
This seems reasonable to me, but I've added more reviews to see if they have any additional feedback.
IIRC, when I wrote the patch to add the verifyDomTree function here it was taken verbatim from the IR level dominator tree verifier. Therefore, it might be a good idea to make a similar change to the IR-level verifier.
lib/CodeGen/MachineDominators.cpp | ||
---|---|---|
147 | I'd probably drop this comment in favor of the title of this revision, "Do not verify Dominator tree if it has no root." |
IIRC, when I wrote the patch to add the verifyDomTree function here it was taken verbatim from the IR level dominator tree verifier. Therefore, it might be a good idea to make a similar change to the IR-level verifier.
This change fixes 11 test fails observer when llvm was build with LLVM_ENABLE_EXPENSIVE_CHECKS turned on. None of them occurs in IR but some time ago there were such fails. So added the respective check.
lib/CodeGen/MachineDominators.cpp | ||
---|---|---|
147 | Rephrased the comment. |
This looks, IMHO, very wrong.
We require domtrees to have roots at all times.
See getRoot, for example, which says:
NodeT *getRoot() const { assert(this->Roots.size() == 1 && "Should always have entry node!"); return this->Roots[0]; }
So if we've created a DominatorTree to call verifyDomTree on,and it doesn't have a root, we have in fact, created a broken dom tree and verification *should* fail.
I'm not sure why we are creating such a tree, but it's *definitely invalid* according to how we work right now.
All this patch does is paper over that by calling getRoots instead of getRoot, because getRoots happens to not assert (we should add a non-emptyness assert there too).
I think you need to fix the underlying problem of creating DominatorTrees without roots, or start a discussion on llvmdev about whether the empty dom tree should be valid.
(Preferably, the former).
Because so far, we've never considered "the completely empty" domtree to be valid, and we haven't audited our functions to make sure they all work properly in such a world.
I very much trust Danny's opinion. Thus, this has been reverted in r293075. I defer Danny's other comments/suggestions (i.e., fixing DT creation w/o roots or starting a discussion on LLVM Dev) to Serge.
I'd probably drop this comment in favor of the title of this revision, "Do not verify Dominator tree if it has no root."