[cfe-dev] Crash on alignments >= 2**16 (PR26444)
Philip Reames via cfe-dev
cfe-dev at lists.llvm.org
Tue Feb 16 09:36:58 PST 2016
From the LLVM perspective, the maximum alignment is specified as:
In Value.h:
00520/// \brief The maximum alignment for instructions.
00521///
00522/// This is the greatest alignment value supported by load, store, and
alloca
00523/// instructions, and global values.
00524
<http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#a50e02a54cc6f87a00a671265e1447e61> static const unsigned MaxAlignmentExponent
<http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#a50e02a54cc6f87a00a671265e1447e61> = 29;
00525
<http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#a2885f6c5817ff68bc24bd1e22e221740> static const unsigned MaximumAlignment
<http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#a2885f6c5817ff68bc24bd1e22e221740> = 1u <<MaxAlignmentExponent
<http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#a50e02a54cc6f87a00a671265e1447e61>;
This is checked in the Verifier via:
Assert(GV.getAlignment() <= Value::MaximumAlignment,
"huge alignment values are unsupported", &GV);
(and similiar checks for Load, Store, Alloca, but not the various atomic
instructions)
On 02/14/2016 01:30 PM, don hinton via cfe-dev wrote:
> Sema::AddAlignment() defines MaxValidAlignment like this:
> // Alignment calculations can wrap around if it's greater than 2**28.
> unsigned MaxValidAlignment =
> Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
> : 268435456;
>
> But AggValueSlot stores Alignment as an unsigned short:
>
> class AggValueSlot {
> ...
> unsigned short Alignment;
>
> The max value for an unsigned short is 2**16 -1, but you are passing 2**16, which AddeAlignment says is okay. However, it ends up getting stored as 0 in an unsigned short.
>
> The fix is to make these sizes consistent, but I'm not sure which should be changed (though I'm guessing Alignment should be unsigned instead of unsigned short).
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160216/00f4d8ce/attachment.html>
More information about the cfe-dev
mailing list