[clang] [Clang][ByteCode] Store type information inside the custom stack (PR #224903)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 05:28:59 PDT 2026
================
@@ -25,15 +25,34 @@ InterpStack::~InterpStack() {
std::free(Chunk->Next);
if (Chunk)
std::free(Chunk);
+
+#if __has_cpp_attribute(no_unique_address)
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+// Clang and GCC complain that `offsetof` isn't allowed on non-standard-layout
+// types. However, it works just fine.
+#pragma GCC diagnostic ignored "-Winvalid-offsetof"
+#endif
+ TYPE_SWITCH(PrimType(), {
+ using Frame = StackFrame<T>;
+ static_assert(offsetof(Frame, type) == sizeof(Frame) - 1);
+ // Currently we don't need to use extra memory to store the type information
+ // for any PrimType on 64 bit platforms. Nothing breaks if this changes, but
+ // it would result in 8 extra bytes used just for the type information.
----------------
tbaederr wrote:
Just to clarify: If that changes, this assertion will fail? And in that case, the assertion should just be removed?
https://github.com/llvm/llvm-project/pull/224903
More information about the cfe-commits
mailing list