<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Sep 5, 2007, at 5:08 PM, Chuck Rose III wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><O:SMARTTAGTYPE namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"> <DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Hola Dale,<O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">I spent some time walking through what’s going on with a friend of mine from VStudio.  Category is given 2 bits in the APFloat class definition.  It’s sign extending the enum value for the comparisons when it loads it out of the class, so the 2 becomes a -2 and the comparison fails.  He sent me a piece of code which I might be able to use to force the issue.  I’ll update when I try that out. <O:P></O:P></SPAN></FONT></P></DIV></O:SMARTTAGTYPE></BLOCKQUOTE><DIV>OK.  This possibility occurred to me, I checked the C++ standard, and the code is valid; this is explicitly required to work, and there's an example.</DIV><DIV>However VStudio is what it is.  I expect expanding the field to 3 bits is good enough.  I don't think that will hurt anything.</DIV><BLOCKQUOTE type="cite"><O:SMARTTAGTYPE namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"><DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Thanks,<O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Chuck.<O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> </O:P></SPAN></FONT></P> <DIV> <DIV class="MsoNormal" align="center" style="text-align:center"><FONT size="3" face="Times New Roman"><SPAN style="font-size:12.0pt"> <HR size="2" width="100%" align="center" tabindex="-1"> </SPAN></FONT></DIV><P class="MsoNormal"><B><FONT size="2" face="Tahoma"><SPAN style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">From:</SPAN></FONT></B><FONT size="2" face="Tahoma"><SPAN style="font-size:10.0pt;font-family:Tahoma"> llvmdev-bounces@cs.uiuc.edu [<A href="mailto:llvmdev-bounces@cs.uiuc.edu">mailto:llvmdev-bounces@cs.uiuc.edu</A>] <B><SPAN style="font-weight:bold">On Behalf Of </SPAN></B>Chuck Rose III<BR> <B><SPAN style="font-weight:bold">Sent:</SPAN></B> Wednesday, September 05, 2007 2:51 PM<BR> <B><SPAN style="font-weight:bold">To:</SPAN></B> <ST1:PERSONNAME w:st="on">LLVM Developers Mailing List</ST1:PERSONNAME><BR> <B><SPAN style="font-weight:bold">Subject:</SPAN></B> Re: [LLVMdev] Seeing a crash with ConstantFP::get</SPAN></FONT><O:P></O:P></P> </DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">It’s in debug.  I’m having a look at the assembler it’s producing right now and it’s definitely a little odd for what should be a simple assignment in zeroSignificand. <O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> </O:P></SPAN></FONT></P> <DIV> <DIV class="MsoNormal" align="center" style="text-align:center"><FONT size="3" face="Times New Roman"><SPAN style="font-size:12.0pt"> <HR size="2" width="100%" align="center" tabindex="-1"> </SPAN></FONT></DIV><P class="MsoNormal"><B><FONT size="2" face="Tahoma"><SPAN style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">From:</SPAN></FONT></B><FONT size="2" face="Tahoma"><SPAN style="font-size:10.0pt;font-family:Tahoma"> llvmdev-bounces@cs.uiuc.edu [<A href="mailto:llvmdev-bounces@cs.uiuc.edu">mailto:llvmdev-bounces@cs.uiuc.edu</A>] <B><SPAN style="font-weight:bold">On Behalf Of </SPAN></B>Dale Johannesen<BR> <B><SPAN style="font-weight:bold">Sent:</SPAN></B> Wednesday, September 05, 2007 2:39 PM<BR> <B><SPAN style="font-weight:bold">To:</SPAN></B> <ST1:PERSONNAME w:st="on">LLVM Developers Mailing List</ST1:PERSONNAME><BR> <B><SPAN style="font-weight:bold">Subject:</SPAN></B> Re: [LLVMdev] Seeing a crash with ConstantFP::get</SPAN></FONT><O:P></O:P></P> </DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><O:P> </O:P></SPAN></FONT></P> <DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt">On Sep 5, 2007, at 2:21 PM, Chuck Rose III wrote:<O:P></O:P></SPAN></FONT></P> </DIV><P class="MsoNormal" style="margin-bottom:12.0pt"><FONT size="3" face="Times New Roman"><SPAN style="font-size:12.0pt"><O:P> </O:P></SPAN></FONT></P> <DIV><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">Hola LLVMers,<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">I’m getting a crash when using ConstantFP::get.<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">I can repro it by adding one line to the Fibonacci example program:<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" color="blue" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new";color:blue"="">int</SPAN></SPAN></FONT><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt; font-family:" courier="" new""=""> main(<FONT color="blue"><SPAN style="color:blue">int</SPAN></FONT> argc, <FONT color="blue"><SPAN style="color:blue">char</SPAN></FONT> **argv) {<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  <FONT color="blue"><SPAN style="color:blue">int</SPAN></FONT> n = argc > 1 ? atol(argv[1]) : 24;<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  <FONT color="green"><SPAN style="color:green">// Create some module to put our function into it.<O:P></O:P></SPAN></FONT></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  Module *M = <FONT color="blue"><SPAN style="color:blue">new</SPAN></FONT> Module(<FONT color="maroon"><SPAN style="color:maroon">"test"</SPAN></FONT>);<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  <FONT color="green"><SPAN style="color:green">// We are about to create the "fib" function:<O:P></O:P></SPAN></FONT></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  Function *FibF = CreateFibFunction(M);<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">// add the following line<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><B><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new";font-weight:bold"="">  Constant* C = ConstantFP::get(Type::FloatTy,0.0);<O:P></O:P></SPAN></SPAN></FONT></B></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">Can someone verify this?  This is on the PC side of my system which I build with the VStudio files.  I don’t know if the Mac side sees this as well, but I’ll try and verify.  Seems really odd to have something this basic crash me.  It came up because the JITter will call ConstantFP::get with the GenericValue arguments passed it, but the above repro is a lot simpler and is independent of the JITter.<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">My call stack looks like this:<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; text-autospace:none"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial">            in here it fails this:</SPAN></FONT><FONT size="2" face="Courier New"><SPAN courier=""><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  assert(category == fcNormal || category == fcNaN);<O:P></O:P></SPAN></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::APFloat::significandParts()  Line 360 + 0x39 bytes    C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::APFloat::zeroSignificand()  Line 387 + 0x15 bytes     C++</SPAN></FONT><O:P></O:P></P> </DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt">I've been working in this area and probably introduced this, but I don't see how:  zeroSignificand() sets 'category' to fcNormal before calling significandParts, so I don't see how that assert could be triggered.   The call stack looks normal for that source line.  It doesn't appear on the Mac.   Could your compiler be misoptimizing the code?<O:P></O:P></SPAN></FONT></P> </DIV> <BLOCKQUOTE style="margin-top:5.0pt;margin-bottom:5.0pt" type="cite"> <DIV><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::APFloat::APFloat(const llvm::fltSemantics & ourSemantics={...}, unsigned __int64 value=1)  Line 307       C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!`anonymous namespace'::DenseMapAPFloatKeyInfo::getEmptyKey()  Line 277 + 0x11 bytes         C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo>::getEmptyKey()  Line 236 + 0x9 bytes          C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo>::init(unsigned int InitBuckets=64)  Line 295 + 0x9 bytes         C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo>::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo>(unsigned int NumInitBuckets=64)  Line 68      C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::ManagedStatic<llvm::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo> >::LazyInit()  Line 72 + 0x24 bytes     C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::ManagedStatic<llvm::DenseMap<`anonymous namespace'::DenseMapAPFloatKeyInfo::KeyTy,llvm::ConstantFP *,A0x5b1fa632::DenseMapAPFloatKeyInfo> >::operator*()  Line 55  C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!llvm::ConstantFP::get(const llvm::Type * Ty=0x01b352d8, double V=0.00000000000000000)  Line 299 + 0xe bytes          C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!main(int argc=1, char * * argv=0x01b35060)  Line 99 + 0x13 bytes  C++<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes         C<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">            Fibonacci.exe!mainCRTStartup()  Line 403          C<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">Thanks,<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt;font-family:Arial">Chuck.<O:P></O:P></SPAN></FONT></P> </DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt">_______________________________________________<O:P></O:P></SPAN></FONT></P> </DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt">LLVM Developers mailing list<O:P></O:P></SPAN></FONT></P> </DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><A href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</A> <SPAN class="apple-converted-space">        </SPAN><A href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</A><O:P></O:P></SPAN></FONT></P> </DIV> <DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><A href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A><O:P></O:P></SPAN></FONT></P> </DIV> </BLOCKQUOTE> </DIV><P class="MsoNormal"><FONT size="3" face="Times New Roman"><SPAN style="font-size: 12.0pt"><O:P> </O:P></SPAN></FONT></P> </DIV> </O:SMARTTAGTYPE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">LLVM Developers mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</A> <SPAN class="Apple-converted-space">        </SPAN><A href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>