<div dir="ltr">Thanks again John. I will go for that direction and hopefully report the problem later if I manage to pinpoint it.<div><br></div><div>Best,</div><div>Peizhao</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 1, 2017 at 5:21 PM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@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 bgcolor="#FFFFFF" text="#000000"><span class="">
    <div class="m_-7777550609902075162moz-cite-prefix">On 3/1/17 6:58 PM, Peizhao Ou wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Yeah, it looks like SROA does mem2reg too. One more
        update is that the following two combinations are fine:
        <div>1. opt (no optimization) + llc (-O0)</div>
        <div>2. opt (-O3) + llc (-O3)</div>
        <div><br>
        </div>
        <div>And the problematic combination is "opt (-O3) + llc (-O0)".
          Now I suspect that there are even synergistic effects between
          frontend and backend optimizations.  Any comments about that?</div>
      </div>
    </blockquote>
    <br></span>
    There are passes like UnifyExitNodes that some passes may assume
    have already been executed.  That could trigger a misoptimization.<br>
    <br>
    That said, I would really like to see bugpoint try to reduce this
    bug.  Your situation is a perfect case for bugpoint, and bugpoint
    should be able to reduce the optimizations and code down to a point
    where someone can tell whether it's a missing optimization or a bug
    in an optimization.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<div><div class="h5"><br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Peizhao</div>
        <div><a href="http://plrg.eecs.uci.edu/%7Epeizhaoo/profile/" target="_blank">http://plrg.eecs.uci.edu/~<wbr>peizhaoo/profile/</a> </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Wed, Mar 1, 2017 at 2:35 PM, Sean
          Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote">
            <div dir="ltr"><br>
              <div class="gmail_extra"><br>
                <div class="gmail_quote"><span>On Wed, Mar 1,
                    2017 at 12:53 PM, John Criswell via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote">
                      <div><span>
                          <div class="m_-7777550609902075162m_627183699730871673m_-943774855540209988moz-cite-prefix">On
                            3/1/17 2:54 PM, Peizhao Ou via llvm-dev
                            wrote:<br>
                          </div>
                          <blockquote type="cite">
                            <div dir="ltr">Hi everyone,
                              <div><br>
                              </div>
                              <div>I am currently testing out a
                                combination of IR->IR passes with opt
                                to benchmark how they affect
                                performance. The source code works fine
                                if simply use the clang (-O0/-O3) to
                                directly compile to object files and
                                link them. However, when I use opt with
                                a select set of passes and then use llc
                                to compile them to binary, the compiled
                                binary is wrong.</div>
                            </div>
                          </blockquote>
                          <br>
                        </span> Can you clarify what you mean by "binary
                        is wrong"?  Does the program not link, or does
                        it produce incorrect results when executed?<br>
                        <br>
                        You might try running mem2reg before any other
                        passes in your random list of optimizations. 
                        mem2reg does SSA construction; I'd bet that
                        you're more likely to trigger a bug in other
                        passes if you haven't run mem2reg first.  That
                        said, I don't think any passes are needed for
                        correctness.<br>
                      </div>
                    </blockquote>
                    <div><br>
                    </div>
                  </span>
                  <div>SROA does this too (among other things).</div>
                  <span class="m_-7777550609902075162HOEnZb">
                    <div><br>
                    </div>
                    <div>-- Sean Silva</div>
                  </span>
                  <div>
                    <div class="m_-7777550609902075162h5">
                      <div> </div>
                      <blockquote class="gmail_quote">
                        <div> <br>
                          You might also try using bugpoint to reduce
                          the bug that you're seeing.  As I said before,
                          you may be triggering bugs that don't usually
                          show up in the standard pass pipeline. 
                          Reducing the bug (and fixing it if you are
                          willing and able) would help improve the
                          quality of the code.<br>
                          <br>
                          Regards,<br>
                          <br>
                          John Criswell<br>
                          <br>
                          <br>
                          <blockquote type="cite"><span>
                              <div dir="ltr">
                                <div><br>
                                </div>
                                <div>That makes me wonder if there are
                                  any IR->IR passes that are
                                  indispensable and they are to
                                  guarantee the semantics?</div>
                                <div><br>
                                </div>
                                <div>Here's my workflow just in case:<br>
                                </div>
                                <div>******************************<wbr>******************************<wbr>*********************</div>
                                <div>1. Compile the source code to
                                  unoptimized IRs:</div>
                                <div>clang -c -emit-llvm -O0 test.c -o
                                  test.bc</div>
                                <div>2. Run opt with a set of IR->IR
                                  passes, e.g.,</div>
                                <div>opt -simplifycfg -sroa -inferattrs
                                  -globalopt -instcombine -simplifycfg
                                  -prune-eh -inline  -tailcallelim
                                  -simplifycfg -loop-simplify -lcssa
                                  -loop-rotate -licm -gvn -verify
                                  test.bc -o test.bc</div>
                                <div>3. Run llc with -O0:</div>
                                <div>llc -file-type=obj test.bc -o
                                  test.o</div>
                                <div>4. Last link all the object files:</div>
                                <div>clang -O0 test1.o test2.o -o test</div>
                                <div>******************************<wbr>******************************<wbr>*********************<br>
                                </div>
                                <div><br>
                                </div>
                                <div>Thanks,</div>
                                <div>Peizhao</div>
                                <div><br>
                                </div>
                              </div>
                              <br>
                              <fieldset class="m_-7777550609902075162m_627183699730871673m_-943774855540209988mimeAttachmentHeader"></fieldset>
                              <br>
                            </span><span>
                              <pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_-7777550609902075162m_627183699730871673m_-943774855540209988moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_-7777550609902075162m_627183699730871673m_-943774855540209988moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a>
</pre>
    </span></blockquote><span class="m_-7777550609902075162m_627183699730871673HOEnZb">
    

    <p>

    </p>
    <pre class="m_-7777550609902075162m_627183699730871673m_-943774855540209988moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="m_-7777550609902075162m_627183699730871673m_-943774855540209988moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/<wbr>criswell</a></pre>
  </span></div>


______________________________<wbr>_________________

LLVM Developers mailing list

<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>

<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a>


</blockquote></div></div></div>
</div></div>
</blockquote></div>
</div>



</blockquote>
<p>
</p><pre class="m_-7777550609902075162moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="m_-7777550609902075162moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/<wbr>criswell</a></pre></div></div></div></blockquote></div><br></div>