[PATCH] D118387: [NFC][IPSCCP] Switch away from Instruction::isSafeToRemove()
Kevin P. Neal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 21 10:52:40 PDT 2022
kpn updated this revision to Diff 417028.
kpn retitled this revision from "[IPSCCP] Switch away from Instruction::isSafeToRemove()" to "[NFC][IPSCCP] Switch away from Instruction::isSafeToRemove()".
kpn added a comment.
Herald added a subscriber: StephenFan.
Herald added a project: All.
Rebase. Ping.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118387/new/
https://reviews.llvm.org/D118387
Files:
llvm/lib/Transforms/Scalar/SCCP.cpp
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SCCP.cpp
+++ llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -91,6 +91,13 @@
return !LV.isUnknownOrUndef() && !isConstant(LV);
}
+static bool canSCCPRemoveInstruction(Instruction *I) {
+ if (wouldInstructionBeTriviallyDead(I))
+ return true;
+
+ return (!isa<CallInst>(I) || !I->mayHaveSideEffects()) && !I->isTerminator();
+}
+
static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
Constant *Const = nullptr;
if (V->getType()->isStructTy()) {
@@ -121,7 +128,8 @@
// Calls with "clang.arc.attachedcall" implicitly use the return value and
// those uses cannot be updated with a constant.
CallBase *CB = dyn_cast<CallBase>(V);
- if (CB && ((CB->isMustTailCall() && !CB->isSafeToRemove()) ||
+ if (CB && ((CB->isMustTailCall() &&
+ !canSCCPRemoveInstruction(CB)) ||
CB->getOperandBundle(LLVMContext::OB_clang_arc_attachedcall))) {
Function *F = CB->getCalledFunction();
@@ -150,7 +158,7 @@
if (Inst.getType()->isVoidTy())
continue;
if (tryToReplaceWithConstant(Solver, &Inst)) {
- if (Inst.isSafeToRemove())
+ if (canSCCPRemoveInstruction(&Inst))
Inst.eraseFromParent();
MadeChanges = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118387.417028.patch
Type: text/x-patch
Size: 1345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220321/7576af16/attachment.bin>
More information about the llvm-commits
mailing list