[clang] 27d730b - [clang][bytecode] Create InterpState allocator on demand (#158802)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 16 02:00:57 PDT 2025
Author: Timm Baeder
Date: 2025-09-16T11:00:53+02:00
New Revision: 27d730b5dbde03d9b9c1074092e94d025c70099f
URL: https://github.com/llvm/llvm-project/commit/27d730b5dbde03d9b9c1074092e94d025c70099f
DIFF: https://github.com/llvm/llvm-project/commit/27d730b5dbde03d9b9c1074092e94d025c70099f.diff
LOG: [clang][bytecode] Create InterpState allocator on demand (#158802)
We often don't need it (especially in C), so make this optional and
create it only when we first allocate something.
Added:
Modified:
clang/lib/AST/ByteCode/InterpState.h
Removed:
################################################################################
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 {
More information about the cfe-commits
mailing list