<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=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
/* 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-size:10.0pt;}
@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">Thank you Matthias,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">$ llc bugpoint-reduced-simplified.bc  -verify-machineinstrs -debug-only=regalloc -print-before-all 2>log<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Result file ‘log’ is attached.  None of the target-specific instructions (LI, VEXT, BLT, J) do anything weird with registers.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I saw PR32688, but it looks like a different assertion failing.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">One thing that struck me as odd was that RegisterCoalescer::joinVirtRegs features this guard that looks very similar to the failed condition<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">  // Some conflicts can only be resolved after all values have been mapped.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">  if (!LHSVals.resolveConflicts(RHSVals) || !RHSVals.resolveConflicts(LHSVals))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">    return false;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Compare that to the failed condition in RegisterCoalescer::joinSubRegRanges, which is structurally quite similar but operates on (I think) sub-ranges of those
 intervals previously tested.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">  if (!LHSVals.resolveConflicts(RHSVals) ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">      !RHSVals.resolveConflicts(LHSVals)) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">    // We already determined that it is legal to merge the intervals, so this<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">    // should never fail.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">    llvm_unreachable("*** Couldn't join subrange!\n");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">  }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Nick Johnson<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">D. E. Shaw Research<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<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""> mbraun@apple.com [mailto:mbraun@apple.com]
<br>
<b>Sent:</b> Monday, April 24, 2017 12:58 PM<br>
<b>To:</b> Johnson, Nicholas Paul<br>
<b>Cc:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] Debugging UNREACHABLE "Couldn't join subrange" in RegisterCoalescer (out-of-tree backend)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">This looks like a bug related to the subregister liveness updating in the RegisterCoalescer.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">As this is always hard to debug without having the actual target at hand:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Make sure the testcase (or rather all testcases) passes `llc -verify-machineinstrs`<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- It would be good to see the full `llc -debug-only=regalloc` dump (looking below I would at least see which slotindexes belong to which instructions). Best to file a PR with the information.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- There is one open PR about coalescing subregister liveness right now:  <a href="http://llvm.org/PR32688">http://llvm.org/PR32688</a> (but it's hard to say without investigation whether it is the same).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">- Matthias<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Apr 24, 2017, at 9:10 AM, Johnson, Nicholas Paul via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hello,<br>
<br>
I have a minimal testcase which crashes RegisterCoalescer in my out-of-tree target.  It only crashes in Debug builds of llc---not in Release builds.  Also, interesting to note that the x86 backend lowers this same testcase successfully.  I did a quick search
 of <a href="http://bugs.llvm.org">bugs.llvm.org</a> and found no matches.<br>
<br>
This implies that the problem is in my backend and/or how my backend interacts with RegisterCoalescer.   I'm not too familiar with RegisterCoalescer.   Can anyone give me a hint on where I should start looking for the problem in my backend?  <br>
<br>
Thank you,<br>
Nick Johnson<br>
D. E. Shaw Research<br>
<br>
<br>
Here's my minimal testcase:<br>
<br>
$ llvm-dis -o - bugpoint.reduced.simplified.bc<br>
; ModuleID = 'bugpoint.reduced.simplified.bc'<br>
source_filename = "bugpoint-output-7eb0c3b.bc"<br>
target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i32:32:32-i64:64:64-v64:64:64-v128:128:128-n32-S128"<br>
target triple = "desgcv3-unknown-elf"<br>
<br>
; Function Attrs: noreturn nounwind<br>
define void @wobble() local_unnamed_addr #0 {<br>
 %1 = extractelement <4 x i32> <i32 0, i32 2, i32 3, i32 4>, i32 undef<br>
 %2 = sub nsw i32 0, %1<br>
 %3 = icmp sgt i32 %2, 0<br>
 br i1 %3, label %4, label %5<br>
<br>
; <label>:4:                                      ; preds = %5, %0<br>
 unreachable<br>
<br>
; <label>:5:                                      ; preds = %0<br>
 %6 = extractelement <4 x i32> <i32 0, i32 2, i32 3, i32 4>, i32 undef<br>
 %7 = sub nsw i32 0, %6<br>
 %8 = icmp sgt i32 %7, 0<br>
 br i1 %8, label %9, label %4<br>
<br>
; <label>:9:                                      ; preds = %5<br>
 unreachable<br>
}<br>
<br>
attributes #0 = { noreturn nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false"
 "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
<br>
<br>
Here's the tail-end of the log, with debugging turned on:<br>
<br>
$llc bugpoint.reduced.simplified.bc -debug<br>
...<br>
208B    %vreg13:sub_64_1<def> = COPY %vreg34:sub_64_1; VecRegs:%vreg13,%vreg34<br>
       Considering merging to VecRegs with %vreg34 in %vreg13<br>
               RHS = %vreg34 [160r,240r:0)[240r,384B:1)[400B,480r:1)[480r,496r:2)[496r,672r:3)  0@160r 1@240r 2@480r 3@496r L00000020 [240r,384B:1)[400B,672r:1)  0@x 1@240r L00000010 [160r,384B:1)[400B,672r:1)  0@x 1@160r L00000002 [480r,480d:1)[496r,672r:0)
  0@496r 1@480r L00000001 [480r,672r:0)  0@480r<br>
               LHS = %vreg13 [96r,112r:0)[112r,208r:1)[208r,288r:2)  0@96r 1@112r 2@208r L00000002 [96r,96d:1)[112r,288r:0)  0@112r 1@96r L00000030 [208r,288r:1)  0@x 1@208r L00000001 [96r,288r:0)  0@96r<br>
               merge %vreg13:2@208r into %vreg34:0@160r --> @160r<br>
               LHST = %vreg13 %vreg13 [96r,112r:0)[112r,208r:1)[208r,288r:2)  0@96r 1@112r 2@208r L00000002 [96r,96d:1)[112r,288r:0)  0@112r 1@96r L00000030 [208r,288r:1)  0@x 1@208r L00000001 [96r,288r:0)  0@96r<br>
               Copy+Merge 00000030 into 00000020<br>
               Reduce Lane to 00000010<br>
               conflict at %vreg34:1@240r<br>
*** Couldn't join subrange!<br>
<br>
UNREACHABLE executed at /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2693!<br>
#0 0x00000000027395af llvm::sys::PrintStackTrace(llvm::raw_ostream&) /d/en/johnsoni-0/gctools/llvm/lib/Support/Unix/Signals.inc:402:0<br>
#1 0x0000000002739971 PrintStackTraceSignalHandler(void*) /d/en/johnsoni-0/gctools/llvm/lib/Support/Unix/Signals.inc:466:0<br>
#2 0x0000000002737bce llvm::sys::RunSignalHandlers() /d/en/johnsoni-0/gctools/llvm/lib/Support/Signals.cpp:44:0<br>
#3 0x0000000002738f41 SignalHandler(int) /d/en/johnsoni-0/gctools/llvm/lib/Support/Unix/Signals.inc:256:0<br>
#4 0x000000396140f7e0 __restore_rt (/lib64/libpthread.so.0+0x396140f7e0)<br>
#5 0x0000003960c325e5 __GI_raise (/lib64/libc.so.6+0x3960c325e5)<br>
#6 0x0000003960c33dc5 __GI_abort (/lib64/libc.so.6+0x3960c33dc5)<br>
#7 0x00000000026d4c42 bindingsErrorHandler(void*, std::string const&, bool) /d/en/johnsoni-0/gctools/llvm/lib/Support/ErrorHandling.cpp:127:0<br>
#8 0x0000000001fdbc85 (anonymous namespace)::RegisterCoalescer::joinSubRegRanges(llvm::LiveRange&, llvm::LiveRange&, llvm::LaneBitmask, llvm::CoalescerPair const&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2695:0<br>
#9 0x0000000001fdc3df (anonymous namespace)::RegisterCoalescer::mergeSubRangeInto(llvm::LiveInterval&, llvm::LiveRange const&, llvm::LaneBitmask, llvm::CoalescerPair&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2769:0<br>
#10 0x0000000001fdcbd5 (anonymous namespace)::RegisterCoalescer::joinVirtRegs(llvm::CoalescerPair&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2832:0<br>
#11 0x0000000001fdd174 (anonymous namespace)::RegisterCoalescer::joinIntervals(llvm::CoalescerPair&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2892:0<br>
#12 0x0000000001fd5fc3 (anonymous namespace)::RegisterCoalescer::joinCopy(llvm::MachineInstr*, bool&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:1468:0<br>
#13 0x0000000001fdd4b6 (anonymous namespace)::RegisterCoalescer::copyCoalesceWorkList(llvm::MutableArrayRef<llvm::MachineInstr*>) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:2962:0<br>
#14 0x0000000001fddf32 (anonymous namespace)::RegisterCoalescer::coalesceLocals() /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:3087:0<br>
#15 0x0000000001fde3a1 (anonymous namespace)::RegisterCoalescer::joinAllIntervals() /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:3121:0<br>
#16 0x0000000001fde6e2 (anonymous namespace)::RegisterCoalescer::runOnMachineFunction(llvm::MachineFunction&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/RegisterCoalescer.cpp:3167:0<br>
#17 0x0000000001d28d87 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /d/en/johnsoni-0/gctools/llvm/lib/CodeGen/MachineFunctionPass.cpp:62:0<br>
...<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>