diff options
Diffstat (limited to 'llvm/lib/CodeGen/ReachingDefAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ReachingDefAnalysis.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp index 5f0b4a9..a1c0c21 100644 --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -33,10 +33,6 @@ bool isValidRegUseOf(const MachineOperand &MO, int PhysReg) { return isValidRegUse(MO) && MO.getReg() == PhysReg; } -bool isKilledRegUse(const MachineOperand &MO) { - return isValidRegUse(MO) && MO.isKill(); -} - bool isValidRegDef(const MachineOperand &MO) { return isValidReg(MO) && MO.isDef(); } @@ -353,7 +349,7 @@ MachineInstr *ReachingDefAnalysis::getUniqueReachingMIDef(MachineInstr *MI, int PhysReg) const { // If there's a local def before MI, return it. MachineInstr *LocalDef = getReachingLocalMIDef(MI, PhysReg); - if (InstIds.lookup(LocalDef) < InstIds.lookup(MI)) + if (LocalDef && InstIds.lookup(LocalDef) < InstIds.lookup(MI)) return LocalDef; SmallPtrSet<MachineBasicBlock*, 4> VisitedBBs; @@ -544,8 +540,8 @@ ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &Visited, return true; } -void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, - InstSet &Dead) const { +void ReachingDefAnalysis::collectKilledOperands(MachineInstr *MI, + InstSet &Dead) const { Dead.insert(MI); auto IsDead = [this, &Dead](MachineInstr *Def, int PhysReg) { unsigned LiveDefs = 0; @@ -568,11 +564,11 @@ void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, }; for (auto &MO : MI->operands()) { - if (!isKilledRegUse(MO)) + if (!isValidRegUse(MO)) continue; - if (MachineInstr *Def = getReachingLocalMIDef(MI, MO.getReg())) + if (MachineInstr *Def = getMIOperand(MI, MO)) if (IsDead(Def, MO.getReg())) - collectLocalKilledOperands(Def, Dead); + collectKilledOperands(Def, Dead); } } |