diff options
author | Volkan Keles <vkeles@apple.com> | 2017-03-21 10:47:35 +0000 |
---|---|---|
committer | Volkan Keles <vkeles@apple.com> | 2017-03-21 10:47:35 +0000 |
commit | 47debaeef06baf5ee1994c9fe80f30feb98c0840 (patch) | |
tree | b585fa188f188d6554d5d13676bc3d1b6625fe17 /llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp | |
parent | 54c7680e1fef9dac8acd55f08fb3f46e6caff400 (diff) | |
download | bcm5719-llvm-47debaeef06baf5ee1994c9fe80f30feb98c0840.tar.gz bcm5719-llvm-47debaeef06baf5ee1994c9fe80f30feb98c0840.zip |
[GlobalISel] Move isTriviallyDead to Utils. NFC.
Make it accessible by the targets to avoid code duplication.
llvm-svn: 298358
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp index c59b200298e..69ad59ade08 100644 --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -48,29 +48,6 @@ void InstructionSelect::getAnalysisUsage(AnalysisUsage &AU) const { MachineFunctionPass::getAnalysisUsage(AU); } -/// Check whether an instruction \p MI is dead: it only defines dead virtual -/// registers, and doesn't have other side effects. -static bool isTriviallyDead(const MachineInstr &MI, - const MachineRegisterInfo &MRI) { - // If we can move an instruction, we can remove it. Otherwise, it has - // a side-effect of some sort. - bool SawStore = false; - if (!MI.isSafeToMove(/*AA=*/nullptr, SawStore)) - return false; - - // Instructions without side-effects are dead iff they only define dead vregs. - for (auto &MO : MI.operands()) { - if (!MO.isReg() || !MO.isDef()) - continue; - - unsigned Reg = MO.getReg(); - // Keep Debug uses live: we don't want to have an effect on debug info. - if (TargetRegisterInfo::isPhysicalRegister(Reg) || !MRI.use_empty(Reg)) - return false; - } - return true; -} - bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) { const MachineRegisterInfo &MRI = MF.getRegInfo(); |