MachineInstr &InsertPt, const MCInstrDesc &II,
unsigned Reg, unsigned OpIdx);
+/// Check whether an instruction \p MI is dead: it only defines dead virtual
+/// registers, and doesn't have other side effects.
+bool isTriviallyDead(const MachineInstr &MI, const MachineRegisterInfo &MRI);
+
/// Report an ISel error as a missed optimization remark to the LLVMContext's
/// diagnostic stream. Set the FailedISel MachineFunction property.
void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
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();
return Reg;
}
+bool llvm::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;
+}
+
void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
MachineOptimizationRemarkEmitter &MORE,
MachineOptimizationRemarkMissed &R) {