Author: Timm Baeder Date: 2025-06-17T12:38:02+02:00 New Revision: ce96fdde54c379fa3893f3f07d8233df9e16b9e2
URL: https://github.com/llvm/llvm-project/commit/ce96fdde54c379fa3893f3f07d8233df9e16b9e2 DIFF: https://github.com/llvm/llvm-project/commit/ce96fdde54c379fa3893f3f07d8233df9e16b9e2.diff LOG: [clang][bytecode] Keep the last chunk in InterpStack::clear() (#144487) We call clear when checking for potential constant expressions, but that used to free all the chunks. Keep the last one so we don't have to re-allocate it. Added: Modified: clang/lib/AST/ByteCode/InterpStack.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpStack.cpp b/clang/lib/AST/ByteCode/InterpStack.cpp index b183335dd5884..6b748d62b83bd 100644 --- a/clang/lib/AST/ByteCode/InterpStack.cpp +++ b/clang/lib/AST/ByteCode/InterpStack.cpp @@ -19,9 +19,7 @@ using namespace clang; using namespace clang::interp; -InterpStack::~InterpStack() { clear(); } - -void InterpStack::clear() { +InterpStack::~InterpStack() { if (Chunk && Chunk->Next) std::free(Chunk->Next); if (Chunk) @@ -33,6 +31,21 @@ void InterpStack::clear() { #endif } +// We keep the last chunk around to reuse. +void InterpStack::clear() { + if (!Chunk) + return; + + if (Chunk->Next) + std::free(Chunk->Next); + + assert(Chunk); + StackSize = 0; +#ifndef NDEBUG + ItemTypes.clear(); +#endif +} + void InterpStack::clearTo(size_t NewSize) { assert(NewSize <= size()); size_t ToShrink = size() - NewSize; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits