<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <span
style="font-size:14.0pt;font-family:"Cambria","serif"">Personally,
      I would prefer to see the short term fix implemented as his "(2)
      GVN should skip unreachable code;". <br>
      <br>
      Given there's already a pre-pass merging blocks into their
      predecessor, simply deleting blocks which aren't reachable
      (according to the dom tree) seems quite straight forward and
      inexpensive.<br>
      <br>
      Philip<br>
      <br>
      <br>
    </span>
    <div class="moz-cite-prefix">On 03/19/2015 05:10 PM, Gao, Yunzhong
      wrote:<br>
    </div>
    <blockquote
cite="mid:7266CA7691ED9C4ABF6BECC94C7EB9FCE7998855@USCULXMSG03.am.sony.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 14 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Cambria;
        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;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 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.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.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;}
/* List Definitions */
@list l0
        {mso-list-id:873887640;
        mso-list-type:hybrid;
        mso-list-template-ids:1654663718 1134465488 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"\(%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D">Hi,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Sorry to
            re-open an old thread here. We have a compiler based on LLVM
            3.6 branch, and the compiler hangs<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">when compiling
            one of our games due to this bug. I am aware that there is
            on-going discussion in llvmdev<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">regarding the
            long-term solution of the general design of LLVM passes,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"> <a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150223/261463.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150223/261463.html</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">, which looks
            like it will take a while before any consensus is reached. I
            wonder if Katya’s patch could serve as a<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">stop-gap
            solution for the short term.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">What do you
            think?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">- Gao<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #B5C4DF
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
                <a class="moz-txt-link-abbreviated" href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a>
                [<a class="moz-txt-link-freetext" href="mailto:llvm-commits-bounces@cs.uiuc.edu">mailto:llvm-commits-bounces@cs.uiuc.edu</a>]
                <b>On Behalf Of </b>Romanova, Katya<br>
                <b>Sent:</b> Sunday, February 22, 2015 1:35 AM<br>
                <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
                <b>Subject:</b> Jump Theading/GVN bug<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Hello,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">I
            encountered a problem triggered by Jump-Threading
            optimization.  This pass is creating an unreachable block
            with an instruction that is not well formed, which then
            causes the subsequent GVN pass to enter an infinite loop.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Here
            are the details:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Consider
            the following small testcase. I reduced it from a huge
            project that was failing during LTO. Unfortunately,  I was
            not given any source files, only the bitcode.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal">-----------------------------------------------------------------------------<o:p></o:p></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">small.ll<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">----------------------------------------------------------------<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">%"class.ls_file::Path"
            = type { [1024 x i8], i8*, i8*, i8*}<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">;
            Function Attrs: nounwind sspstrong uwtable<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">define
            void @foo(%"class.ls_file::Path"* %this, i8* nocapture
            readonly %pPath) #0 {<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %1 = load i8* %pPath, align 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  switch
            i8 %1, label %.loopexit.i.i [<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 92, label %2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 47, label %2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            ]
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">;
            <label>:2                                       ;
            preds = %0, %0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %3 = load i8* %pPath, align 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  %4
            = icmp eq i8 %3, 46<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            br i1 %4, label %.critedge.i.i, label %.outer.i.i
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">.critedge.i.i:                                   
            ; preds = %.critedge.i.i, %.critedge.i.i, %2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %.0.i.i = phi i8* [ %pPath, %2 ], [ %5, %.critedge.i.i ], [
            %5, %.critedge.i.i ]<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %5 = getelementptr inbounds i8* %.0.i.i, i64 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  %6
            = load i8* %5, align 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  switch
            i8 %6, label %.outer.i.i [<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 92, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 47, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            ]
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">.outer.i.i:                                      
            ; preds = %.critedge.i.i, %2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %.2.ph2.i.i = phi i8* [ %5, %.critedge.i.i ], [ %pPath, %2 ]<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %7 = load i8* %.2.ph2.i.i, align 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  %8
            = icmp eq i8 %7, 0
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  br
            label %.loopexit.i.i
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">.loopexit.i.i:                                   
            ; preds = %7<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            ret void
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">}<o:p></o:p></span></p>
        <div style="border:none;border-bottom:solid windowtext
          1.0pt;padding:0in 0in 1.0pt 0in">
          <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        </div>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">If
            you run GVN after jump threading, opt will go into infinite
            recursion.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">opt 
            -jump-threading small.ll -o test2.o<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">opt
            -gvn test2.o -o test3.o<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Segmentation
            fault (core dumped)<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Here’s
            why it’s happening:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Jump
            threading transforms this block:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">.critedge.i.i:                                   
            ; preds = %.critedge.i.i, %.critedge.i.i, %2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %.0.i.i = phi i8* [ %pPath, %2 ], [ %5, %.critedge.i.i ], [
            %5, %.critedge.i.i ]<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %5 = getelementptr inbounds i8* %.0.i.i, i64 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  %6
            = load i8* %5, align 1
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">  switch
            i8 %6, label %.outer.i.i [<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 92, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 47, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            ]
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">into
            the following block:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">.critedge.i.i:                                   
            ; preds = %.critedge.i.i, %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %2 = getelementptr inbounds i8* %2, i64 1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            %3 = load i8* %2, align 1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            switch i8 %3, label %.outer.i.i [<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 92, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">   
            i8 47, label %.critedge.i.i<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> 
            ]<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Note
            that the block .critedge.i.i is now unreachable and it
            contains the following instruction:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">%2
            = getelementptr inbounds i8* %2, i64 1                   <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">This
            instruction doesn’t appear to be well formed. However, one
            could argue that it is – formally %2 def does dominate all
            %2 uses because both are located in an unreachable block, so
            every path to the use is passing through the def (because
            there are 0 paths like that).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">That
            is likely the reason why –verify doesn’t complain about it.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">And
            this is where the problem actually happens:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">When
            -gvn pass is invoked afterwards, it goes into an infinite
            recursion in function ‘<span
              style="background:white;mso-highlight:white">PHITranslateSubExpr</span>’
            (located in PHITransAddr.cpp). When processing a GEP
            instruction (%2), this function calls itself recursively
            with its first operand (which is also %2).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">//
            Handle getelementptr with at least one PHI translatable
            operand.<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white"> 
            if (GetElementPtrInst *GEP =
            dyn_cast<GetElementPtrInst>(Inst)) {<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">   
            SmallVector<Value*, 8> GEPOps;<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">   
            bool AnyChanged = false;<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">   
            for (unsigned i = 0, e = GEP->getNumOperands(); i != e;
            ++i) {<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">     
            Value *GEPOp = PHITranslateSubExpr(GEP->getOperand(i),
            CurBB, PredBB, DT);                     // <- it goes
            into infinite recursion here.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif";background:white;mso-highlight:white">     
            if (GEPOp == 0) return 0;</span><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">There
            are several different ways to fix this problem.
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoListParagraph"
          style="text-indent:-.25in;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="font-size:14.0pt;font-family:"Cambria","serif""><span
              style="mso-list:Ignore">(1)<span style="font:7.0pt
                "Times New Roman"">                       
              </span></span></span><!--[endif]--><span
style="font-size:14.0pt;font-family:"Cambria","serif"">We
            have to remove the unreachable code immediately after or
            during Jump-Threading pass;<o:p></o:p></span></p>
        <p class="MsoListParagraph"
          style="text-indent:-.25in;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="font-size:14.0pt;font-family:"Cambria","serif""><span
              style="mso-list:Ignore">(2)<span style="font:7.0pt
                "Times New Roman"">                       
              </span></span></span><!--[endif]--><span
style="font-size:14.0pt;font-family:"Cambria","serif"">GVN
            should skip unreachable code;<o:p></o:p></span></p>
        <p class="MsoListParagraph"
          style="text-indent:-.25in;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="font-size:14.0pt;font-family:"Cambria","serif""><span
              style="mso-list:Ignore">(3)<span style="font:7.0pt
                "Times New Roman"">                       
              </span></span></span><!--[endif]--><span
style="font-size:14.0pt;font-family:"Cambria","serif"">GVN
            shouldn’t recursively invoke the same function with the same
            arguments. 
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Here
            is an extra check that implements the 3<sup>rd</sup>
            approach. Please review.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal">===================================================================<o:p></o:p></p>
        <p class="MsoNormal">--- PHITransAddr.cpp    (revision 229821)<o:p></o:p></p>
        <p class="MsoNormal">+++ PHITransAddr.cpp    (working copy)<o:p></o:p></p>
        <p class="MsoNormal">@@ -217,10 +217,13 @@<o:p></o:p></p>
        <p class="MsoNormal">     SmallVector<Value*, 8> GEPOps;<o:p></o:p></p>
        <p class="MsoNormal">     bool AnyChanged = false;<o:p></o:p></p>
        <p class="MsoNormal">     for (unsigned i = 0, e =
          GEP->getNumOperands(); i != e; ++i) {<o:p></o:p></p>
        <p class="MsoNormal">-      Value *GEPOp =
          PHITranslateSubExpr(GEP->getOperand(i), CurBB, PredBB, DT);<o:p></o:p></p>
        <p class="MsoNormal">+      Value *Operand=
          GEP->getOperand(i);<o:p></o:p></p>
        <p class="MsoNormal">+      if (GEP==Operand)<o:p></o:p></p>
        <p class="MsoNormal">+        continue;<o:p></o:p></p>
        <p class="MsoNormal">+      Value *GEPOp =
          PHITranslateSubExpr(Operand, CurBB, PredBB, DT);<o:p></o:p></p>
        <p class="MsoNormal">       if (!GEPOp) return nullptr;<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">-      AnyChanged |= GEPOp !=
          GEP->getOperand(i);<o:p></o:p></p>
        <p class="MsoNormal">+      AnyChanged |= GEPOp != Operand;<o:p></o:p></p>
        <p class="MsoNormal">       GEPOps.push_back(GEPOp);<o:p></o:p></p>
        <p class="MsoNormal">     }<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
            style="font-family:"Cambria","serif"">===================================================================</span><o:p></o:p></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">One
            thing to note here is – unreachable code, if not removed,
            could push invalid code through subsequent passes. This
            invalid code will not be caught by the verifier. If  these
            passes are not paranoid enough, the bad code may cause all
            sorts of issues. The case above is one example.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif"">Katya.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:14.0pt;font-family:"Cambria","serif""> <o:p></o:p></span></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>