<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 2:21 PM, Chuck Rose III wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"> <DIV class="Section1"><P class="MsoNormal"><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"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><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"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><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"><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="text-autospace:none"><FONT size="2" color="blue" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new";="" color:blue"="">int</SPAN></FONT><FONT size="2" face="Courier New"><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></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><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></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><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></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><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></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><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></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">  Function *FibF = CreateFibFunction(M);<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new""=""><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal" style="text-autospace:none"><FONT size="2" face="Courier New"><SPAN style="font-size:10.0pt;font-family:" courier="" new""="">// add the following line<O:P></O:P></SPAN></FONT></P><P class="MsoNormal" style="text-autospace:none"><B><FONT size="2" face="Courier New"><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></FONT></B></P><P class="MsoNormal"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><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"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><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"><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="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 style="font-size:10.0pt;font-family:" courier="" new""="">  assert(category == fcNormal || category == fcNaN);<O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><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"><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></P></DIV></BLOCKQUOTE><DIV>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?</DIV><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial"><O:P> </O:P></SPAN></FONT></P><P class="MsoNormal"><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"><FONT size="2" face="Arial"><SPAN style="font-size:10.0pt; font-family:Arial">Chuck.<O:P></O:P></SPAN></FONT></P> </DIV><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>