1 //===---- ReachingDefAnalysis.cpp - Reaching Def Analysis ---*- C++ -*-----===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "llvm/ADT/SmallSet.h" 10 #include "llvm/CodeGen/LivePhysRegs.h" 11 #include "llvm/CodeGen/ReachingDefAnalysis.h" 12 #include "llvm/CodeGen/TargetRegisterInfo.h" 13 #include "llvm/CodeGen/TargetSubtargetInfo.h" 14 #include "llvm/Support/Debug.h" 15 16 using namespace llvm; 17 18 #define DEBUG_TYPE "reaching-deps-analysis" 19 20 char ReachingDefAnalysis::ID = 0; 21 INITIALIZE_PASS(ReachingDefAnalysis, DEBUG_TYPE, "ReachingDefAnalysis", false, 22 true) 23 24 static bool isValidReg(const MachineOperand &MO) { 25 return MO.isReg() && MO.getReg(); 26 } 27 28 static bool isValidRegUse(const MachineOperand &MO) { 29 return isValidReg(MO) && MO.isUse(); 30 } 31 32 static bool isValidRegUseOf(const MachineOperand &MO, int PhysReg) { 33 return isValidRegUse(MO) && MO.getReg() == PhysReg; 34 } 35 36 static bool isValidRegDef(const MachineOperand &MO) { 37 return isValidReg(MO) && MO.isDef(); 38 } 39 40 static bool isValidRegDefOf(const MachineOperand &MO, int PhysReg) { 41 return isValidRegDef(MO) && MO.getReg() == PhysReg; 42 } 43 44 void ReachingDefAnalysis::enterBasicBlock( 45 const LoopTraversal::TraversedMBBInfo &TraversedMBB) { 46 47 MachineBasicBlock *MBB = TraversedMBB.MBB; 48 unsigned MBBNumber = MBB->getNumber(); 49 assert(MBBNumber < MBBReachingDefs.size() && 50 "Unexpected basic block number."); 51 MBBReachingDefs[MBBNumber].resize(NumRegUnits); 52 53 // Reset instruction counter in each basic block. 54 CurInstr = 0; 55 56 // Set up LiveRegs to represent registers entering MBB. 57 // Default values are 'nothing happened a long time ago'. 58 if (LiveRegs.empty()) 59 LiveRegs.assign(NumRegUnits, ReachingDefDefaultVal); 60 61 // This is the entry block. 62 if (MBB->pred_empty()) { 63 for (const auto &LI : MBB->liveins()) { 64 for (MCRegUnitIterator Unit(LI.PhysReg, TRI); Unit.isValid(); ++Unit) { 65 // Treat function live-ins as if they were defined just before the first 66 // instruction. Usually, function arguments are set up immediately 67 // before the call. 68 if (LiveRegs[*Unit] != -1) { 69 LiveRegs[*Unit] = -1; 70 MBBReachingDefs[MBBNumber][*Unit].push_back(-1); 71 } 72 } 73 } 74 LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n"); 75 return; 76 } 77 78 // Try to coalesce live-out registers from predecessors. 79 for (MachineBasicBlock *pred : MBB->predecessors()) { 80 assert(unsigned(pred->getNumber()) < MBBOutRegsInfos.size() && 81 "Should have pre-allocated MBBInfos for all MBBs"); 82 const LiveRegsDefInfo &Incoming = MBBOutRegsInfos[pred->getNumber()]; 83 // Incoming is null if this is a backedge from a BB 84 // we haven't processed yet 85 if (Incoming.empty()) 86 continue; 87 88 // Find the most recent reaching definition from a predecessor. 89 for (unsigned Unit = 0; Unit != NumRegUnits; ++Unit) 90 LiveRegs[Unit] = std::max(LiveRegs[Unit], Incoming[Unit]); 91 } 92 93 // Insert the most recent reaching definition we found. 94 for (unsigned Unit = 0; Unit != NumRegUnits; ++Unit) 95 if (LiveRegs[Unit] != ReachingDefDefaultVal) 96 MBBReachingDefs[MBBNumber][Unit].push_back(LiveRegs[Unit]); 97 98 LLVM_DEBUG(dbgs() << printMBBReference(*MBB) 99 << (!TraversedMBB.IsDone ? ": incomplete\n" 100 : ": all preds known\n")); 101 } 102 103 void ReachingDefAnalysis::leaveBasicBlock( 104 const LoopTraversal::TraversedMBBInfo &TraversedMBB) { 105 assert(!LiveRegs.empty() && "Must enter basic block first."); 106 unsigned MBBNumber = TraversedMBB.MBB->getNumber(); 107 assert(MBBNumber < MBBOutRegsInfos.size() && 108 "Unexpected basic block number."); 109 // Save register clearances at end of MBB - used by enterBasicBlock(). 110 MBBOutRegsInfos[MBBNumber] = LiveRegs; 111 112 // While processing the basic block, we kept `Def` relative to the start 113 // of the basic block for convenience. However, future use of this information 114 // only cares about the clearance from the end of the block, so adjust 115 // everything to be relative to the end of the basic block. 116 for (int &OutLiveReg : MBBOutRegsInfos[MBBNumber]) 117 if (OutLiveReg != ReachingDefDefaultVal) 118 OutLiveReg -= CurInstr; 119 LiveRegs.clear(); 120 } 121 122 void ReachingDefAnalysis::processDefs(MachineInstr *MI) { 123 assert(!MI->isDebugInstr() && "Won't process debug instructions"); 124 125 unsigned MBBNumber = MI->getParent()->getNumber(); 126 assert(MBBNumber < MBBReachingDefs.size() && 127 "Unexpected basic block number."); 128 129 for (auto &MO : MI->operands()) { 130 if (!isValidRegDef(MO)) 131 continue; 132 for (MCRegUnitIterator Unit(MO.getReg(), TRI); Unit.isValid(); ++Unit) { 133 // This instruction explicitly defines the current reg unit. 134 LLVM_DEBUG(dbgs() << printReg(*Unit, TRI) << ":\t" << CurInstr 135 << '\t' << *MI); 136 137 // How many instructions since this reg unit was last written? 138 if (LiveRegs[*Unit] != CurInstr) { 139 LiveRegs[*Unit] = CurInstr; 140 MBBReachingDefs[MBBNumber][*Unit].push_back(CurInstr); 141 } 142 } 143 } 144 InstIds[MI] = CurInstr; 145 ++CurInstr; 146 } 147 148 void ReachingDefAnalysis::processBasicBlock( 149 const LoopTraversal::TraversedMBBInfo &TraversedMBB) { 150 enterBasicBlock(TraversedMBB); 151 for (MachineInstr &MI : *TraversedMBB.MBB) { 152 if (!MI.isDebugInstr()) 153 processDefs(&MI); 154 } 155 leaveBasicBlock(TraversedMBB); 156 } 157 158 bool ReachingDefAnalysis::runOnMachineFunction(MachineFunction &mf) { 159 MF = &mf; 160 TRI = MF->getSubtarget().getRegisterInfo(); 161 LLVM_DEBUG(dbgs() << "********** REACHING DEFINITION ANALYSIS **********\n"); 162 init(); 163 traverse(); 164 return false; 165 } 166 167 void ReachingDefAnalysis::releaseMemory() { 168 // Clear the internal vectors. 169 MBBOutRegsInfos.clear(); 170 MBBReachingDefs.clear(); 171 InstIds.clear(); 172 LiveRegs.clear(); 173 } 174 175 void ReachingDefAnalysis::reset() { 176 releaseMemory(); 177 init(); 178 traverse(); 179 } 180 181 void ReachingDefAnalysis::init() { 182 NumRegUnits = TRI->getNumRegUnits(); 183 MBBReachingDefs.resize(MF->getNumBlockIDs()); 184 // Initialize the MBBOutRegsInfos 185 MBBOutRegsInfos.resize(MF->getNumBlockIDs()); 186 LoopTraversal Traversal; 187 TraversedMBBOrder = Traversal.traverse(*MF); 188 } 189 190 void ReachingDefAnalysis::traverse() { 191 // Traverse the basic blocks. 192 for (LoopTraversal::TraversedMBBInfo TraversedMBB : TraversedMBBOrder) 193 processBasicBlock(TraversedMBB); 194 // Sorting all reaching defs found for a ceartin reg unit in a given BB. 195 for (MBBDefsInfo &MBBDefs : MBBReachingDefs) { 196 for (MBBRegUnitDefs &RegUnitDefs : MBBDefs) 197 llvm::sort(RegUnitDefs); 198 } 199 } 200 201 int ReachingDefAnalysis::getReachingDef(MachineInstr *MI, int PhysReg) const { 202 assert(InstIds.count(MI) && "Unexpected machine instuction."); 203 int InstId = InstIds.lookup(MI); 204 int DefRes = ReachingDefDefaultVal; 205 unsigned MBBNumber = MI->getParent()->getNumber(); 206 assert(MBBNumber < MBBReachingDefs.size() && 207 "Unexpected basic block number."); 208 int LatestDef = ReachingDefDefaultVal; 209 for (MCRegUnitIterator Unit(PhysReg, TRI); Unit.isValid(); ++Unit) { 210 for (int Def : MBBReachingDefs[MBBNumber][*Unit]) { 211 if (Def >= InstId) 212 break; 213 DefRes = Def; 214 } 215 LatestDef = std::max(LatestDef, DefRes); 216 } 217 return LatestDef; 218 } 219 220 MachineInstr* ReachingDefAnalysis::getReachingLocalMIDef(MachineInstr *MI, 221 int PhysReg) const { 222 return getInstFromId(MI->getParent(), getReachingDef(MI, PhysReg)); 223 } 224 225 bool ReachingDefAnalysis::hasSameReachingDef(MachineInstr *A, MachineInstr *B, 226 int PhysReg) const { 227 MachineBasicBlock *ParentA = A->getParent(); 228 MachineBasicBlock *ParentB = B->getParent(); 229 if (ParentA != ParentB) 230 return false; 231 232 return getReachingDef(A, PhysReg) == getReachingDef(B, PhysReg); 233 } 234 235 MachineInstr *ReachingDefAnalysis::getInstFromId(MachineBasicBlock *MBB, 236 int InstId) const { 237 assert(static_cast<size_t>(MBB->getNumber()) < MBBReachingDefs.size() && 238 "Unexpected basic block number."); 239 assert(InstId < static_cast<int>(MBB->size()) && 240 "Unexpected instruction id."); 241 242 if (InstId < 0) 243 return nullptr; 244 245 for (auto &MI : *MBB) { 246 auto F = InstIds.find(&MI); 247 if (F != InstIds.end() && F->second == InstId) 248 return &MI; 249 } 250 251 return nullptr; 252 } 253 254 int 255 ReachingDefAnalysis::getClearance(MachineInstr *MI, MCPhysReg PhysReg) const { 256 assert(InstIds.count(MI) && "Unexpected machine instuction."); 257 return InstIds.lookup(MI) - getReachingDef(MI, PhysReg); 258 } 259 260 bool 261 ReachingDefAnalysis::hasLocalDefBefore(MachineInstr *MI, int PhysReg) const { 262 return getReachingDef(MI, PhysReg) >= 0; 263 } 264 265 void ReachingDefAnalysis::getReachingLocalUses(MachineInstr *Def, int PhysReg, 266 InstSet &Uses) const { 267 MachineBasicBlock *MBB = Def->getParent(); 268 MachineBasicBlock::iterator MI = MachineBasicBlock::iterator(Def); 269 while (++MI != MBB->end()) { 270 if (MI->isDebugInstr()) 271 continue; 272 273 // If/when we find a new reaching def, we know that there's no more uses 274 // of 'Def'. 275 if (getReachingLocalMIDef(&*MI, PhysReg) != Def) 276 return; 277 278 for (auto &MO : MI->operands()) { 279 if (!isValidRegUseOf(MO, PhysReg)) 280 continue; 281 282 Uses.insert(&*MI); 283 if (MO.isKill()) 284 return; 285 } 286 } 287 } 288 289 bool 290 ReachingDefAnalysis::getLiveInUses(MachineBasicBlock *MBB, int PhysReg, 291 InstSet &Uses) const { 292 for (auto &MI : *MBB) { 293 if (MI.isDebugInstr()) 294 continue; 295 for (auto &MO : MI.operands()) { 296 if (!isValidRegUseOf(MO, PhysReg)) 297 continue; 298 if (getReachingDef(&MI, PhysReg) >= 0) 299 return false; 300 Uses.insert(&MI); 301 } 302 } 303 return isReachingDefLiveOut(&MBB->back(), PhysReg); 304 } 305 306 void 307 ReachingDefAnalysis::getGlobalUses(MachineInstr *MI, int PhysReg, 308 InstSet &Uses) const { 309 MachineBasicBlock *MBB = MI->getParent(); 310 311 // Collect the uses that each def touches within the block. 312 getReachingLocalUses(MI, PhysReg, Uses); 313 314 // Handle live-out values. 315 if (auto *LiveOut = getLocalLiveOutMIDef(MI->getParent(), PhysReg)) { 316 if (LiveOut != MI) 317 return; 318 319 SmallVector<MachineBasicBlock*, 4> ToVisit; 320 ToVisit.insert(ToVisit.begin(), MBB->successors().begin(), 321 MBB->successors().end()); 322 SmallPtrSet<MachineBasicBlock*, 4>Visited; 323 while (!ToVisit.empty()) { 324 MachineBasicBlock *MBB = ToVisit.back(); 325 ToVisit.pop_back(); 326 if (Visited.count(MBB) || !MBB->isLiveIn(PhysReg)) 327 continue; 328 if (getLiveInUses(MBB, PhysReg, Uses)) 329 ToVisit.insert(ToVisit.end(), MBB->successors().begin(), 330 MBB->successors().end()); 331 Visited.insert(MBB); 332 } 333 } 334 } 335 336 void 337 ReachingDefAnalysis::getLiveOuts(MachineBasicBlock *MBB, int PhysReg, 338 InstSet &Defs, BlockSet &VisitedBBs) const { 339 if (VisitedBBs.count(MBB)) 340 return; 341 342 VisitedBBs.insert(MBB); 343 LivePhysRegs LiveRegs(*TRI); 344 LiveRegs.addLiveOuts(*MBB); 345 if (!LiveRegs.contains(PhysReg)) 346 return; 347 348 if (auto *Def = getLocalLiveOutMIDef(MBB, PhysReg)) 349 Defs.insert(Def); 350 else 351 for (auto *Pred : MBB->predecessors()) 352 getLiveOuts(Pred, PhysReg, Defs, VisitedBBs); 353 } 354 355 MachineInstr *ReachingDefAnalysis::getUniqueReachingMIDef(MachineInstr *MI, 356 int PhysReg) const { 357 // If there's a local def before MI, return it. 358 MachineInstr *LocalDef = getReachingLocalMIDef(MI, PhysReg); 359 if (LocalDef && InstIds.lookup(LocalDef) < InstIds.lookup(MI)) 360 return LocalDef; 361 362 SmallPtrSet<MachineBasicBlock*, 4> VisitedBBs; 363 SmallPtrSet<MachineInstr*, 2> Incoming; 364 for (auto *Pred : MI->getParent()->predecessors()) 365 getLiveOuts(Pred, PhysReg, Incoming, VisitedBBs); 366 367 // If we have a local def and an incoming instruction, then there's not a 368 // unique instruction def. 369 if (!Incoming.empty() && LocalDef) 370 return nullptr; 371 else if (Incoming.size() == 1) 372 return *Incoming.begin(); 373 else 374 return LocalDef; 375 } 376 377 MachineInstr *ReachingDefAnalysis::getMIOperand(MachineInstr *MI, 378 unsigned Idx) const { 379 assert(MI->getOperand(Idx).isReg() && "Expected register operand"); 380 return getUniqueReachingMIDef(MI, MI->getOperand(Idx).getReg()); 381 } 382 383 MachineInstr *ReachingDefAnalysis::getMIOperand(MachineInstr *MI, 384 MachineOperand &MO) const { 385 assert(MO.isReg() && "Expected register operand"); 386 return getUniqueReachingMIDef(MI, MO.getReg()); 387 } 388 389 bool ReachingDefAnalysis::isRegUsedAfter(MachineInstr *MI, int PhysReg) const { 390 MachineBasicBlock *MBB = MI->getParent(); 391 LivePhysRegs LiveRegs(*TRI); 392 LiveRegs.addLiveOuts(*MBB); 393 394 // Yes if the register is live out of the basic block. 395 if (LiveRegs.contains(PhysReg)) 396 return true; 397 398 // Walk backwards through the block to see if the register is live at some 399 // point. 400 for (auto Last = MBB->rbegin(), End = MBB->rend(); Last != End; ++Last) { 401 LiveRegs.stepBackward(*Last); 402 if (LiveRegs.contains(PhysReg)) 403 return InstIds.lookup(&*Last) > InstIds.lookup(MI); 404 } 405 return false; 406 } 407 408 bool ReachingDefAnalysis::isRegDefinedAfter(MachineInstr *MI, 409 int PhysReg) const { 410 MachineBasicBlock *MBB = MI->getParent(); 411 if (getReachingDef(MI, PhysReg) != getReachingDef(&MBB->back(), PhysReg)) 412 return true; 413 414 if (auto *Def = getLocalLiveOutMIDef(MBB, PhysReg)) 415 return Def == getReachingLocalMIDef(MI, PhysReg); 416 417 return false; 418 } 419 420 bool 421 ReachingDefAnalysis::isReachingDefLiveOut(MachineInstr *MI, int PhysReg) const { 422 MachineBasicBlock *MBB = MI->getParent(); 423 LivePhysRegs LiveRegs(*TRI); 424 LiveRegs.addLiveOuts(*MBB); 425 if (!LiveRegs.contains(PhysReg)) 426 return false; 427 428 MachineInstr *Last = &MBB->back(); 429 int Def = getReachingDef(MI, PhysReg); 430 if (getReachingDef(Last, PhysReg) != Def) 431 return false; 432 433 // Finally check that the last instruction doesn't redefine the register. 434 for (auto &MO : Last->operands()) 435 if (isValidRegDefOf(MO, PhysReg)) 436 return false; 437 438 return true; 439 } 440 441 MachineInstr* ReachingDefAnalysis::getLocalLiveOutMIDef(MachineBasicBlock *MBB, 442 int PhysReg) const { 443 LivePhysRegs LiveRegs(*TRI); 444 LiveRegs.addLiveOuts(*MBB); 445 if (!LiveRegs.contains(PhysReg)) 446 return nullptr; 447 448 MachineInstr *Last = &MBB->back(); 449 int Def = getReachingDef(Last, PhysReg); 450 for (auto &MO : Last->operands()) 451 if (isValidRegDefOf(MO, PhysReg)) 452 return Last; 453 454 return Def < 0 ? nullptr : getInstFromId(MBB, Def); 455 } 456 457 static bool mayHaveSideEffects(MachineInstr &MI) { 458 return MI.mayLoadOrStore() || MI.mayRaiseFPException() || 459 MI.hasUnmodeledSideEffects() || MI.isTerminator() || 460 MI.isCall() || MI.isBarrier() || MI.isBranch() || MI.isReturn(); 461 } 462 463 // Can we safely move 'From' to just before 'To'? To satisfy this, 'From' must 464 // not define a register that is used by any instructions, after and including, 465 // 'To'. These instructions also must not redefine any of Froms operands. 466 template<typename Iterator> 467 bool ReachingDefAnalysis::isSafeToMove(MachineInstr *From, 468 MachineInstr *To) const { 469 if (From->getParent() != To->getParent()) 470 return false; 471 472 SmallSet<int, 2> Defs; 473 // First check that From would compute the same value if moved. 474 for (auto &MO : From->operands()) { 475 if (!isValidReg(MO)) 476 continue; 477 if (MO.isDef()) 478 Defs.insert(MO.getReg()); 479 else if (!hasSameReachingDef(From, To, MO.getReg())) 480 return false; 481 } 482 483 // Now walk checking that the rest of the instructions will compute the same 484 // value and that we're not overwriting anything. Don't move the instruction 485 // past any memory, control-flow or other ambigious instructions. 486 for (auto I = ++Iterator(From), E = Iterator(To); I != E; ++I) { 487 if (mayHaveSideEffects(*I)) 488 return false; 489 for (auto &MO : I->operands()) 490 if (MO.isReg() && MO.getReg() && Defs.count(MO.getReg())) 491 return false; 492 } 493 return true; 494 } 495 496 bool ReachingDefAnalysis::isSafeToMoveForwards(MachineInstr *From, 497 MachineInstr *To) const { 498 return isSafeToMove<MachineBasicBlock::reverse_iterator>(From, To); 499 } 500 501 bool ReachingDefAnalysis::isSafeToMoveBackwards(MachineInstr *From, 502 MachineInstr *To) const { 503 return isSafeToMove<MachineBasicBlock::iterator>(From, To); 504 } 505 506 bool ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, 507 InstSet &ToRemove) const { 508 SmallPtrSet<MachineInstr*, 1> Ignore; 509 SmallPtrSet<MachineInstr*, 2> Visited; 510 return isSafeToRemove(MI, Visited, ToRemove, Ignore); 511 } 512 513 bool 514 ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &ToRemove, 515 InstSet &Ignore) const { 516 SmallPtrSet<MachineInstr*, 2> Visited; 517 return isSafeToRemove(MI, Visited, ToRemove, Ignore); 518 } 519 520 bool 521 ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &Visited, 522 InstSet &ToRemove, InstSet &Ignore) const { 523 if (Visited.count(MI) || Ignore.count(MI)) 524 return true; 525 else if (mayHaveSideEffects(*MI)) { 526 // Unless told to ignore the instruction, don't remove anything which has 527 // side effects. 528 return false; 529 } 530 531 Visited.insert(MI); 532 for (auto &MO : MI->operands()) { 533 if (!isValidRegDef(MO)) 534 continue; 535 536 SmallPtrSet<MachineInstr*, 4> Uses; 537 getGlobalUses(MI, MO.getReg(), Uses); 538 539 for (auto I : Uses) { 540 if (Ignore.count(I) || ToRemove.count(I)) 541 continue; 542 if (!isSafeToRemove(I, Visited, ToRemove, Ignore)) 543 return false; 544 } 545 } 546 ToRemove.insert(MI); 547 return true; 548 } 549 550 void ReachingDefAnalysis::collectKilledOperands(MachineInstr *MI, 551 InstSet &Dead) const { 552 Dead.insert(MI); 553 auto IsDead = [this, &Dead](MachineInstr *Def, int PhysReg) { 554 unsigned LiveDefs = 0; 555 for (auto &MO : Def->operands()) { 556 if (!isValidRegDef(MO)) 557 continue; 558 if (!MO.isDead()) 559 ++LiveDefs; 560 } 561 562 if (LiveDefs > 1) 563 return false; 564 565 SmallPtrSet<MachineInstr*, 4> Uses; 566 getGlobalUses(Def, PhysReg, Uses); 567 for (auto *Use : Uses) 568 if (!Dead.count(Use)) 569 return false; 570 return true; 571 }; 572 573 for (auto &MO : MI->operands()) { 574 if (!isValidRegUse(MO)) 575 continue; 576 if (MachineInstr *Def = getMIOperand(MI, MO)) 577 if (IsDead(Def, MO.getReg())) 578 collectKilledOperands(Def, Dead); 579 } 580 } 581 582 bool ReachingDefAnalysis::isSafeToDefRegAt(MachineInstr *MI, 583 int PhysReg) const { 584 SmallPtrSet<MachineInstr*, 1> Ignore; 585 return isSafeToDefRegAt(MI, PhysReg, Ignore); 586 } 587 588 bool ReachingDefAnalysis::isSafeToDefRegAt(MachineInstr *MI, int PhysReg, 589 InstSet &Ignore) const { 590 // Check for any uses of the register after MI. 591 if (isRegUsedAfter(MI, PhysReg)) { 592 if (auto *Def = getReachingLocalMIDef(MI, PhysReg)) { 593 SmallPtrSet<MachineInstr*, 2> Uses; 594 getReachingLocalUses(Def, PhysReg, Uses); 595 for (auto *Use : Uses) 596 if (!Ignore.count(Use)) 597 return false; 598 } else 599 return false; 600 } 601 602 MachineBasicBlock *MBB = MI->getParent(); 603 // Check for any defs after MI. 604 if (isRegDefinedAfter(MI, PhysReg)) { 605 auto I = MachineBasicBlock::iterator(MI); 606 for (auto E = MBB->end(); I != E; ++I) { 607 if (Ignore.count(&*I)) 608 continue; 609 for (auto &MO : I->operands()) 610 if (isValidRegDefOf(MO, PhysReg)) 611 return false; 612 } 613 } 614 return true; 615 } 616