Skip to content

Commit a28452d

Browse files
committed
[NFC] Address bit-field storage sizes to ensure ideal packing
The MS bit-field packing ABI depends on the storage size of the type of being placed in the bit-field. This PR addresses a number of cases in llvm where the storage type has lead to suboptimal packing.
1 parent 7460056 commit a28452d

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

llvm/include/llvm/ADT/ImmutableSet.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/SmallVector.h"
2121
#include "llvm/ADT/iterator.h"
2222
#include "llvm/Support/Allocator.h"
23+
#include "llvm/Support/Compiler.h"
2324
#include "llvm/Support/ErrorHandling.h"
2425
#include <cassert>
2526
#include <cstdint>
@@ -213,9 +214,12 @@ class ImutAVLTree {
213214
ImutAVLTree *next = nullptr;
214215

215216
unsigned height : 28;
216-
bool IsMutable : 1;
217-
bool IsDigestCached : 1;
218-
bool IsCanonicalized : 1;
217+
LLVM_PREFERRED_TYPE(bool)
218+
unsigned IsMutable : 1;
219+
LLVM_PREFERRED_TYPE(bool)
220+
unsigned IsDigestCached : 1;
221+
LLVM_PREFERRED_TYPE(bool)
222+
unsigned IsCanonicalized : 1;
219223

220224
value_type value;
221225
uint32_t digest = 0;

llvm/include/llvm/Bitstream/BitCodes.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/SmallVector.h"
2121
#include "llvm/ADT/StringExtras.h"
2222
#include "llvm/Bitstream/BitCodeEnums.h"
23+
#include "llvm/Support/Compiler.h"
2324
#include "llvm/Support/DataTypes.h"
2425
#include "llvm/Support/ErrorHandling.h"
2526
#include <cassert>
@@ -32,8 +33,9 @@ namespace llvm {
3233
///
3334
class BitCodeAbbrevOp {
3435
uint64_t Val; // A literal value or data for an encoding.
35-
bool IsLiteral : 1; // Indicate whether this is a literal value or not.
36-
unsigned Enc : 3; // The encoding to use.
36+
LLVM_PREFERRED_TYPE(bool)
37+
uint64_t IsLiteral : 1; // Indicate whether this is a literal value or not.
38+
uint64_t Enc : 3; // The encoding to use.
3739
public:
3840
enum Encoding {
3941
Fixed = 1, // A fixed width field, Val specifies number of bits.

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "DemangleConfig.h"
2020
#include "StringViewExtras.h"
2121
#include "Utility.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include <algorithm>
2324
#include <cctype>
2425
#include <cstdio>
@@ -164,18 +165,18 @@ class NodeArray;
164165
// traversed by the printLeft/Right functions to produce a demangled string.
165166
class Node {
166167
public:
167-
enum Kind : unsigned char {
168+
enum Kind : unsigned {
168169
#define NODE(NodeKind) K##NodeKind,
169170
#include "ItaniumNodes.def"
170171
};
171172

172173
/// Three-way bool to track a cached value. Unknown is possible if this node
173174
/// has an unexpanded parameter pack below it that may affect this cache.
174-
enum class Cache : unsigned char { Yes, No, Unknown, };
175+
enum class Cache : unsigned { Yes, No, Unknown, };
175176

176177
/// Operator precedence for expression nodes. Used to determine required
177178
/// parens in expression emission.
178-
enum class Prec {
179+
enum class Prec : unsigned {
179180
Primary,
180181
Postfix,
181182
Unary,
@@ -2995,7 +2996,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
29952996
};
29962997
char Enc[2]; // Encoding
29972998
OIKind Kind; // Kind of operator
2998-
bool Flag : 1; // Entry-specific flag
2999+
LLVM_PREFERRED_TYPE(bool)
3000+
unsigned Flag : 1; // Entry-specific flag
29993001
Node::Prec Prec : 7; // Precedence
30003002
const char *Name; // Spelling
30013003

llvm/include/llvm/IR/Metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,8 @@ class MDNode : public Metadata {
10761076
/// Explicity set alignment because bitfields by default have an
10771077
/// alignment of 1 on z/OS.
10781078
struct alignas(alignof(size_t)) Header {
1079-
bool IsResizable : 1;
1080-
bool IsLarge : 1;
1079+
size_t IsResizable : 1;
1080+
size_t IsLarge : 1;
10811081
size_t SmallSize : 4;
10821082
size_t SmallNumOps : 4;
10831083
size_t : sizeof(size_t) * CHAR_BIT - 10;

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/IR/GlobalValue.h"
2929
#include "llvm/IR/Module.h"
3030
#include "llvm/Support/Allocator.h"
31+
#include "llvm/Support/Compiler.h"
3132
#include "llvm/Support/InterleavedRange.h"
3233
#include "llvm/Support/MathExtras.h"
3334
#include "llvm/Support/ScaledNumber.h"
@@ -72,7 +73,8 @@ struct CalleeInfo {
7273
uint32_t Hotness : 3;
7374

7475
// True if at least one of the calls to the callee is a tail call.
75-
bool HasTailCall : 1;
76+
LLVM_PREFERRED_TYPE(bool)
77+
uint32_t HasTailCall : 1;
7678

7779
/// The value stored in RelBlockFreq has to be interpreted as the digits of
7880
/// a scaled number with a scale of \p -ScaleShift.

llvm/include/llvm/IR/User.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class User : public Value {
7979
struct AllocInfo {
8080
public:
8181
const unsigned NumOps : NumUserOperandsBits;
82-
const bool HasHungOffUses : 1;
83-
const bool HasDescriptor : 1;
82+
const unsigned HasHungOffUses : 1;
83+
const unsigned HasDescriptor : 1;
8484

8585
AllocInfo() = delete;
8686

0 commit comments

Comments
 (0)