[clang] faf31b0 - [clang][bytecode] Allocate EvalEmitter locals using InterpState allocator (#220922)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 20:36:43 PDT 2026
Author: Timm Baeder
Date: 2026-09-04T05:36:38+02:00
New Revision: faf31b04449c2592100d9693acf882c751de6519
URL: https://github.com/llvm/llvm-project/commit/faf31b04449c2592100d9693acf882c751de6519
DIFF: https://github.com/llvm/llvm-project/commit/faf31b04449c2592100d9693acf882c751de6519.diff
LOG: [clang][bytecode] Allocate EvalEmitter locals using InterpState allocator (#220922)
They have the same lifetime, so might as well use the existing
allocator.
Added:
Modified:
clang/lib/AST/ByteCode/EvalEmitter.cpp
clang/lib/AST/ByteCode/EvalEmitter.h
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 80eb593c2f6c4..93b332cda6e19 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -21,14 +21,6 @@ EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State &Parent,
InterpStack &Stk)
: Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {}
-EvalEmitter::~EvalEmitter() {
- for (auto &V : Locals) {
- Block *B = reinterpret_cast<Block *>(V.get());
- if (B->isInitialized())
- B->invokeDtor();
- }
-}
-
/// Clean up all our resources. This needs to done in failed evaluations before
/// we call InterpStack::clear(), because there might be a Pointer on the stack
/// pointing into a Block in the EvalEmitter.
@@ -151,11 +143,11 @@ EvalEmitter::LabelTy EvalEmitter::getLabel() { return NextLabel++; }
Scope::Local EvalEmitter::createLocal(const Descriptor *D) {
// Allocate memory for a local.
- auto Memory = std::make_unique<char[]>(sizeof(Block) + D->getAllocSize() +
- Block::InlineDescMD);
- auto *B = new (Memory.get()) Block(Ctx.getEvalID(), D, Block::InlineDescMD,
- /*IsStatic=*/false);
- B->invokeCtorNoMemset();
+ char *Memory = reinterpret_cast<char *>(
+ S.allocate(sizeof(Block) + D->getAllocSize() + Block::InlineDescMD));
+ auto *B = new (Memory) Block(Ctx.getEvalID(), D, Block::InlineDescMD,
+ /*IsStatic=*/false);
+ B->invokeCtor();
// Initialize local variable inline descriptor.
auto &Desc = B->getBlockDesc<InlineDescriptor>();
@@ -169,7 +161,7 @@ Scope::Local EvalEmitter::createLocal(const Descriptor *D) {
// Register the local.
unsigned Off = Locals.size();
- Locals.push_back(std::move(Memory));
+ Locals.push_back(Memory);
return {D, Off};
}
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h
index a80b573a7df8b..4f02f796097aa 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -63,8 +63,6 @@ class EvalEmitter : public SourceMapper {
protected:
EvalEmitter(Context &Ctx, Program &P, State &Parent, InterpStack &Stk);
- virtual ~EvalEmitter();
-
/// Define a label.
void emitLabel(LabelTy Label);
/// Create a label.
@@ -126,11 +124,11 @@ class EvalEmitter : public SourceMapper {
std::optional<PtrCallback> PtrCB;
/// Temporaries which require storage.
- llvm::SmallVector<std::unique_ptr<char[]>> Locals;
+ llvm::SmallVector<char *> Locals;
Block *getLocal(unsigned Index) const {
assert(Index < Locals.size());
- return reinterpret_cast<Block *>(Locals[Index].get());
+ return reinterpret_cast<Block *>(Locals[Index]);
}
void updateGlobalTemporaries();
More information about the cfe-commits
mailing list