[PATCH] D111661: [FuncSpec] Only visit uses of the instruction instead of every constant use.

duk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 13 04:49:17 PDT 2021


duck-37 updated this revision to Diff 379341.
duck-37 added a comment.

Visit with SCCPSolver after replacing users.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111661/new/

https://reviews.llvm.org/D111661

Files:
  llvm/lib/Transforms/IPO/FunctionSpecialization.cpp


Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -305,12 +305,15 @@
 
     // Using replaceUsesWithIf is probably the easiest way to do this without
     // duplicating code.
+    SmallVector<Instruction *, 8> ReplacedUsers;
     V->replaceUsesWithIf(Const, [&](auto &U) {
       if (auto *I = dyn_cast<Instruction>(U.getUser()))
         if (Solver.isBlockExecutable(I->getParent()))
-          Solver.visit(I);
+          ReplacedUsers.push_back(I);
       return true;
     });
+    for (auto *I : ReplacedUsers)
+      Solver.visit(I);
 
     // Remove the instruction from Block and Solver.
     if (auto *I = dyn_cast<Instruction>(V)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111661.379341.patch
Type: text/x-patch
Size: 833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/9a4fb4ea/attachment-0001.bin>


More information about the llvm-commits mailing list