Skip to content

Commit 9ee0116

Browse files
committed
Use bitfields
Actually shrinks the struct from 528 to 520 bytes.
1 parent 17963fa commit 9ee0116

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

clang/lib/AST/ByteCode/Function.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,32 @@ class Function final {
277277
/// List of parameter offsets.
278278
llvm::SmallVector<unsigned, 8> ParamOffsets;
279279
/// Flag to indicate if the function is valid.
280-
bool IsValid = false;
280+
LLVM_PREFERRED_TYPE(bool)
281+
unsigned IsValid : 1;
281282
/// Flag to indicate if the function is done being
282283
/// compiled to bytecode.
283-
bool IsFullyCompiled = false;
284+
LLVM_PREFERRED_TYPE(bool)
285+
unsigned IsFullyCompiled : 1;
284286
/// Flag indicating if this function takes the this pointer
285287
/// as the first implicit argument
286-
bool HasThisPointer = false;
288+
LLVM_PREFERRED_TYPE(bool)
289+
unsigned HasThisPointer : 1;
287290
/// Whether this function has Return Value Optimization, i.e.
288291
/// the return value is constructed in the caller's stack frame.
289292
/// This is done for functions that return non-primive values.
290-
bool HasRVO = false;
293+
LLVM_PREFERRED_TYPE(bool)
294+
unsigned HasRVO : 1;
291295
/// If we've already compiled the function's body.
292-
bool HasBody = false;
293-
bool Defined = false;
294-
bool Variadic = false;
295-
bool Virtual = false;
296-
bool Immediate = false;
296+
LLVM_PREFERRED_TYPE(bool)
297+
unsigned HasBody : 1;
298+
LLVM_PREFERRED_TYPE(bool)
299+
unsigned Defined : 1;
300+
LLVM_PREFERRED_TYPE(bool)
301+
unsigned Variadic : 1;
302+
LLVM_PREFERRED_TYPE(bool)
303+
unsigned Virtual : 1;
304+
LLVM_PREFERRED_TYPE(bool)
305+
unsigned Immediate : 1;
297306

298307
public:
299308
/// Dumps the disassembled bytecode to \c llvm::errs().

0 commit comments

Comments
 (0)