diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2020-01-02 16:53:37 -0600 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2020-01-03 10:43:40 -0600 |
| commit | 6b9ee2d6cd9fc3534bb9d7e1582c57f1857e411b (patch) | |
| tree | 6ca3af68d95e9cdd4eb8163ba4e8d44aa13572d6 | |
| parent | c90681b681a7a45cf5bf515d1904e2015f7ed524 (diff) | |
| download | bcm5719-llvm-6b9ee2d6cd9fc3534bb9d7e1582c57f1857e411b.tar.gz bcm5719-llvm-6b9ee2d6cd9fc3534bb9d7e1582c57f1857e411b.zip | |
[Attributor][NFC] Unify the way we delete dead functions
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 46664d62769..a8d7eb35b98 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -5695,13 +5695,6 @@ ChangeStatus Attributor::run(Module &M) { BUILD_STAT_NAME(AAIsDead, BasicBlock) += ToBeDeletedBlocks.size(); } - STATS_DECL(AAIsDead, Function, "Number of dead functions deleted."); - for (Function *Fn : ToBeDeletedFunctions) { - Fn->replaceAllUsesWith(UndefValue::get(Fn->getType())); - Fn->eraseFromParent(); - STATS_TRACK(AAIsDead, Function); - } - // Identify dead internal functions and delete them. This happens outside // the other fixpoint analysis as we might treat potentially dead functions // as live to lower the number of iterations. If they happen to be dead, the @@ -5719,15 +5712,15 @@ ChangeStatus Attributor::run(Module &M) { if (!F) continue; - if (!checkForAllCallSites([](AbstractCallSite ACS) { return false; }, - *F, true, nullptr)) + if (!checkForAllCallSites( + [this](AbstractCallSite ACS) { + return ToBeDeletedFunctions.count( + ACS.getInstruction()->getFunction()); + }, + *F, true, nullptr)) continue; - STATS_TRACK(AAIsDead, Function); ToBeDeletedFunctions.insert(F); - F->deleteBody(); - F->replaceAllUsesWith(UndefValue::get(F->getType())); - F->eraseFromParent(); InternalFns[u] = nullptr; FoundDeadFn = true; } @@ -5737,6 +5730,14 @@ ChangeStatus Attributor::run(Module &M) { // Rewrite the functions as requested during manifest. ManifestChange = ManifestChange | rewriteFunctionSignatures(); + STATS_DECL(AAIsDead, Function, "Number of dead functions deleted."); + BUILD_STAT_NAME(AAIsDead, Function) += ToBeDeletedFunctions.size(); + for (Function *Fn : ToBeDeletedFunctions) { + Fn->deleteBody(); + Fn->replaceAllUsesWith(UndefValue::get(Fn->getType())); + Fn->eraseFromParent(); + } + if (VerifyMaxFixpointIterations && IterationCounter != MaxFixpointIterations) { errs() << "\n[Attributor] Fixpoint iteration done after: " |

