[llvm] Add -Wms-bitfield-padding warning when possible (PR #139828)
Vlad Serebrennikov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 02:39:27 PDT 2025
Endilll wrote:
> @mstorsjo @Endilll @IanWood1 given you're doing stage2+ builds would you folk mind seeing if this warning triggers for you? after applying #139825 if possible
I applied changes from both PRs, and I'm seeing the following warnings (heavily deduplicated):
```
/home/user/endill/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:152:11: warning: bit-field 'AsmPrinterFlags' of type 'uint8_t' (aka 'unsigned char') has a different storage size than the preceding bit-field (1 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
152 | uint8_t AsmPrinterFlags : LLVM_MI_ASMPRINTERFLAGS_BITS;
| ^
/home/user/endill/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:147:12: note: preceding bit-field 'Flags' declared here with type 'uint32_t' (aka 'unsigned int')
147 | uint32_t Flags : LLVM_MI_FLAGS_BITS;
| ^
In file included from /home/user/endill/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:14:
/home/user/endill/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h:66:14: warning: bit-field 'IsSubfield' of type 'uint16_t' (aka 'unsigned short') has a different storage size than the preceding bit-field (2 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
66 | uint16_t IsSubfield : 1;
| ^
/home/user/endill/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h:63:9: note: preceding bit-field 'DataOffset' declared here with type 'int'
63 | int DataOffset : 31;
| ^
/home/user/endill/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:90:12: warning: bit-field 'OptionGroupIndex' of type 'uint16_t' (aka 'unsigned short') has a different storage size than the preceding bit-field (2 vs 1 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
90 | uint16_t OptionGroupIndex : 15;
| ^
/home/user/endill/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:88:11: note: preceding bit-field 'WarnShowInSystemMacro' declared here with type 'uint8_t' (aka 'unsigned char')
88 | uint8_t WarnShowInSystemMacro : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/AST/DeclTemplate.h:1862:8: warning: bit-field 'StrictPackMatch' of type 'bool' has a different storage size than the preceding bit-field (1 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
1862 | bool StrictPackMatch : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/AST/DeclTemplate.h:1855:12: note: preceding bit-field 'SpecializationKind' declared here with type 'unsigned int'
1855 | unsigned SpecializationKind : 3;
| ^
/home/user/endill/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h:1667:8: warning: bit-field 'Visited' of type 'bool' has a different storage size than the preceding bit-field (1 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
1667 | bool Visited : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h:1664:12: note: preceding bit-field 'BlockID' declared here with type 'unsigned int'
1664 | unsigned BlockID : 31;
| ^
/home/user/endill/llvm-project/clang/include/clang/Sema/ScopeInfo.h:119:8: warning: bit-field 'HasBranchProtectedScope' of type 'bool' has a different storage size than the preceding bit-field (1 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
119 | bool HasBranchProtectedScope : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/Sema/ScopeInfo.h:115:13: note: preceding bit-field 'Kind' declared here with type 'ScopeKind'
115 | ScopeKind Kind : 3;
| ^
/home/user/endill/llvm-project/clang/include/clang/Sema/Overload.h:987:14: warning: bit-field 'IsADLCandidate' of type 'unsigned int' has a different storage size than the preceding bit-field (4 vs 1 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
987 | unsigned IsADLCandidate : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/Sema/Overload.h:983:10: note: preceding bit-field 'StrictPackMatch' declared here with type 'bool'
983 | bool StrictPackMatch : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:272:8: warning: bit-field 'AnalyzerWerror' of type 'bool' has a different storage size than the preceding bit-field (1 vs 4 bytes) and will not be packed under the Microsoft ABI [-Wms-bitfield-padding]
272 | bool AnalyzerWerror : 1;
| ^
/home/user/endill/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:269:12: note: preceding bit-field 'NoRetryExhausted' declared here with type 'unsigned int'
269 | unsigned NoRetryExhausted : 1;
| ^
```
Most of them are in headers, so you should take care of them before people's build logs are flooded.
P.S. I'm not really doing 2-stage builds. What I do is that I use nightly builds from https://apt.llvm.org, and update 1-2 times per month on average. TIL that the second stage of 2-stage builds is not compatible with `distcc`, which makes sense, so this was a somewhat painful exercise.
https://github.com/llvm/llvm-project/pull/139828
More information about the llvm-commits
mailing list