https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/202322
Replace it with a `uint8_t` representing some bool flags about the function. This reduces the size of a frame from 88 to 80 bytes. >From 3aa88a9ef2b44e0ac59db6f59b3d31abf3336ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Mon, 8 Jun 2026 13:09:37 +0200 Subject: [PATCH] FuncFlags --- clang/lib/AST/ByteCode/InterpFrame.cpp | 10 ++++------ clang/lib/AST/ByteCode/InterpFrame.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp index 9c9318fe0e55a..98bd897445cad 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.cpp +++ b/clang/lib/AST/ByteCode/InterpFrame.cpp @@ -35,6 +35,10 @@ InterpFrame::InterpFrame(InterpState &S, const Function *Func, if (!Func) return; + + FuncFlags |= Func->hasRVO() * HasRVOFlag; + FuncFlags |= Func->hasThisPointer() * HasThisFlag; + // Initialize argument blocks. for (unsigned I = 0, N = Func->getNumWrittenParams(); I != N; ++I) new (argBlock(I)) Block(S.EvalID, Func->getParamDescriptor(I).Desc); @@ -61,12 +65,6 @@ InterpFrame::InterpFrame(InterpState &S, const Function *Func, CodePtr RetPC, // If the fuction has a This pointer, that one is next. // Then follow the actual arguments (but those are handled // in getParamPointer()). - if (Func->hasRVO()) { - // RVO pointer offset is always 0. - } - - if (Func->hasThisPointer()) - ThisPointerOffset = Func->hasRVO() ? sizeof(Pointer) : 0; } InterpFrame::~InterpFrame() { diff --git a/clang/lib/AST/ByteCode/InterpFrame.h b/clang/lib/AST/ByteCode/InterpFrame.h index 7dbf58c23fd5c..64bbb87d7a6fe 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.h +++ b/clang/lib/AST/ByteCode/InterpFrame.h @@ -127,13 +127,13 @@ class InterpFrame final : public Frame { /// Returns a pointer to an argument - lazily creates a block. Pointer getParamPointer(unsigned Offset); - bool hasThisPointer() const { return Func && Func->hasThisPointer(); } + bool hasThisPointer() const { return FuncFlags & HasThisFlag; } /// Returns the 'this' pointer. const Pointer &getThis() const { assert(hasThisPointer()); assert(!isBottomFrame()); - return stackRef<Pointer>(ThisPointerOffset); + return stackRef<Pointer>((FuncFlags & HasRVOFlag) ? sizeof(Pointer) : 0); } /// Returns the RVO pointer, if the Function has one. @@ -169,6 +169,9 @@ class InterpFrame final : public Frame { void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const; private: + static constexpr uint8_t HasRVOFlag = 1u << 0u; + static constexpr uint8_t HasThisFlag = 1u << 1u; + /// Returns an original argument from the stack. template <typename T> const T &stackRef(unsigned Offset) const { assert(Args); @@ -215,8 +218,6 @@ class InterpFrame final : public Frame { unsigned Depth; /// Reference to the function being executed. const Function *Func; - /// Offset of the instance pointer. Use with stackRef<>(). - unsigned ThisPointerOffset; /// Return address. CodePtr RetPC; /// The size of all the arguments. @@ -228,6 +229,10 @@ class InterpFrame final : public Frame { public: unsigned MSVCConstexprAllowed = 0; + +private: + /// Relevant flags about the function. + uint8_t FuncFlags = 0; }; } // namespace interp _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
