[llvm] dfec0b3 - [FuncSpec] Save compilation time by caching uses for propagation
Bin Cheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 15 18:46:48 PST 2022
Author: Bin Cheng
Date: 2022-02-16T10:46:26+08:00
New Revision: dfec0b3053b9d433fa3770ff31bc540406db4ba8
URL: https://github.com/llvm/llvm-project/commit/dfec0b3053b9d433fa3770ff31bc540406db4ba8
DIFF: https://github.com/llvm/llvm-project/commit/dfec0b3053b9d433fa3770ff31bc540406db4ba8.diff
LOG: [FuncSpec] Save compilation time by caching uses for propagation
We only need to do propagation on use instructions of the original
value, rather than the replacing const value which might have lots
of irrelavant uses. This is done by caching uses before replacing.
Differential Revision: https://reviews.llvm.org/D119815
Added:
Modified:
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 9b6246b380bf6..832fa468dd3f9 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -344,12 +344,17 @@ class FunctionSpecializer {
LLVM_DEBUG(dbgs() << "FnSpecialization: Replacing " << *V
<< "\nFnSpecialization: with " << *Const << "\n");
- V->replaceAllUsesWith(Const);
-
- for (auto *U : Const->users())
+ // Record uses of V to avoid visiting irrelevant uses of const later.
+ SmallVector<Instruction *> UseInsts;
+ for (auto *U : V->users())
if (auto *I = dyn_cast<Instruction>(U))
if (Solver.isBlockExecutable(I->getParent()))
- Solver.visit(I);
+ UseInsts.push_back(I);
+
+ V->replaceAllUsesWith(Const);
+
+ for (auto *I : UseInsts)
+ Solver.visit(I);
// Remove the instruction from Block and Solver.
if (auto *I = dyn_cast<Instruction>(V)) {
More information about the llvm-commits
mailing list