summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorGerolf Hoflehner <ghoflehner@apple.com>2014-08-13 21:15:23 +0000
committerGerolf Hoflehner <ghoflehner@apple.com>2014-08-13 21:15:23 +0000
commitcaa8bfd13b8e0477d5c5256170408ac24cd2e1e5 (patch)
tree276dfd625c2666e999e6e5b304bbf9aa0da3e6fe /llvm/lib/CodeGen/MachineInstr.cpp
parentc9cbde7e8be50c51ce3ae4dad19aef1578a826fe (diff)
downloadbcm5719-llvm-caa8bfd13b8e0477d5c5256170408ac24cd2e1e5.tar.gz
bcm5719-llvm-caa8bfd13b8e0477d5c5256170408ac24cd2e1e5.zip
[Cleanup] Utility function to erase instruction and mark DBG_Values
New function to erase a machine instruction and mark DBG_VALUE for removal. A DBG_VALUE is marked for removal when it references an operand defined in the instruction. Use the new function to cleanup code in dead machine instruction removal pass. llvm-svn: 215580
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 06af6f88d92..ad58cf39bac 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -895,6 +895,27 @@ void MachineInstr::eraseFromParent() {
getParent()->erase(this);
}
+void MachineInstr::eraseFromParentAndMarkDBGValuesForRemoval() {
+ assert(getParent() && "Not embedded in a basic block!");
+ MachineBasicBlock *MBB = getParent();
+ MachineFunction *MF = MBB->getParent();
+ assert(MF && "Not embedded in a function!");
+
+ MachineInstr *MI = (MachineInstr *)this;
+ MachineRegisterInfo &MRI = MF->getRegInfo();
+
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = MI->getOperand(i);
+ if (!MO.isReg() || !MO.isDef())
+ continue;
+ unsigned Reg = MO.getReg();
+ if (!TargetRegisterInfo::isVirtualRegister(Reg))
+ continue;
+ MRI.markUsesInDebugValueAsUndef(Reg);
+ }
+ MI->eraseFromParent();
+}
+
void MachineInstr::eraseFromBundle() {
assert(getParent() && "Not embedded in a basic block!");
getParent()->erase_instr(this);
OpenPOWER on IntegriCloud