[clang] 576ced5 - [clang][bytecode] Simplify Block::replacePointer() (#144490)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 03:43:42 PDT 2025
Author: Timm Baeder
Date: 2025-06-17T12:43:39+02:00
New Revision: 576ced56d78b48e658b0a170603388e4802f6311
URL: https://github.com/llvm/llvm-project/commit/576ced56d78b48e658b0a170603388e4802f6311
DIFF: https://github.com/llvm/llvm-project/commit/576ced56d78b48e658b0a170603388e4802f6311.diff
LOG: [clang][bytecode] Simplify Block::replacePointer() (#144490)
Try to do less work here instead of a full remove + add.
Added:
Modified:
clang/lib/AST/ByteCode/InterpBlock.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/InterpBlock.cpp b/clang/lib/AST/ByteCode/InterpBlock.cpp
index 9ef44cd29ff87..f60307870ffcc 100644
--- a/clang/lib/AST/ByteCode/InterpBlock.cpp
+++ b/clang/lib/AST/ByteCode/InterpBlock.cpp
@@ -69,20 +69,26 @@ void Block::cleanup() {
void Block::replacePointer(Pointer *Old, Pointer *New) {
assert(Old);
assert(New);
+ assert(Old != New);
if (IsStatic) {
assert(!Pointers);
return;
}
-
#ifndef NDEBUG
assert(hasPointer(Old));
#endif
- removePointer(Old);
- addPointer(New);
+ if (Old->Prev)
+ Old->Prev->Next = New;
+ if (Old->Next)
+ Old->Next->Prev = New;
+ New->Prev = Old->Prev;
+ New->Next = Old->Next;
+ if (Pointers == Old)
+ Pointers = New;
Old->PointeeStorage.BS.Pointee = nullptr;
-
+ New->PointeeStorage.BS.Pointee = this;
#ifndef NDEBUG
assert(!hasPointer(Old));
assert(hasPointer(New));
More information about the cfe-commits
mailing list