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