[llvm] r239357 - [MC] Use unsigned for the Kind bitfield in MCSymbol

Benjamin Kramer benny.kra at gmail.com
Mon Jun 15 12:58:59 PDT 2015


> On 15.06.2015, at 21:53, Justin Bogner <mail at justinbogner.com> wrote:
> 
> Reid Kleckner <reid at kleckner.net> writes:
>> Author: rnk
>> Date: Mon Jun  8 17:12:44 2015
>> New Revision: 239357
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=239357&view=rev
>> Log:
>> [MC] Use unsigned for the Kind bitfield in MCSymbol
>> 
>> Fixes most of the test suite on Windows with clang-cl.
>> 
>> I'm not sure why the test suite was passing with MSVC 2013. Maybe they
>> changed their behavior and we are emulating their old sign extension
>> behavior. I think this deserves more investigation, but I want to green
>> the bot first.
> 
> Does MSVC DTRT if we give the enum an underlying type of unsigned
> instead?

Yes, but GCC will warn that the bitfield cannot represent the full width of the enum. According to the standard an enum with a fixed type can represent any value that type can represent.

- Ben

>> Modified:
>>    llvm/trunk/include/llvm/MC/MCSymbol.h
>> 
>> Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=239357&r1=239356&r2=239357&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCSymbol.h Mon Jun  8 17:12:44 2015
>> @@ -90,7 +90,9 @@ protected:
>>   /// This symbol is private extern.
>>   mutable unsigned IsPrivateExtern : 1;
>> 
>> -  SymbolKind Kind : 2;
>> +  /// LLVM RTTI discriminator. This is actually a SymbolKind enumerator, but is
>> +  /// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
>> +  unsigned Kind : 2;
>> 
>>   /// Index field, for use by the object file implementation.
>>   mutable uint32_t Index = 0;
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list