<div dir="ltr">Well, I don't know why it's failing by just looking at it. I'll submit a fix for the LoopRotate bug in a moment and will see it unbreaks this buildbot.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 4:42 PM, Juergen Ributzka <span dir="ltr"><<a href="mailto:juergen@ributzka.de" target="_blank">juergen@ributzka.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I don't know if this is reproducible on Linux, but the file that is failing is common code in compiler-rt (<span style="color:rgb(51,51,51);font-family:monospace;font-size:14px;white-space:pre-wrap">sanitizer_libc.cc.o)</span>.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 1:32 PM, Jakub (Kuba) Kuderski <span dir="ltr"><<a href="mailto:kubakuderski@gmail.com" target="_blank">kubakuderski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Juergen,<br><br>It seems like the patch caught some invalid DominatorTrees :).<br><br>I'm now investigating a failure in LoopRotation happening in <font face="monospace, monospace">test/Transforms/ArgumentPro<wbr>motion/pr3085.ll </font><font face="arial, helvetica, sans-serif">with expensive checks enabled, but I don't know if that's related.<br>I looked and the buildbot's output and it seems to fail on OSX -- do you know if it's reproducible on x86_64 linux?<br><br>Best,<br>Jakub</font></div><div class="gmail_extra"><div><div class="m_3818168455659261539h5"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 4:26 PM, Juergen Ributzka <span dir="ltr"><<a href="mailto:juergen@ributzka.de" target="_blank">juergen@ributzka.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Jakub,<div><br></div><div>I think this broke one of our jobs on Green Dragon:</div><div><a href="http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/8568/consoleFull" target="_blank">http://green.lab.llvm.org/gree<wbr>n/job/clang-stage1-cmake-RA-ex<wbr>pensive/8568/consoleFull</a><br></div><div><br></div><div>Could you please take a look?</div><div><br></div><div>Thanks</div><div><br></div><div>Cheers,</div><div>Juergen</div></div><div class="m_3818168455659261539m_-2283884895673315123HOEnZb"><div class="m_3818168455659261539m_-2283884895673315123h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 7:33 AM, Jakub Kuderski via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kuhar<br>
Date: Tue Oct 3 07:33:41 2017<br>
New Revision: 314801<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314801&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=314801&view=rev</a><br>
Log:<br>
[Dominators] Add DFS number verification<br>
<br>
Summary:<br>
This patch teaches the DominatorTree verifier to check DFS In/Out numbers which are used to answer dominance queries.<br>
DFS number verification is done in O(nlogn), so it shouldn't add much overhead on top of the O(n^3) sibling property verification.<br>
This check should detect errors like the one spotted in PR34466 and related bug reports.<br>
<br>
The patch also cleans up the DFS calculation a bit, as all constructed trees should have a single root now.<br>
<br>
I see 2 new test failures when running check-all after this change:<br>
<br>
```<br>
Failing Tests (2):<br>
Polly :: Isl/CodeGen/OpenMP/reference-a<wbr>rgument-from-non-affine-region<wbr>.ll<br>
Polly :: Isl/CodeGen/OpenMP/two-paralle<wbr>l-loops-reference-outer-indvar<wbr>.ll<br>
<br>
```<br>
which seem to happen just after `Create LLVM-IR from SCoPs` -- I XFAILed them in r314800.<br>
<br>
Reviewers: dberlin, grosser, davide, zhendongsu, bollu<br>
<br>
Reviewed By: dberlin<br>
<br>
Subscribers: nandini12396, bollu, Meinersbur, brzycki, llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D38331" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3833<wbr>1</a><br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTree.h<br>
llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTreeConstruction.h<br>
<br>
Modified: llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTree.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GenericDomTree.h?rev=314801&r1=314800&r2=314801&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Support/GenericDomTree.h?rev=3<wbr>14801&r1=314800&r2=314801&view<wbr>=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTree.h (original)<br>
+++ llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTree.h Tue Oct 3 07:33:41 2017<br>
@@ -702,28 +702,25 @@ public:<br>
return;<br>
}<br>
<br>
- unsigned DFSNum = 0;<br>
-<br>
SmallVector<std::pair<const DomTreeNodeBase<NodeT> *,<br>
typename DomTreeNodeBase<NodeT>::const_<wbr>iterator>,<br>
32> WorkStack;<br>
<br>
const DomTreeNodeBase<NodeT> *ThisRoot = getRootNode();<br>
-<br>
+ assert((!Parent || ThisRoot) && "Empty constructed DomTree");<br>
if (!ThisRoot)<br>
return;<br>
<br>
- // Even in the case of multiple exits that form the post dominator root<br>
- // nodes, do not iterate over all exits, but start from the virtual root<br>
- // node. Otherwise bbs, that are not post dominated by any exit but by the<br>
- // virtual root node, will never be assigned a DFS number.<br>
- WorkStack.push_back(std::make_<wbr>pair(ThisRoot, ThisRoot->begin()));<br>
+ // Both dominators and postdominators have a single root node. In the case<br>
+ // case of PostDominatorTree, this node is a virtual root.<br>
+ WorkStack.push_back({ThisRoot, ThisRoot->begin()});<br>
+<br>
+ unsigned DFSNum = 0;<br>
ThisRoot->DFSNumIn = DFSNum++;<br>
<br>
while (!WorkStack.empty()) {<br>
const DomTreeNodeBase<NodeT> *Node = WorkStack.back().first;<br>
- typename DomTreeNodeBase<NodeT>::const_<wbr>iterator ChildIt =<br>
- WorkStack.back().second;<br>
+ const auto ChildIt = WorkStack.back().second;<br>
<br>
// If we visited all of the children of this node, "recurse" back up the<br>
// stack setting the DFOutNum.<br>
@@ -735,7 +732,7 @@ public:<br>
const DomTreeNodeBase<NodeT> *Child = *ChildIt;<br>
++WorkStack.back().second;<br>
<br>
- WorkStack.push_back(std::make_<wbr>pair(Child, Child->begin()));<br>
+ WorkStack.push_back({Child, Child->begin()});<br>
Child->DFSNumIn = DFSNum++;<br>
}<br>
}<br>
<br>
Modified: llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTreeConstruction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h?rev=314801&r1=314800&r2=314801&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Support/GenericDomTreeConstruc<wbr>tion.h?rev=314801&r1=314800&r2<wbr>=314801&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTreeConstruction.h (original)<br>
+++ llvm/trunk/include/llvm/Suppor<wbr>t/GenericDomTreeConstruction.h Tue Oct 3 07:33:41 2017<br>
@@ -1349,6 +1349,102 @@ struct SemiNCAInfo {<br>
return true;<br>
}<br>
<br>
+ // Check if the computed DFS numbers are correct. Note that DFS info may not<br>
+ // be valid, and when that is the case, we don't verify the numbers.<br>
+ static bool VerifyDFSNumbers(const DomTreeT &DT) {<br>
+ if (!DT.DFSInfoValid || !DT.Parent)<br>
+ return true;<br>
+<br>
+ const NodePtr RootBB = IsPostDom ? nullptr : DT.getRoots()[0];<br>
+ const TreeNodePtr Root = DT.getNode(RootBB);<br>
+<br>
+ auto PrintNodeAndDFSNums = [](const TreeNodePtr TN) {<br>
+ errs() << BlockNamePrinter(TN) << " {" << TN->getDFSNumIn() << ", "<br>
+ << TN->getDFSNumOut() << '}';<br>
+ };<br>
+<br>
+ // Verify the root's DFS In number. Although DFS numbering would also work<br>
+ // if we started from some other value, we assume 0-based numbering.<br>
+ if (Root->getDFSNumIn() != 0) {<br>
+ errs() << "DFSIn number for the tree root is not:\n\t";<br>
+ PrintNodeAndDFSNums(Root);<br>
+ errs() << '\n';<br>
+ errs().flush();<br>
+ return false;<br>
+ }<br>
+<br>
+ // For each tree node verify if children's DFS numbers cover their parent's<br>
+ // DFS numbers with no gaps.<br>
+ for (const auto &NodeToTN : DT.DomTreeNodes) {<br>
+ const TreeNodePtr Node = NodeToTN.second.get();<br>
+<br>
+ // Handle tree leaves.<br>
+ if (Node->getChildren().empty()) {<br>
+ if (Node->getDFSNumIn() + 1 != Node->getDFSNumOut()) {<br>
+ errs() << "Tree leaf should have DFSOut = DFSIn + 1:\n\t";<br>
+ PrintNodeAndDFSNums(Node);<br>
+ errs() << '\n';<br>
+ errs().flush();<br>
+ return false;<br>
+ }<br>
+<br>
+ continue;<br>
+ }<br>
+<br>
+ // Make a copy and sort it such that it is possible to check if there are<br>
+ // no gaps between DFS numbers of adjacent children.<br>
+ SmallVector<TreeNodePtr, 8> Children(Node->begin(), Node->end());<br>
+ std::sort(Children.begin(), Children.end(),<br>
+ [](const TreeNodePtr Ch1, const TreeNodePtr Ch2) {<br>
+ return Ch1->getDFSNumIn() < Ch2->getDFSNumIn();<br>
+ });<br>
+<br>
+ auto PrintChildrenError = [Node, &Children, PrintNodeAndDFSNums](<br>
+ const TreeNodePtr FirstCh, const TreeNodePtr SecondCh = nullptr) {<br>
+ assert(FirstCh);<br>
+<br>
+ errs() << "Incorrect DFS numbers for:\n\tParent ";<br>
+ PrintNodeAndDFSNums(Node);<br>
+<br>
+ errs() << "\n\tChild ";<br>
+ PrintNodeAndDFSNums(FirstCh);<br>
+<br>
+ if (SecondCh) {<br>
+ errs() << "\n\tSecond child ";<br>
+ PrintNodeAndDFSNums(SecondCh);<br>
+ }<br>
+<br>
+ errs() << "\nAll children: ";<br>
+ for (const TreeNodePtr Ch : Children) {<br>
+ PrintNodeAndDFSNums(Ch);<br>
+ errs() << ", ";<br>
+ }<br>
+<br>
+ errs() << '\n';<br>
+ errs().flush();<br>
+ };<br>
+<br>
+ if (Children.front()->getDFSNumIn<wbr>() != Node->getDFSNumIn() + 1) {<br>
+ PrintChildrenError(Children.fr<wbr>ont());<br>
+ return false;<br>
+ }<br>
+<br>
+ if (Children.back()->getDFSNumOut<wbr>() + 1 != Node->getDFSNumOut()) {<br>
+ PrintChildrenError(Children.ba<wbr>ck());<br>
+ return false;<br>
+ }<br>
+<br>
+ for (size_t i = 0, e = Children.size() - 1; i != e; ++i) {<br>
+ if (Children[i]->getDFSNumOut() + 1 != Children[i + 1]->getDFSNumIn()) {<br>
+ PrintChildrenError(Children[i]<wbr>, Children[i + 1]);<br>
+ return false;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ return true;<br>
+ }<br>
+<br>
// Checks if for every edge From -> To in the graph<br>
// NCD(From, To) == IDom(To) or To.<br>
bool verifyNCD(const DomTreeT &DT) {<br>
@@ -1521,7 +1617,8 @@ bool Verify(const DomTreeT &DT) {<br>
SemiNCAInfo<DomTreeT> SNCA(nullptr);<br>
return SNCA.verifyRoots(DT) && SNCA.verifyReachability(DT) &&<br>
SNCA.VerifyLevels(DT) && SNCA.verifyNCD(DT) &&<br>
- SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT)<wbr>;<br>
+ SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT) &&<br>
+ SNCA.VerifyDFSNumbers(DT);<br>
}<br>
<br>
} // namespace DomTreeBuilder<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="m_3818168455659261539HOEnZb"><font color="#888888">-- <br><div class="m_3818168455659261539m_-2283884895673315123gmail_signature" data-smartmail="gmail_signature"><div>Jakub Kuderski</div></div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div>Jakub Kuderski</div></div>
</div>