[llvm] fe827a9 - [ModuleInliner] Properly delete dead functions
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 12 09:57:58 PST 2022
Author: Arthur Eubanks
Date: 2022-01-12T09:57:43-08:00
New Revision: fe827a93f69ddea80308d63a6b54b17106779354
URL: https://github.com/llvm/llvm-project/commit/fe827a93f69ddea80308d63a6b54b17106779354
DIFF: https://github.com/llvm/llvm-project/commit/fe827a93f69ddea80308d63a6b54b17106779354.diff
LOG: [ModuleInliner] Properly delete dead functions
Followup to D116964 where we only did this in the CGSCC inliner.
Fixes leaks reported in D116964.
Added:
Modified:
llvm/lib/Transforms/IPO/ModuleInliner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/ModuleInliner.cpp b/llvm/lib/Transforms/IPO/ModuleInliner.cpp
index ebf080e87c3b6..d515303e4911b 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;
}
More information about the llvm-commits
mailing list