Skip to content

Commit eb5a79b

Browse files
committed
SIL: Remove the bump pointer allocator for zombie function names from SILModule.
It's not needed because the names are stored in the ZombieFunctionTable anyway (this table was added later).
1 parent 1d62d34 commit eb5a79b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

include/swift/SIL/SILModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ class SILModule {
171171
/// but kept alive for debug info generation.
172172
FunctionListType zombieFunctions;
173173

174-
/// Stores the names of zombie functions.
175-
llvm::BumpPtrAllocator zombieFunctionNames;
176-
177174
/// Lookup table for SIL vtables from class decls.
178175
llvm::DenseMap<const ClassDecl *, SILVTable *> VTableMap;
179176

lib/SIL/IR/SILModule.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,18 +448,23 @@ SILFunction *SILModule::removeFromZombieList(StringRef Name) {
448448
/// Erase a function from the module.
449449
void SILModule::eraseFunction(SILFunction *F) {
450450
assert(!F->isZombie() && "zombie function is in list of alive functions");
451+
452+
llvm::StringMapEntry<SILFunction*> *entry =
453+
&*ZombieFunctionTable.insert(std::make_pair(F->getName(), nullptr)).first;
454+
assert(!entry->getValue() && "Zombie function already exists");
455+
StringRef zombieName = entry->getKey();
456+
451457
// The owner of the function's Name is the FunctionTable key. As we remove
452-
// the function from the table we have to store the name string elsewhere:
453-
// in zombieFunctionNames.
454-
StringRef copiedName = F->getName().copy(zombieFunctionNames);
458+
// the function from the table we need to use the allocated name string from
459+
// the ZombieFunctionTable.
455460
FunctionTable.erase(F->getName());
456-
F->Name = copiedName;
461+
F->Name = zombieName;
457462

458463
// The function is dead, but we need it later (at IRGen) for debug info
459464
// or vtable stub generation. So we move it into the zombie list.
460465
getFunctionList().remove(F);
461466
zombieFunctions.push_back(F);
462-
ZombieFunctionTable[copiedName] = F;
467+
entry->setValue(F);
463468
F->setZombie();
464469

465470
// This opens dead-function-removal opportunities for called functions.

0 commit comments

Comments
 (0)