[clang] [NFC] Reduce size of FunctionEffect to 1 byte. (PR #100753)
Doug Wyatt via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 26 07:47:12 PDT 2024
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/100753
>From 3cc18ded835f3a25dc98bc81988d3a2f1181c300 Mon Sep 17 00:00:00 2001
From: Doug Wyatt <dwyatt at apple.com>
Date: Sun, 5 May 2024 12:36:53 -0700
Subject: [PATCH 1/2] Reduce size of FunctionEffect to 1 byte.
---
clang/include/clang/AST/Type.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 25defea58c2dc..cb345c3028909 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4699,16 +4699,16 @@ class FunctionEffect {
private:
LLVM_PREFERRED_TYPE(Kind)
- unsigned FKind : 3;
+ uint8_t FKind : 3;
// Expansion: for hypothetical TCB+types, there could be one Kind for TCB,
// then ~16(?) bits "SubKind" to map to a specific named TCB. SubKind would
// be considered for uniqueness.
public:
- FunctionEffect() : FKind(unsigned(Kind::None)) {}
+ FunctionEffect() : FKind(uint8_t(Kind::None)) {}
- explicit FunctionEffect(Kind K) : FKind(unsigned(K)) {}
+ explicit FunctionEffect(Kind K) : FKind(uint8_t(K)) {}
/// The kind of the effect.
Kind kind() const { return Kind(FKind); }
>From 2021255f055106effabff218149a895168031c6c Mon Sep 17 00:00:00 2001
From: Doug Wyatt <dwyatt at apple.com>
Date: Fri, 26 Jul 2024 07:46:47 -0700
Subject: [PATCH 2/2] Make FunctionEffect just have a Kind instead of a
bitfield
---
clang/include/clang/AST/Type.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index cb345c3028909..509f0d95643b0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4698,26 +4698,25 @@ class FunctionEffect {
};
private:
- LLVM_PREFERRED_TYPE(Kind)
- uint8_t FKind : 3;
+ Kind FKind;
// Expansion: for hypothetical TCB+types, there could be one Kind for TCB,
// then ~16(?) bits "SubKind" to map to a specific named TCB. SubKind would
// be considered for uniqueness.
public:
- FunctionEffect() : FKind(uint8_t(Kind::None)) {}
+ FunctionEffect() : FKind(Kind::None) {}
- explicit FunctionEffect(Kind K) : FKind(uint8_t(K)) {}
+ explicit FunctionEffect(Kind K) : FKind(K) {}
/// The kind of the effect.
- Kind kind() const { return Kind(FKind); }
+ Kind kind() const { return FKind; }
/// Return the opposite kind, for effects which have opposites.
Kind oppositeKind() const;
/// For serialization.
- uint32_t toOpaqueInt32() const { return FKind; }
+ uint32_t toOpaqueInt32() const { return uint32_t(FKind); }
static FunctionEffect fromOpaqueInt32(uint32_t Value) {
return FunctionEffect(Kind(Value));
}
More information about the cfe-commits
mailing list