[PATCH] D118392: [SCCP][FuncSpec] Switch away from Instruction::isSafeToRemove()

Kevin P. Neal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 09:22:08 PST 2022


kpn created this revision.
kpn added reviewers: nikic, fhahn, sepavloff, spatel, craig.topper, SjoerdMeijer.
Herald added subscribers: snehasish, ormris, hiraditya.
kpn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In D115737 <https://reviews.llvm.org/D115737> I found that I needed to teach Instruction::isSafeToRemove() about strictfp/constrained intrinsics. It was pointed out that this is probably the wrong function to use isInstructionTriviallyDead(). It doesn't make sense to have a "second, worse implementation".

I also believe that the Instruction class is the wrong place for this functionality. The information about whether or not an instruction can be removed is in the transform passes and should stay there.

I do not understand this pass well enough to add constrained support at this time, but this at least gets us away from the problematic API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118392

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
@@ -339,7 +339,7 @@
 
     // Remove the instruction from Block and Solver.
     if (auto *I = dyn_cast<Instruction>(V)) {
-      if (I->isSafeToRemove()) {
+      if (!I->isTerminator()) {
         I->eraseFromParent();
         Solver.removeLatticeValueFor(I);
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118392.403699.patch
Type: text/x-patch
Size: 508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220127/63050fef/attachment.bin>


More information about the llvm-commits mailing list