https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/158802
We often don't need it (especially in C), so make this optional and create it only when we first allocate something. >From 6e55ce4b529cdb1e42fd5703cc946118ed84844d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 16 Sep 2025 08:07:41 +0200 Subject: [PATCH] [clang][bytecode] Create InterpState allocator on demand We often don't need it (especially in C), so make this optional and create it only when we first allocate something. --- clang/lib/AST/ByteCode/InterpState.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpState.h b/clang/lib/AST/ByteCode/InterpState.h index e095908bce986..4e1b9aec09099 100644 --- a/clang/lib/AST/ByteCode/InterpState.h +++ b/clang/lib/AST/ByteCode/InterpState.h @@ -122,7 +122,9 @@ class InterpState final : public State, public SourceMapper { StdAllocatorCaller getStdAllocatorCaller(StringRef Name) const; void *allocate(size_t Size, unsigned Align = 8) const { - return Allocator.Allocate(Size, Align); + if (!Allocator) + Allocator.emplace(); + return Allocator->Allocate(Size, Align); } template <typename T> T *allocate(size_t Num = 1) const { return static_cast<T *>(allocate(Num * sizeof(T), alignof(T))); @@ -188,7 +190,7 @@ class InterpState final : public State, public SourceMapper { /// for. llvm::SmallVector<const Block *> InitializingBlocks; - mutable llvm::BumpPtrAllocator Allocator; + mutable std::optional<llvm::BumpPtrAllocator> Allocator; }; class InterpStateCCOverride final { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
