summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2022-01-12 09:55:16 -0800
committerArthur Eubanks <aeubanks@google.com>2022-01-12 09:57:43 -0800
commitfe827a93f69ddea80308d63a6b54b17106779354 (patch)
treea7c7c83afd18de3ac12ed06cb6cc6d20a00efe64
parent3a32d2e74e5c03d97a41ef7b0a01f206af62ad4f (diff)
[ModuleInliner] Properly delete dead functions
Followup to D116964 where we only did this in the CGSCC inliner. Fixes leaks reported in D116964.
-rw-r--r--llvm/lib/Transforms/IPO/ModuleInliner.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/ModuleInliner.cpp b/llvm/lib/Transforms/IPO/ModuleInliner.cpp
index ebf080e87c3b..d515303e4911 100644
--- a/llvm/lib/Transforms/IPO/ModuleInliner.cpp
+++ b/llvm/lib/Transforms/IPO/ModuleInliner.cpp
@@ -335,14 +335,7 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,
FAM.clear(*DeadF, DeadF->getName());
// And delete the actual function from the module.
- // The Advisor may use Function pointers to efficiently index various
- // internal maps, e.g. for memoization. Function cleanup passes like
- // argument promotion create new functions. It is possible for a new
- // function to be allocated at the address of a deleted function. We could
- // index using names, but that's inefficient. Alternatively, we let the
- // Advisor free the functions when it sees fit.
- DeadF->getBasicBlockList().clear();
- M.getFunctionList().remove(DeadF);
+ M.getFunctionList().erase(DeadF);
++NumDeleted;
}