This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Change bitfield types to be identical.
ClosedPublic

Authored by oontvoo on Nov 2 2021, 12:16 PM.

Details

Reviewers
int3
gkm
Group Reviewers
Restricted Project
Commits
rGae31f9fbaddd: [lld-macho] Change bitfield types to be identical.
Summary

Symbol's subclasses all have an additional bitfield of type uint8_t (RefState enum).
For the bitfields in the same block tomerge, they should be of the same type. (clang/gcc will work, but others like MSVC does not)

Eg., https://gcc.godbolt.org/z/9sPbzYsqG

Diff Detail

Event Timeline

oontvoo created this revision.Nov 2 2021, 12:16 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
oontvoo requested review of this revision.Nov 2 2021, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2021, 12:16 PM
oontvoo edited the summary of this revision. (Show Details)Nov 2 2021, 12:21 PM
int3 accepted this revision.Nov 2 2021, 12:27 PM

Oh yes, I remember seeing this issue. Thanks!

This revision is now accepted and ready to land.Nov 2 2021, 12:27 PM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Nov 2 2021, 1:38 PM

Bitfields can't be merged across classes in either abi: https://gcc.godbolt.org/z/n5Efxh551

Also, Defined doesn't have a refState field.

These fields are semantically bool, so I'd keep them that unless there's a reason to change it. In this case this doesn't buy anything as far as I can tell. (But if you have eg /usr/bin/time -f %M / /usr/bin/time -l numbers to back up a benefit, then changes like this are great of course.)

Bitfields can't be merged across classes in either abi: https://gcc.godbolt.org/z/n5Efxh551

Also, Defined doesn't have a refState field.

These fields are semantically bool, so I'd keep them that unless there's a reason to change it. In this case this doesn't buy anything as far as I can tell. (But if you have eg /usr/bin/time -f %M / /usr/bin/time -l numbers to back up a benefit, then changes like this are great of course.)

oops ... too late . will revert it.

re: benefit: nothing measured yet , I'd been seeing a few warnings in the vicinity warning: ‘lld::macho::DylibSymbol::refState’ is too small to hold all values of ‘enum class lld::macho::RefState’ so I started poking around an noticed this ...