[clang][bytecode] Remove InterpFrame::ThisPointerOffset#202322
Merged
Conversation
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesReplace it with a Full diff: https://github.com/llvm/llvm-project/pull/202322.diff 2 Files Affected:
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
|
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
carlobertolli
pushed a commit
to carlobertolli/llvm-project
that referenced
this pull request
Jun 11, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace it with a
uint8_trepresenting some bool flags about the function. This reduces the size of a frame from 88 to 80 bytes.