-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][bytecode] Save Immediate bit in Function #139671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesOtherwise, we have to look at the FunctionDecl at every function call. Full diff: https://github.com/llvm/llvm-project/pull/139671.diff 3 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Function.cpp b/clang/lib/AST/ByteCode/Function.cpp
index 8a4e089d9ecd0..f790d13738953 100644
--- a/clang/lib/AST/ByteCode/Function.cpp
+++ b/clang/lib/AST/ByteCode/Function.cpp
@@ -26,6 +26,7 @@ Function::Function(Program &P, FunctionDeclTy Source, unsigned ArgSize,
HasRVO(HasRVO) {
if (const auto *F = dyn_cast<const FunctionDecl *>(Source)) {
Variadic = F->isVariadic();
+ Immediate = F->isImmediateFunction();
if (const auto *CD = dyn_cast<CXXConstructorDecl>(F)) {
Virtual = CD->isVirtual();
Kind = FunctionKind::Ctor;
diff --git a/clang/lib/AST/ByteCode/Function.h b/clang/lib/AST/ByteCode/Function.h
index 436574dd3a4c7..c21ac441ad5d5 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -155,6 +155,7 @@ class Function final {
/// Checks if the function is virtual.
bool isVirtual() const { return Virtual; };
+ bool isImmediate() const { return Immediate; }
/// Checks if the function is a constructor.
bool isConstructor() const { return Kind == FunctionKind::Ctor; }
@@ -292,6 +293,7 @@ class Function final {
bool Defined = false;
bool Variadic = false;
bool Virtual = false;
+ bool Immediate = false;
public:
/// Dumps the disassembled bytecode to \c llvm::errs().
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 43f8d156589b6..a13b56c82cb44 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1502,7 +1502,7 @@ bool Call(InterpState &S, CodePtr OpPC, const Function *Func,
InterpFrame *FrameBefore = S.Current;
S.Current = NewFrame.get();
- InterpStateCCOverride CCOverride(S, Func->getDecl()->isImmediateFunction());
+ InterpStateCCOverride CCOverride(S, Func->isImmediate());
// Note that we cannot assert(CallResult.hasValue()) here since
// Ret() above only sets the APValue if the curent frame doesn't
// have a caller set.
|
cor3ntin
approved these changes
May 13, 2025
cor3ntin
reviewed
May 13, 2025
Otherwise, we have to look at the FunctionDecl at every function call.
Actually shrinks the struct from 528 to 520 bytes.
shafik
added a commit
to shafik/llvm-project
that referenced
this pull request
Jun 9, 2025
Static analysis flagged HasBody as not being initialized during construction. It looks like an oversight in: llvm#139671 This would be a lot simpler with C++20 which allows in class initialization of bit-fields.
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Jun 10, 2025
…tructor (#143443) Static analysis flagged HasBody as not being initialized during construction. It looks like an oversight in: llvm/llvm-project#139671 This would be a lot simpler with C++20 which allows in class initialization of bit-fields.
rorth
pushed a commit
to rorth/llvm-project
that referenced
this pull request
Jun 11, 2025
…vm#143443) Static analysis flagged HasBody as not being initialized during construction. It looks like an oversight in: llvm#139671 This would be a lot simpler with C++20 which allows in class initialization of bit-fields.
tomtor
pushed a commit
to tomtor/llvm-project
that referenced
this pull request
Jun 14, 2025
…vm#143443) Static analysis flagged HasBody as not being initialized during construction. It looks like an oversight in: llvm#139671 This would be a lot simpler with C++20 which allows in class initialization of bit-fields.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:bytecode
Issues for the clang bytecode constexpr interpreter
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
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.
Otherwise, we have to look at the FunctionDecl at every function call.