llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

They have the same lifetime, so might as well use the existing allocator.

---
Full diff: https://github.com/llvm/llvm-project/pull/220922.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+6-14) 
- (modified) clang/lib/AST/ByteCode/EvalEmitter.h (+2-4) 


``````````diff
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();

``````````

</details>


https://github.com/llvm/llvm-project/pull/220922
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to