[llvm] r300213 - [APSInt] Add a static_assert to ensure APSInt is packed well with APInt after r300171.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 10:07:26 PDT 2017


I was afraid of something like that. Reverted in r300217.

~Craig

On Thu, Apr 13, 2017 at 9:58 AM, Reid Kleckner <rnk at google.com> wrote:

> MSVC does not pack data into base class tail padding, so this
> static_assert fails everywhere on Windows. If we want to do this
> optimization portably, we need to use the ugly SubclassData pattern that
> Value uses.
>
> On Thu, Apr 13, 2017 at 9:34 AM, Craig Topper via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ctopper
>> Date: Thu Apr 13 11:34:49 2017
>> New Revision: 300213
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=300213&view=rev
>> Log:
>> [APSInt] Add a static_assert to ensure APSInt is packed well with APInt
>> after r300171.
>>
>> Modified:
>>     llvm/trunk/include/llvm/ADT/APSInt.h
>>
>> Modified: llvm/trunk/include/llvm/ADT/APSInt.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/
>> ADT/APSInt.h?rev=300213&r1=300212&r2=300213&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/include/llvm/ADT/APSInt.h (original)
>> +++ llvm/trunk/include/llvm/ADT/APSInt.h Thu Apr 13 11:34:49 2017
>> @@ -24,7 +24,9 @@ class LLVM_NODISCARD APSInt : public API
>>
>>  public:
>>    /// Default constructor that creates an uninitialized APInt.
>> -  explicit APSInt() : IsUnsigned(false) {}
>> +  explicit APSInt() : IsUnsigned(false) {
>> +    static_assert(sizeof(*this) == 16, "APSInt fields poorly packed");
>> +  }
>>
>>    /// APSInt ctor - Create an APSInt with the specified width, default to
>>    /// unsigned.
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/1eff6383/attachment.html>


More information about the llvm-commits mailing list