[llvm] [CodeGen] Refactor DeadMIElim isDead and GISel isTriviallyDead (PR #105956)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 10:10:48 PDT 2024
================
@@ -1323,6 +1323,26 @@ bool MachineInstr::isSafeToMove(bool &SawStore) const {
return true;
}
+bool MachineInstr::wouldBeTriviallyDead() const {
+ // Don't delete frame allocation labels.
+ // FIXME: Why is LOCAL_ESCAPE not considered in MachineInstr::isLabel?
+ if (getOpcode() == TargetOpcode::LOCAL_ESCAPE)
+ return false;
+
+ // LIFETIME markers should be preserved.
+ // FIXME: Why are LIFETIME markers not considered in MachineInstr::isPosition?
+ if (isLifetimeMarker())
+ return false;
+
+ // If we can move an instruction, we can remove it. Otherwise, it has
+ // a side-effect of some sort.
+ bool SawStore = false;
+ if (!isSafeToMove(SawStore) && !isPHI())
+ return false;
+
+ return true;
----------------
arsenm wrote:
fold to return of bool expression?
https://github.com/llvm/llvm-project/pull/105956
More information about the llvm-commits
mailing list