<div dir="ltr"><div>I'll try to fix this is nobody else has yet. I suspect it's similar to:</div><div><a href="https://reviews.llvm.org/rL333610">https://reviews.llvm.org/rL333610</a></div><div>...constant expressions get grouped in with regular constants in our pattern matching and cause trouble.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 10, 2019 at 1:45 PM Yuseok Jeon via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_-7173752822440537342gmail-m_8403425450559278875divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0px;margin-bottom:0px">Thank you for your guide.</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px"><span>I dumped last IR (input IR <span>to InstCombine pass)</span> into "bug.ll" file by using `opt -print-before-all -O3`. </span></p>
<p style="margin-top:0px;margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px;margin-bottom:0px"><span>I also created bc file using `-emit-llvm -O1 -Xclang -disable-llvm-passes -c`. </span></p>
<p style="margin-top:0px;margin-bottom:0px"><span>- you can reproduce the infinite loop by using `opt -O2 -instcombine < bug.bc`. </span></p>
<p style="margin-top:0px;margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px;margin-bottom:0px"><span>I attached these files into this email and please let me know if you need more files and information.</span><br>
</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px">Best Regards,</p>
<p style="margin-top:0px;margin-bottom:0px">Y. Jeon.</p>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7173752822440537342gmail-m_8403425450559278875divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Sanjoy Das <<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>><br>
<b>Sent:</b> Monday, July 8, 2019 10:12:43 PM<br>
<b>To:</b> Yuseok Jeon<br>
<b>Cc:</b> llvm-dev; David Majnemer<br>
<b>Subject:</b> Re: [LLVM] Infinite loop during LLVM InstructionCombining pass optimization</font>
<div> </div>
</div>
<div class="gmail-m_-7173752822440537342gmail-m_8403425450559278875BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="gmail-m_-7173752822440537342gmail-m_8403425450559278875PlainText">If you're able to reproduce the infinite loop with -O3 then you should<br>
be able to dump out the IR that causes `opt -instcombine` to infloop,<br>
unless the bug is truly esoteric (e.g. only caused by a specific<br>
use-list ordering). Maybe take a closer look at the output from `opt<br>
-print-before-all -O3`?<br>
<br>
Alternatively you can use bugpoint to minimize the IR to get a small<br>
reproducer that causes `opt -O3` to hang:<br>
<a href="http://blog.llvm.org/2015/11/reduce-your-testcases-with-bugpoint-and.html" target="_blank">http://blog.llvm.org/2015/11/reduce-your-testcases-with-bugpoint-and.html</a><br>
<br>
-- Sanjoy<br>
<br>
On Mon, Jul 8, 2019 at 6:02 PM Yuseok Jeon <<a href="mailto:jeon41@purdue.edu" target="_blank">jeon41@purdue.edu</a>> wrote:<br>
><br>
> Thank you for your reply.<br>
><br>
><br>
> Could you please let me know how to dump out the IR input to InstCombine?<br>
><br>
><br>
> Alternatively, I created bc file and IR input (It did not work with "opt -instcombine < bug.ll") files.<br>
><br>
> - I tried to create IR input to InstCombine pass using "-mllvm- print-before-all" option.<br>
><br>
> - I also created bc file using “-emit-llvm -O1 -Xclang -disable-llvm-passes -c -o bug.bc”. You can reproduce the infinite loop using "opt -O3 bug.bc"<br>
><br>
> - I attached these files into this email.<br>
><br>
><br>
> Best Regards,<br>
><br>
> Y. Jeon.<br>
><br>
><br>
> ________________________________<br>
> From: Sanjoy Das <<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>><br>
> Sent: Monday, July 8, 2019 12:52:50 AM<br>
> To: Yuseok Jeon; llvm-dev; David Majnemer<br>
> Subject: Re: [LLVM] Infinite loop during LLVM InstructionCombining pass optimization<br>
><br>
> +llvm-dev [usually it is best to CC the llvm dev list for these kinds<br>
> of questions]<br>
><br>
> Also +David Majnemer for InstCombine.<br>
><br>
> This looks like an LLVM bug to me if it reproduces on top of tree.<br>
> Can you dump out the IR input to InstCombine so that we can reproduce<br>
> the infinite loop with `opt -instcombine < bug.ll`? If yes, that<br>
> would be a pretty reasonable bug report.<br>
><br>
> -- Sanjoy<br>
><br>
> On Sun, Jul 7, 2019 at 7:13 PM Yuseok Jeon <<a href="mailto:jeon41@purdue.edu" target="_blank">jeon41@purdue.edu</a>> wrote:<br>
> ><br>
> > Dear Sanjoy Das,<br>
> ><br>
> ><br>
> > My name is Yuseok Jeon.<br>
> ><br>
> > - I'm a Ph.D. student at Purdue University.<br>
> ><br>
> ><br>
> > These days, I'm working on LLVM based project and in trouble because of Infinite loop during LLVM InstructionCombining pass optimization.<br>
> ><br>
> ><br>
> > Thus, I tried to look for experts who commits this LLVM pass to ask this issue and found you.<br>
> ><br>
> > - I'm really sorry if this bothers you.<br>
> ><br>
> ><br>
> > If you don't mind, could you please review whether this is LLVM pass bug or my problem?<br>
> ><br>
> ><br>
> > ==========================================================<br>
> ><br>
> ><br>
> > I found an infinite loop during InstructionCombining optimization in such an environment.<br>
> ><br>
> > LLVM version: 8.0 release<br>
> > Test program: Deal.II (In SPEC CPU2006 benchmark)<br>
> > I modified clang to forcibly mark a non-polymorphic class as a polymorphic class to test some functions and compiled Deal.II.<br>
> ><br>
> > This is a detail infinite loop case (IR code).<br>
> ><br>
> > I only modified clang (not InstructionCombining pass).<br>
> ><br>
> > Step 1: (Applied fmul's Y * (-X) => -(X*Y) policy. 1 instruction -> 2 instructions)<br>
> ><br>
> > [Before] %153 = fmul double %129, fsub (double -0.000000e+00, double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @_ZTV5PointILi3EE, i64 0, inrange i32 0, i64 2) to i64) to double)), !dbg !3967<br>
> ><br>
> > [After]<br>
> ><br>
> > %153 = fmul double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @_ZTV5PointILi3EE, i64 0, inrange i32 0, i64 2) to i64) to double), %129<br>
> ><br>
> > <badref> = fsub double -0.000000e+00, %153, !dbg !DILocation(line: 483, column: 29, scope: <0x6d73b40>, inlinedAt: !DILocation(line: 1032, column: 7, scope: <0x69a9230>)<br>
> ><br>
> > Step 2 (Applied fmul's SimplifyAssociativeOrCommutative policy. More specifically, "order operands such that they are listed from right (least complex) to left (most complex)" policy).<br>
> ><br>
> > [Before] %153 = fmul double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @_ZTV5PointILi3EE, i64 0, inrange i32 0, i64 2) to i64) to double), %129, !dbg !3967<br>
> ><br>
> > [After] %153 = fmul double %129, bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @_ZTV5PointILi3EE, i64 0, inrange i32 0, i64 2) to i64) to double), !dbg !3967<br>
> ><br>
> > Step 3 (Applied fsub's "Fold negation into constant operand" policy. (i.e., -(X * C) --> X * (-C)) )<br>
> ><br>
> > [Before] %154 = fsub double -0.000000e+00, %153, !dbg !3967<br>
> ><br>
> > [After] <badref> = fmul double %129, fsub (double -0.000000e+00, double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @_ZTV5PointILi3EE, i64 0, inrange i32 0, i64 2) to i64) to double))<br>
> ><br>
> > After Step 3, infinte loop is started (i.e., Step1 -> step2 -> step3 -> step1 ->step2 -> step3 -> ...).<br>
> ><br>
> > ====================================================================<br>
> ><br>
> ><br>
> > I will look forward to your response.<br>
> ><br>
> ><br>
> > Thank you very much :).<br>
> ><br>
> ><br>
> > Best regards,<br>
> ><br>
> > Y. Jeon.<br>
> ><br>
> ><br>
> ><br>
</div>
</span></font></div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>