<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=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        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:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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-IE link=blue vlink=purple style='word-wrap: break-word;-webkit-nbsp-mode: space;-webkit-line-break: after-white-space'><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'>I have found that failures such as this (especially given the nature of diagnostic, and the fact that it only crashes on Windows), have often had to do with the a bug in using the C++ Standard collections and iterators.  It is worth building this in Debug mode using MSVC++ and using the debug instrumented STL collections and iterators.  The implementation of these in MSVC++ is more rigorous than the version provided with G++ and using this in debug mode often diagnoses an iteration error in the code that appears to be harmless in the G++ implementation, but which represents a logical failure in the code that is still wrong, but does not crash.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] <b>On Behalf Of </b>Sebastian Blessing via llvm-dev<br><b>Sent:</b> 11 September 2015 12:38<br><b>To:</b> llvm-dev@lists.llvm.org<br><b>Subject:</b> [llvm-dev] Optimizer issues on Windows<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>Dear Community,<o:p></o:p></span></p></div></div></div><div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>The <a href="https://github.com/CausalityLtd/ponyc/tree/llvm37">ponyc</a> (llvm37 branch) project is facing an issue on Windows:<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>When optimizations are turned on (llvm 3.7.0-final and <a href="https://github.com/CausalityLtd/ponyc/blob/llvm37/src/libponyc/codegen/genopt.cc">more specifically</a>, opt-level 3,  BBVectorize, LoopVectorize, SLPVectorize, RerollLoops, LoadCombine + a custom heap to stack pass) writing an object file aborts (on Windows only) with the following fatal error:<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>“Starting a function before ending the previous one!” at MCStreamer.cpp:407 during LLVMTargetMachineEmitToFile. Verifying the IR with llc raises no errors.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>What exact problem is being detected here and how can we get more details on the location in the IR that is causing the problem?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>Turning off optimizations successfully writes the object file. This only occurs on Windows, writing object files works fine on Linux and OS X.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>Is this a know issue with LLVM 3.7.0-final and how can this be fixed? Is a patch required?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>This might be related to <a href="https://llvm.org/bugs/show_bug.cgi?id=24374">https://llvm.org/bugs/show_bug.cgi?id=24374</a>.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>Kind regards<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'>Sebastian<o:p></o:p></span></p></div><div><div id=""><div><div id="the_sig_to_copy"><div><div style='margin-top:6.0pt;margin-right:6.0pt;max-width: 470px' id=tp1><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div></div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black;border:solid windowtext 1.0pt;padding:0cm'><img border=0 width=1 height=1 id="_x0000_i1025" src="cid:image001.jpg@01D0EC9B.D0517630" alt="Image removed by sender."><img border=0 width=1 height=1 id="_x0000_i1026" src="cid:image001.jpg@01D0EC9B.D0517630" alt="Image removed by sender."></span><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p></o:p></span></p></div></div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Calibri",sans-serif;color:black'><o:p> </o:p></span></p></div></div></div></div></body></html>