[clang] af76b6d - [clang][bytecode] Update what primtypes need a Descriptor ctor func (#203834)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 15 04:05:49 PDT 2026
Author: Timm Baeder
Date: 2026-06-15T13:05:44+02:00
New Revision: af76b6d32dba793d67eb8298907f32a68f3b13b0
URL: https://github.com/llvm/llvm-project/commit/af76b6d32dba793d67eb8298907f32a68f3b13b0
DIFF: https://github.com/llvm/llvm-project/commit/af76b6d32dba793d67eb8298907f32a68f3b13b0.diff
LOG: [clang][bytecode] Update what primtypes need a Descriptor ctor func (#203834)
Now that IntegralAP is allocated via InterpState/Program, we don't need
to initialize it. The same is true for Floating.
And with the new `InitMapPtr` being zero by default as well, we don't
need ctor funcs for primitive array types if the element type doesn't
need one.
Added:
Modified:
clang/lib/AST/ByteCode/Descriptor.cpp
clang/lib/AST/ByteCode/InitMap.h
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 8c5bb1af869d1..8d9b87107e65d 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -31,7 +31,10 @@ template <typename T> static constexpr bool needsCtor() {
std::is_same_v<T, Integral<32, false>> ||
std::is_same_v<T, Integral<64, true>> ||
std::is_same_v<T, Integral<64, false>> ||
- std::is_same_v<T, Boolean>)
+ std::is_same_v<T, Integral<64, false>> ||
+ std::is_same_v<T, IntegralAP<false>> ||
+ std::is_same_v<T, IntegralAP<true>> ||
+ std::is_same_v<T, Floating> || std::is_same_v<T, Boolean>)
return false;
return true;
@@ -243,12 +246,6 @@ static bool needsRecordDtor(const Record *R) {
static BlockCtorFn getCtorPrim(PrimType T) {
switch (T) {
- case PT_Float:
- return ctorTy<PrimConv<PT_Float>::T>;
- case PT_IntAP:
- return ctorTy<PrimConv<PT_IntAP>::T>;
- case PT_IntAPS:
- return ctorTy<PrimConv<PT_IntAPS>::T>;
case PT_Ptr:
return ctorTy<PrimConv<PT_Ptr>::T>;
case PT_MemberPtr:
@@ -261,12 +258,6 @@ static BlockCtorFn getCtorPrim(PrimType T) {
static BlockDtorFn getDtorPrim(PrimType T) {
switch (T) {
- case PT_Float:
- return dtorTy<PrimConv<PT_Float>::T>;
- case PT_IntAP:
- return dtorTy<PrimConv<PT_IntAP>::T>;
- case PT_IntAPS:
- return dtorTy<PrimConv<PT_IntAPS>::T>;
case PT_Ptr:
return dtorTy<PrimConv<PT_Ptr>::T>;
case PT_MemberPtr:
@@ -278,7 +269,8 @@ static BlockDtorFn getDtorPrim(PrimType T) {
}
static BlockCtorFn getCtorArrayPrim(PrimType Type) {
- TYPE_SWITCH(Type, return ctorArrayTy<T>);
+ TYPE_SWITCH(Type, if constexpr (!needsCtor<T>()) return nullptr;
+ return ctorArrayTy<T>);
llvm_unreachable("unknown Expr");
}
diff --git a/clang/lib/AST/ByteCode/InitMap.h b/clang/lib/AST/ByteCode/InitMap.h
index b11c305e95ba4..4a941437f7975 100644
--- a/clang/lib/AST/ByteCode/InitMap.h
+++ b/clang/lib/AST/ByteCode/InitMap.h
@@ -82,7 +82,7 @@ struct InitMapPtr final {
/// V's value after the initmap has been destroyed because
/// all its elements have already been initialized.
static constexpr intptr_t AllInitializedValue = 1;
- uintptr_t V = 0;
+ uintptr_t V = NoInitMapValue;
explicit InitMapPtr() = default;
bool hasInitMap() const {
More information about the cfe-commits
mailing list