<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Thank you for your guide.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><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:0;margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span>I also created bc file using `-emit-llvm -O1 -Xclang -disable-llvm-passes -c`. </span></p>
<p style="margin-top:0;margin-bottom:0"><span>- you can reproduce the infinite loop by using `opt -O2 -instcombine < bug.bc`. </span></p>
<p style="margin-top:0;margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><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:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards,</p>
<p style="margin-top:0;margin-bottom:0">Y. Jeon.</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Sanjoy Das <sanjoy@playingwithpointers.com><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="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">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">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 <jeon41@purdue.edu> 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 <sanjoy@playingwithpointers.com><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 <jeon41@purdue.edu> 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>
</body>
</html>