<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:12.0pt;
        font-family:"Times New Roman",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;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@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"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Yeah, sorry about that.  I’ve since moved the test to an X86-specific location.<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Mike Aizatsky [mailto:aizatsky@chromium.org]
<br>
<b>Sent:</b> Thursday, December 03, 2015 12:00 PM<br>
<b>To:</b> Kaylor, Andrew <andrew.kaylor@intel.com>; llvm-commits@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm] r254629 - [WinEH] Avoid infinite loop in BranchFolding for multiple single block funclets<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Looks like this change broke the build:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/3908/steps/ninja%20check%201/logs/stdio">http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/3908/steps/ninja%20check%201/logs/stdio</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">******************** TEST 'LLVM :: Transforms/BranchFolding/single-block-funclets.ll' FAILED ********************<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Script:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/home/renato.golin/buildslave/clang-cmake-aarch64-42vma/stage1/./bin/llc -mtriple=x86_64-pc-windows-msvc < /home/renato.golin/buildslave/clang-cmake-aarch64-42vma/llvm/test/Transforms/BranchFolding/single-block-funclets.ll | /home/renato.golin/buildslave/clang-cmake-aarch64-42vma/stage1/./bin/FileCheck
 /home/renato.golin/buildslave/clang-cmake-aarch64-42vma/llvm/test/Transforms/BranchFolding/single-block-funclets.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Exit Code: 2<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Command Output (stderr):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/home/renato.golin/buildslave/clang-cmake-aarch64-42vma/stage1/./bin/llc: : error: unable to get target for 'x86_64-pc-windows-msvc', see --version and --triple.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">FileCheck error: '-' is empty.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Thu, Dec 3, 2015 at 10:58 AM Andrew Kaylor via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: akaylor<br>
Date: Thu Dec  3 12:55:28 2015<br>
New Revision: 254629<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=254629&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=254629&view=rev</a><br>
Log:<br>
[WinEH] Avoid infinite loop in BranchFolding for multiple single block funclets<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D14996" target="_blank">http://reviews.llvm.org/D14996</a><br>
<br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/BranchFolding.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=254629&r1=254628&r2=254629&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=254629&r1=254628&r2=254629&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu Dec  3 12:55:28 2015<br>
@@ -1564,6 +1564,14 @@ ReoptimizeBlock:<br>
       // removed, move this block to the end of the function.<br>
       MachineBasicBlock *PrevTBB = nullptr, *PrevFBB = nullptr;<br>
       SmallVector<MachineOperand, 4> PrevCond;<br>
+      // We're looking for cases where PrevBB could possibly fall through to<br>
+      // FallThrough, but if FallThrough is an EH pad that wouldn't be useful<br>
+      // so here we skip over any EH pads so we might have a chance to find<br>
+      // a branch target from PrevBB.<br>
+      while (FallThrough != MF.end() && FallThrough->isEHPad())<br>
+        ++FallThrough;<br>
+      // Now check to see if the current block is sitting between PrevBB and<br>
+      // a block to which it could fall through.<br>
       if (FallThrough != MF.end() &&<br>
           !TII->AnalyzeBranch(PrevBB, PrevTBB, PrevFBB, PrevCond, true) &&<br>
           PrevBB.isSuccessor(&*FallThrough)) {<br>
<br>
Added: llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll?rev=254629&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll?rev=254629&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll (added)<br>
+++ llvm/trunk/test/Transforms/BranchFolding/single-block-funclets.ll Thu Dec  3 12:55:28 2015<br>
@@ -0,0 +1,110 @@<br>
+; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s<br>
+<br>
+declare i32 @__CxxFrameHandler3(...)<br>
+<br>
+declare void @throw()<br>
+declare i16 @f()<br>
+<br>
+define i16 @test1(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {<br>
+entry:<br>
+  %cmp = icmp eq i16 %a, 10<br>
+  br i1 %cmp, label %if.then, label %if.else<br>
+<br>
+if.then:<br>
+  %call1 = invoke i16 @f()<br>
+          to label %cleanup unwind label %catch.dispatch<br>
+<br>
+if.else:<br>
+  %call2 = invoke i16 @f()<br>
+          to label %cleanup unwind label %catch.dispatch<br>
+<br>
+catch.dispatch:<br>
+  catchpad [i8* null, i32 8, i8* null]<br>
+          to label %catch unwind label %catch.dispatch.2<br>
+<br>
+catch:<br>
+  invoke void @throw() noreturn<br>
+          to label %unreachable unwind label %catchendblock<br>
+<br>
+catch.dispatch.2:<br>
+  catchpad [i8* null, i32 64, i8* null]<br>
+          to label %catch.2 unwind label %catchendblock<br>
+<br>
+catch.2:<br>
+  store i8 1, i8* %b<br>
+  invoke void @throw() noreturn<br>
+          to label %unreachable unwind label %catchendblock<br>
+<br>
+catchendblock:<br>
+  catchendpad unwind to caller<br>
+<br>
+cleanup:<br>
+  %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ]<br>
+  ret i16 %retval<br>
+<br>
+unreachable:<br>
+  unreachable<br>
+}<br>
+<br>
+; This test verifies the case where two funclet blocks meet the old criteria<br>
+; to be placed at the end.  The order of the blocks is not important for the<br>
+; purposes of this test.  The failure mode is an infinite loop during<br>
+; compilation.<br>
+;<br>
+; CHECK-LABEL: .def     test1;<br>
+<br>
+define i16 @test2(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {<br>
+entry:<br>
+  %cmp = icmp eq i16 %a, 10<br>
+  br i1 %cmp, label %if.then, label %if.else<br>
+<br>
+if.then:<br>
+  %call1 = invoke i16 @f()<br>
+          to label %cleanup unwind label %catch.dispatch<br>
+<br>
+if.else:<br>
+  %call2 = invoke i16 @f()<br>
+          to label %cleanup unwind label %catch.dispatch<br>
+<br>
+catch.dispatch:<br>
+  catchpad [i8* null, i32 8, i8* null]<br>
+          to label %catch unwind label %catch.dispatch.2<br>
+<br>
+catch:<br>
+  invoke void @throw() noreturn<br>
+          to label %unreachable unwind label %catchendblock<br>
+<br>
+catch.dispatch.2:<br>
+  %c2 = catchpad [i8* null, i32 32, i8* null]<br>
+          to label %catch.2 unwind label %catch.dispatch.3<br>
+<br>
+catch.2:<br>
+  store i8 1, i8* %b<br>
+  catchret %c2 to label %cleanup<br>
+<br>
+catch.dispatch.3:<br>
+  %c3 = catchpad [i8* null, i32 64, i8* null]<br>
+          to label %catch.3 unwind label %catchendblock<br>
+<br>
+catch.3:<br>
+  store i8 2, i8* %b<br>
+  catchret %c3 to label %cleanup<br>
+<br>
+catchendblock:<br>
+  catchendpad unwind to caller<br>
+<br>
+cleanup:<br>
+  %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ], [ -1, %catch.2 ], [ -1, %catch.3 ]<br>
+  ret i16 %retval<br>
+<br>
+unreachable:<br>
+  unreachable<br>
+}<br>
+<br>
+; This test verifies the case where three funclet blocks all meet the old<br>
+; criteria to be placed at the end.  The order of the blocks is not important<br>
+; for the purposes of this test.  The failure mode is an infinite loop during<br>
+; compilation.<br>
+;<br>
+; CHECK-LABEL: .def     test2;<br>
+<br>
<br>
<br>
_______________________________________________<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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>