- Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][bytecode] Create InterpState allocator on demand #158802
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
Conversation
We often don't need it (especially in C), so make this optional and create it only when we first allocate something.
| @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesWe often don't need it (especially in C), so make this optional and create it only when we first allocate something. Full diff: https://github.com/llvm/llvm-project/pull/158802.diff 1 Files Affected:
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 { |
| LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/13563 Here is the relevant piece of the build log for the reference |
We often don't need it (especially in C), so make this optional and create it only when we first allocate something.