[clang] [Clang][ByteCode] Store type information inside the custom stack (PR #224903)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 05:38:22 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.
----------------
philnik777 wrote:
Yes, exactly. This is simply here to make sure it's a conscious decision to not have tail padding somewhere and not just someone thinking "it really doesn't matter where the padding is - it's unused anyway".
https://github.com/llvm/llvm-project/pull/224903
More information about the cfe-commits
mailing list