<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I wasn’t able to reproduce the failure, so I reverted the commit in r316612 while I investigate.<o:p></o:p></p><p class=MsoNormal>Can you please send me the command line to use that will fail under bugpoint?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Balaram<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> Balaram Makam [mailto:bmakam@codeaurora.org] <br><b>Sent:</b> Wednesday, October 25, 2017 4:04 PM<br><b>To:</b> 'Galina Kistanova' <gkistanova@gmail.com><br><b>Cc:</b> 'Artur Pilipenko via llvm-commits' <llvm-commits@lists.llvm.org><br><b>Subject:</b> RE: [llvm] r316582 - [Local] Fix a bug in the domtree update logic for MergeBasicBlockIntoOnlyPred.<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Looking..<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>From:</b> Galina Kistanova [<a href="mailto:gkistanova@gmail.com">mailto:gkistanova@gmail.com</a>] <br><b>Sent:</b> Wednesday, October 25, 2017 3:48 PM<br><b>To:</b> Balaram Makam <<a href="mailto:bmakam@codeaurora.org">bmakam@codeaurora.org</a>><br><b>Cc:</b> Artur Pilipenko via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>><br><b>Subject:</b> Re: [llvm] r316582 - [Local] Fix a bug in the domtree update logic for MergeBasicBlockIntoOnlyPred.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hello Balaram,<br><br>It looks like this commit broke tests on our builder:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5719">http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5719</a><br><br>. . .<br>Failing Tests (1):<br>    LLVM :: Transforms/CalledValuePropagation/simple-arguments.ll<br><br>Please have a look?<br><br>Thanks<br><br>Galina<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Oct 25, 2017 at 7:55 AM, Balaram Makam via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><p class=MsoNormal>Author: bmakam<br>Date: Wed Oct 25 07:55:48 2017<br>New Revision: 316582<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=316582&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=316582&view=rev</a><br>Log:<br>[Local] Fix a bug in the domtree update logic for MergeBasicBlockIntoOnlyPred.<br><br>Summary: For some irreducible CFG the domtree nodes might be dead, do not update domtree for dead nodes.<br><br>Reviewers: kuhar, dberlin, hfinkel<br><br>Reviewed By: kuhar<br><br>Subscribers: llvm-commits, mcrosier<br><br>Differential Revision: <a href="https://reviews.llvm.org/D38960" target="_blank">https://reviews.llvm.org/D38960</a><br><br>Modified:<br>    llvm/trunk/lib/Transforms/Utils/Local.cpp<br>    llvm/trunk/unittests/Transforms/Utils/Local.cpp<br><br>Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=316582&r1=316581&r2=316582&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=316582&r1=316581&r2=316582&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Oct 25 07:55:48 2017<br>@@ -649,9 +649,13 @@ void llvm::MergeBasicBlockIntoOnlyPred(B<br>     DestBB->moveAfter(PredBB);<br><br>   if (DT) {<br>-    BasicBlock *PredBBIDom = DT->getNode(PredBB)->getIDom()->getBlock();<br>-    DT->changeImmediateDominator(DestBB, PredBBIDom);<br>-    DT->eraseNode(PredBB);<br>+    // For some irreducible CFG we end up having forward-unreachable blocks<br>+    // so check if getNode returns a valid node before updating the domtree.<br>+    if (DomTreeNode *DTN = DT->getNode(PredBB)) {<br>+      BasicBlock *PredBBIDom = DTN->getIDom()->getBlock();<br>+      DT->changeImmediateDominator(DestBB, PredBBIDom);<br>+      DT->eraseNode(PredBB);<br>+    }<br>   }<br>   // Nuke BB.<br>   PredBB->eraseFromParent();<br><br>Modified: llvm/trunk/unittests/Transforms/Utils/Local.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Local.cpp?rev=316582&r1=316581&r2=316582&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Local.cpp?rev=316582&r1=316581&r2=316582&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/Utils/Local.cpp (original)<br>+++ llvm/trunk/unittests/Transforms/Utils/Local.cpp Wed Oct 25 07:55:48 2017<br>@@ -166,3 +166,48 @@ TEST(Local, ReplaceDbgDeclare) {<br>       Declares++;<br>   EXPECT_EQ(2, Declares);<br> }<br>+<br>+/// Build the dominator tree for the function and run the Test.<br>+static void runWithDomTree(<br>+    Module &M, StringRef FuncName,<br>+    function_ref<void(Function &F, DominatorTree *DT)> Test) {<br>+  auto *F = M.getFunction(FuncName);<br>+  ASSERT_NE(F, nullptr) << "Could not find " << FuncName;<br>+  // Compute the dominator tree for the function.<br>+  DominatorTree DT(*F);<br>+  Test(*F, &DT);<br>+}<br>+<br>+TEST(Local, MergeBasicBlockIntoOnlyPred) {<br>+  LLVMContext C;<br>+<br>+  std::unique_ptr<Module> M = parseIR(<br>+      C,<br>+      "define i32 @f(i8* %str) {\n"<br>+      "entry:\n"<br>+      "  br label %bb2.i\n"<br>+      "bb2.i:                                            ; preds = %bb4.i, %entry\n"<br>+      "  br i1 false, label %bb4.i, label %base2flt.exit204\n"<br>+      "bb4.i:                                            ; preds = %bb2.i\n"<br>+      "  br i1 false, label %base2flt.exit204, label %bb2.i\n"<br>+      "bb10.i196.bb7.i197_crit_edge:                     ; No predecessors!\n"<br>+      "  br label %bb7.i197\n"<br>+      "bb7.i197:                                         ; preds = %bb10.i196.bb7.i197_crit_edge\n"<br>+      "  %.reg2mem.0 = phi i32 [ %.reg2mem.0, %bb10.i196.bb7.i197_crit_edge ]\n"<br>+      "  br i1 undef, label %base2flt.exit204, label %base2flt.exit204\n"<br>+      "base2flt.exit204:                                 ; preds = %bb7.i197, %bb7.i197, %bb2.i, %bb4.i\n"<br>+      "  ret i32 0\n"<br>+      "}\n");<br>+  runWithDomTree(<br>+      *M, "f", [&](Function &F, DominatorTree *DT) {<br>+        for (Function::iterator I = F.begin(), E = F.end(); I != E;) {<br>+          BasicBlock *BB = &*I++;<br>+          BasicBlock *SinglePred = BB->getSinglePredecessor();<br>+          if (!SinglePred || SinglePred == BB || BB->hasAddressTaken()) continue;<br>+          BranchInst *Term = dyn_cast<BranchInst>(SinglePred->getTerminator());<br>+          if (Term && !Term->isConditional())<br>+            MergeBasicBlockIntoOnlyPred(BB, DT);<br>+        }<br>+        EXPECT_TRUE(DT->verify());<br>+      });<br>+}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>