[PATCH]Fix for PR15318: AsmPrinter crashes with assertion

Hao Liu Hao.Liu at arm.com
Tue Mar 19 02:58:01 PDT 2013


Hi,

 

Please consider a patch in attachment as fix for PR15318: AsmPrinter crashes
with assertion.

http://llvm.org/bugs/show_bug.cgi?id=15318

 

APFloat::toString tries to print floating point in decimal string. It
calculates the precision and padding of the output format. At the end of the
AdjustPrecision function, it truncates the significand down to its active
bit count but always keeps it never drop below 32 bits.

 

BitWidth of significand is larger than active bits, but it is not always
larger than 32. E.g. when the 64bit value 0x41EFFFFFE0000000 is read and
called toString(), the BitWidth of significand is smaller than 32. Then
truncating the significand to 32 will cause an assertion failure (it always
asserts width < BitWidth).

 

The fix is very simple, just remove the "don't try to drop below 32"
operation. Always truncate it to the active bits. 

 

I just find it's no need to keep significand above 32. The AdjustPrecision
function does useless thing, which causes the assertion failure. 

 

 

Thanks,

-Hao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130319/b32e4658/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: APFloat.patch
Type: application/octet-stream
Size: 628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130319/b32e4658/attachment.obj>


More information about the llvm-commits mailing list