SIL: fix a memory leak, related to zombie functions

The leak happened in this scenario:
1. A function becomes dead and gets deleted (which means: it gets added to the zombie-list)
2. A function with the same name is created again. This can happen with specializations.

In such a case we just removed the zombie function from the zombie-list without deleting it.
But we cannot delete zombie functions, because they might still be referenced by metadata, like debug-info.

Therefore the right fix is to resurrect the zombie function if a new function is created with the same name.

rdar://problem/66931238
This commit is contained in:
Erik Eckstein
2020-09-10 14:51:40 +02:00
parent e9650cf4cb
commit 1d62d3481c
4 changed files with 92 additions and 38 deletions

View File

@@ -340,7 +340,7 @@ public:
/// Specialization can cause a function that was erased before by dead function
/// elimination to become alive again. If this happens we need to remove it
/// from the list of zombies.
void removeFromZombieList(StringRef Name);
SILFunction *removeFromZombieList(StringRef Name);
/// Erase a global SIL variable from the module.
void eraseGlobalVariable(SILGlobalVariable *G);