[llvm-dev] LLVM type.h question

James Courtier-Dutton via llvm-dev llvm-dev at lists.llvm.org
Mon May 4 12:34:15 PDT 2020


Thank you. I missed that SubclassData was a bitfield.

Kind Regards

James


On Mon, 4 May 2020 at 17:14, Chris Lattner <clattner at nondot.org> wrote:
>
> Right - this is intended to catch a problem where someone tries to store a value in SubclassData that is too large to fit in the bitfield.
>
> -Chris
>
> On May 3, 2020, at 4:45 PM, Craig Topper via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Isn't the SubclassData member a 24 bit bitfield? I think the truncation would happen on the assignment to it.
>
> ~Craig
>
>
> On Sun, May 3, 2020 at 4:06 PM James Courtier-Dutton via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>
>> Hi,
>>
>> I see this in the Type class:
>>
>> unsigned getSubclassData() const { return SubclassData; }
>>
>> void setSubclassData(unsigned val) {
>>   SubclassData = val;
>>   // Ensure we don't have any accidental truncation.
>>   assert(getSubclassData() == val && "Subclass data too large for field");
>> }
>>
>> How will the assert ever get triggered?
>> The type is "unsigned" so how can getSubclassData() ever not equal val ?
>> Where does the truncation take place?
>>
>> Kind Regards
>>
>> James
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>


More information about the llvm-dev mailing list