diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index a0f4040..0d78c2ca 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -1323,6 +1323,28 @@ 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; + + // Don't delete FAKE_USE. + // FIXME: Why is FAKE_USE not considered in MachineInstr::isPosition? + if (isFakeUse()) + 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; + return isPHI() || isSafeToMove(SawStore); +} + static bool MemOperandsHaveAlias(const MachineFrameInfo &MFI, AAResults *AA, bool UseTBAA, const MachineMemOperand *MMOa, const MachineMemOperand *MMOb) { |