LCOV - code coverage report
Current view: top level - lib/CodeGen - MachineBasicBlock.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 494 592 83.4 %
Date: 2018-07-13 00:08:38 Functions: 66 71 93.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/CodeGen/MachineBasicBlock.cpp ----------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // Collect the sequence of machine instructions for a basic block.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/CodeGen/MachineBasicBlock.h"
      15             : #include "llvm/ADT/SmallPtrSet.h"
      16             : #include "llvm/CodeGen/LiveIntervals.h"
      17             : #include "llvm/CodeGen/LiveVariables.h"
      18             : #include "llvm/CodeGen/MachineDominators.h"
      19             : #include "llvm/CodeGen/MachineFunction.h"
      20             : #include "llvm/CodeGen/MachineInstrBuilder.h"
      21             : #include "llvm/CodeGen/MachineLoopInfo.h"
      22             : #include "llvm/CodeGen/MachineRegisterInfo.h"
      23             : #include "llvm/CodeGen/SlotIndexes.h"
      24             : #include "llvm/CodeGen/TargetInstrInfo.h"
      25             : #include "llvm/CodeGen/TargetRegisterInfo.h"
      26             : #include "llvm/CodeGen/TargetSubtargetInfo.h"
      27             : #include "llvm/Config/llvm-config.h"
      28             : #include "llvm/IR/BasicBlock.h"
      29             : #include "llvm/IR/DataLayout.h"
      30             : #include "llvm/IR/DebugInfoMetadata.h"
      31             : #include "llvm/IR/ModuleSlotTracker.h"
      32             : #include "llvm/MC/MCAsmInfo.h"
      33             : #include "llvm/MC/MCContext.h"
      34             : #include "llvm/Support/DataTypes.h"
      35             : #include "llvm/Support/Debug.h"
      36             : #include "llvm/Support/raw_ostream.h"
      37             : #include "llvm/Target/TargetMachine.h"
      38             : #include <algorithm>
      39             : using namespace llvm;
      40             : 
      41             : #define DEBUG_TYPE "codegen"
      42             : 
      43      446076 : MachineBasicBlock::MachineBasicBlock(MachineFunction &MF, const BasicBlock *B)
      44      892152 :     : BB(B), Number(-1), xParent(&MF) {
      45      446076 :   Insts.Parent = this;
      46      446076 :   if (B)
      47      865660 :     IrrLoopHeaderWeight = B->getIrrLoopHeaderWeight();
      48      446076 : }
      49             : 
      50      891834 : MachineBasicBlock::~MachineBasicBlock() {
      51      445917 : }
      52             : 
      53             : /// Return the MCSymbol for this basic block.
      54      240888 : MCSymbol *MachineBasicBlock::getSymbol() const {
      55      240888 :   if (!CachedMCSymbol) {
      56      123301 :     const MachineFunction *MF = getParent();
      57      123301 :     MCContext &Ctx = MF->getContext();
      58      123301 :     auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();
      59             :     assert(getNumber() >= 0 && "cannot get label for unreachable MBB");
      60      246602 :     CachedMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB" +
      61      369903 :                                            Twine(MF->getFunctionNumber()) +
      62      369903 :                                            "_" + Twine(getNumber()));
      63             :   }
      64             : 
      65      240888 :   return CachedMCSymbol;
      66             : }
      67             : 
      68             : 
      69           0 : raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
      70           0 :   MBB.print(OS);
      71           0 :   return OS;
      72             : }
      73             : 
      74       84421 : Printable llvm::printMBBReference(const MachineBasicBlock &MBB) {
      75      168842 :   return Printable([&MBB](raw_ostream &OS) { return MBB.printAsOperand(OS); });
      76             : }
      77             : 
      78             : /// When an MBB is added to an MF, we need to update the parent pointer of the
      79             : /// MBB, the MBB numbering, and any instructions in the MBB to be on the right
      80             : /// operand list for registers.
      81             : ///
      82             : /// MBBs start out as #-1. When a MBB is added to a MachineFunction, it
      83             : /// gets the next available unique MBB number. If it is removed from a
      84             : /// MachineFunction, it goes back to being #-1.
      85      446073 : void ilist_callback_traits<MachineBasicBlock>::addNodeToList(
      86             :     MachineBasicBlock *N) {
      87      446073 :   MachineFunction &MF = *N->getParent();
      88      446073 :   N->Number = MF.addToMBBNumbering(N);
      89             : 
      90             :   // Make sure the instructions have their operands in the reginfo lists.
      91      446073 :   MachineRegisterInfo &RegInfo = MF.getRegInfo();
      92             :   for (MachineBasicBlock::instr_iterator
      93      446171 :          I = N->instr_begin(), E = N->instr_end(); I != E; ++I)
      94          98 :     I->AddRegOperandsToUseLists(RegInfo);
      95      446073 : }
      96             : 
      97      445917 : void ilist_callback_traits<MachineBasicBlock>::removeNodeFromList(
      98             :     MachineBasicBlock *N) {
      99      445917 :   N->getParent()->removeFromMBBNumbering(N->Number);
     100      445917 :   N->Number = -1;
     101      445917 : }
     102             : 
     103             : /// When we add an instruction to a basic block list, we update its parent
     104             : /// pointer and add its operands from reg use/def lists if appropriate.
     105     8020457 : void ilist_traits<MachineInstr>::addNodeToList(MachineInstr *N) {
     106             :   assert(!N->getParent() && "machine instruction already in a basic block");
     107     8020457 :   N->setParent(Parent);
     108             : 
     109             :   // Add the instruction's register operands to their corresponding
     110             :   // use/def lists.
     111     8020457 :   MachineFunction *MF = Parent->getParent();
     112     8020457 :   N->AddRegOperandsToUseLists(MF->getRegInfo());
     113     8020457 : }
     114             : 
     115             : /// When we remove an instruction from a basic block list, we update its parent
     116             : /// pointer and remove its operands from reg use/def lists if appropriate.
     117     4073965 : void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr *N) {
     118             :   assert(N->getParent() && "machine instruction not in a basic block");
     119             : 
     120             :   // Remove from the use/def lists.
     121     4073965 :   if (MachineFunction *MF = N->getMF())
     122     4073965 :     N->RemoveRegOperandsFromUseLists(MF->getRegInfo());
     123             : 
     124             :   N->setParent(nullptr);
     125     4073965 : }
     126             : 
     127             : /// When moving a range of instructions from one MBB list to another, we need to
     128             : /// update the parent pointers and the use/def lists.
     129       64702 : void ilist_traits<MachineInstr>::transferNodesFromList(ilist_traits &FromList,
     130             :                                                        instr_iterator First,
     131             :                                                        instr_iterator Last) {
     132             :   assert(Parent->getParent() == FromList.Parent->getParent() &&
     133             :         "MachineInstr parent mismatch!");
     134             :   assert(this != &FromList && "Called without a real transfer...");
     135             :   assert(Parent != FromList.Parent && "Two lists have the same parent?");
     136             : 
     137             :   // If splicing between two blocks within the same function, just update the
     138             :   // parent pointers.
     139      242985 :   for (; First != Last; ++First)
     140      178283 :     First->setParent(Parent);
     141       64702 : }
     142             : 
     143     4004733 : void ilist_traits<MachineInstr>::deleteNode(MachineInstr *MI) {
     144             :   assert(!MI->getParent() && "MI is still in a block!");
     145     4004733 :   Parent->getParent()->DeleteMachineInstr(MI);
     146     4004733 : }
     147             : 
     148      283375 : MachineBasicBlock::iterator MachineBasicBlock::getFirstNonPHI() {
     149             :   instr_iterator I = instr_begin(), E = instr_end();
     150      299884 :   while (I != E && I->isPHI())
     151             :     ++I;
     152             :   assert((I == E || !I->isInsideBundle()) &&
     153             :          "First non-phi MI cannot be inside a bundle!");
     154      283375 :   return I;
     155             : }
     156             : 
     157             : MachineBasicBlock::iterator
     158       82163 : MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) {
     159       82163 :   const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
     160             : 
     161             :   iterator E = end();
     162      230294 :   while (I != E && (I->isPHI() || I->isPosition() ||
     163       55121 :                     TII->isBasicBlockPrologue(*I)))
     164             :     ++I;
     165             :   // FIXME: This needs to change if we wish to bundle labels
     166             :   // inside the bundle.
     167             :   assert((I == E || !I->isInsideBundle()) &&
     168             :          "First non-phi / non-label instruction is inside a bundle!");
     169       82163 :   return I;
     170             : }
     171             : 
     172             : MachineBasicBlock::iterator
     173       32115 : MachineBasicBlock::SkipPHIsLabelsAndDebug(MachineBasicBlock::iterator I) {
     174       32115 :   const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
     175             : 
     176             :   iterator E = end();
     177      161527 :   while (I != E && (I->isPHI() || I->isPosition() || I->isDebugInstr() ||
     178       31804 :                     TII->isBasicBlockPrologue(*I)))
     179             :     ++I;
     180             :   // FIXME: This needs to change if we wish to bundle labels / dbg_values
     181             :   // inside the bundle.
     182             :   assert((I == E || !I->isInsideBundle()) &&
     183             :          "First non-phi / non-label / non-debug "
     184             :          "instruction is inside a bundle!");
     185       32115 :   return I;
     186             : }
     187             : 
     188     2641855 : MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
     189     2641855 :   iterator B = begin(), E = end(), I = E;
     190     9850117 :   while (I != B && ((--I)->isTerminator() || I->isDebugInstr()))
     191             :     ; /*noop */
     192     9979935 :   while (I != E && !I->isTerminator())
     193             :     ++I;
     194     2641855 :   return I;
     195             : }
     196             : 
     197       20517 : MachineBasicBlock::instr_iterator MachineBasicBlock::getFirstInstrTerminator() {
     198             :   instr_iterator B = instr_begin(), E = instr_end(), I = E;
     199       84751 :   while (I != B && ((--I)->isTerminator() || I->isDebugInstr()))
     200             :     ; /*noop */
     201       77556 :   while (I != E && !I->isTerminator())
     202             :     ++I;
     203       20517 :   return I;
     204             : }
     205             : 
     206     1460491 : MachineBasicBlock::iterator MachineBasicBlock::getFirstNonDebugInstr() {
     207             :   // Skip over begin-of-block dbg_value instructions.
     208     1460491 :   return skipDebugInstructionsForward(begin(), end());
     209             : }
     210             : 
     211     1873206 : MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() {
     212             :   // Skip over end-of-block dbg_value instructions.
     213             :   instr_iterator B = instr_begin(), I = instr_end();
     214     1876508 :   while (I != B) {
     215             :     --I;
     216             :     // Return instruction that starts a bundle.
     217     1853800 :     if (I->isDebugInstr() || I->isInsideBundle())
     218             :       continue;
     219     1851825 :     return I;
     220             :   }
     221             :   // The block is all debug values.
     222             :   return end();
     223             : }
     224             : 
     225      463142 : bool MachineBasicBlock::hasEHPadSuccessor() const {
     226     1079640 :   for (const_succ_iterator I = succ_begin(), E = succ_end(); I != E; ++I)
     227      655594 :     if ((*I)->isEHPad())
     228             :       return true;
     229             :   return false;
     230             : }
     231             : 
     232             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     233             : LLVM_DUMP_METHOD void MachineBasicBlock::dump() const {
     234             :   print(dbgs());
     235             : }
     236             : #endif
     237             : 
     238       15012 : bool MachineBasicBlock::isLegalToHoistInto() const {
     239       15012 :   if (isReturnBlock() || hasEHPadSuccessor())
     240             :     return false;
     241             :   return true;
     242             : }
     243             : 
     244        2393 : StringRef MachineBasicBlock::getName() const {
     245        2393 :   if (const BasicBlock *LBB = getBasicBlock())
     246        2359 :     return LBB->getName();
     247             :   else
     248          34 :     return StringRef("", 0);
     249             : }
     250             : 
     251             : /// Return a hopefully unique identifier for this block.
     252           0 : std::string MachineBasicBlock::getFullName() const {
     253             :   std::string Name;
     254           0 :   if (getParent())
     255           0 :     Name = (getParent()->getName() + ":").str();
     256           0 :   if (getBasicBlock())
     257           0 :     Name += getBasicBlock()->getName();
     258             :   else
     259           0 :     Name += ("BB" + Twine(getNumber())).str();
     260           0 :   return Name;
     261             : }
     262             : 
     263           0 : void MachineBasicBlock::print(raw_ostream &OS, const SlotIndexes *Indexes,
     264             :                               bool IsStandalone) const {
     265           0 :   const MachineFunction *MF = getParent();
     266           0 :   if (!MF) {
     267           0 :     OS << "Can't print out MachineBasicBlock because parent MachineFunction"
     268           0 :        << " is null\n";
     269           0 :     return;
     270             :   }
     271           0 :   const Function &F = MF->getFunction();
     272           0 :   const Module *M = F.getParent();
     273           0 :   ModuleSlotTracker MST(M);
     274           0 :   MST.incorporateFunction(F);
     275           0 :   print(OS, MST, Indexes, IsStandalone);
     276             : }
     277             : 
     278       14470 : void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
     279             :                               const SlotIndexes *Indexes,
     280             :                               bool IsStandalone) const {
     281       14470 :   const MachineFunction *MF = getParent();
     282       14470 :   if (!MF) {
     283           0 :     OS << "Can't print out MachineBasicBlock because parent MachineFunction"
     284           0 :        << " is null\n";
     285           0 :     return;
     286             :   }
     287             : 
     288       14470 :   if (Indexes)
     289             :     OS << Indexes->getMBBStartIdx(this) << '\t';
     290             : 
     291       14470 :   OS << "bb." << getNumber();
     292             :   bool HasAttributes = false;
     293       14470 :   if (const auto *BB = getBasicBlock()) {
     294       14416 :     if (BB->hasName()) {
     295       13875 :       OS << "." << BB->getName();
     296             :     } else {
     297             :       HasAttributes = true;
     298         541 :       OS << " (";
     299         541 :       int Slot = MST.getLocalSlot(BB);
     300         541 :       if (Slot == -1)
     301           0 :         OS << "<ir-block badref>";
     302             :       else
     303        1082 :         OS << (Twine("%ir-block.") + Twine(Slot)).str();
     304             :     }
     305             :   }
     306             : 
     307       14470 :   if (hasAddressTaken()) {
     308           2 :     OS << (HasAttributes ? ", " : " (");
     309           2 :     OS << "address-taken";
     310             :     HasAttributes = true;
     311             :   }
     312       14470 :   if (isEHPad()) {
     313           4 :     OS << (HasAttributes ? ", " : " (");
     314           4 :     OS << "landing-pad";
     315             :     HasAttributes = true;
     316             :   }
     317       14470 :   if (getAlignment()) {
     318           0 :     OS << (HasAttributes ? ", " : " (");
     319           0 :     OS << "align " << getAlignment();
     320             :     HasAttributes = true;
     321             :   }
     322       14470 :   if (HasAttributes)
     323         547 :     OS << ")";
     324       14470 :   OS << ":\n";
     325             : 
     326       14470 :   const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
     327       14470 :   const MachineRegisterInfo &MRI = MF->getRegInfo();
     328       14470 :   const TargetInstrInfo &TII = *getParent()->getSubtarget().getInstrInfo();
     329             :   bool HasLineAttributes = false;
     330             : 
     331             :   // Print the preds of this block according to the CFG.
     332       14470 :   if (!pred_empty() && IsStandalone) {
     333       12777 :     if (Indexes) OS << '\t';
     334             :     // Don't indent(2), align with previous line attributes.
     335       12777 :     OS << "; predecessors: ";
     336       33024 :     for (auto I = pred_begin(), E = pred_end(); I != E; ++I) {
     337       20247 :       if (I != pred_begin())
     338        7470 :         OS << ", ";
     339       40494 :       OS << printMBBReference(**I);
     340             :     }
     341             :     OS << '\n';
     342             :     HasLineAttributes = true;
     343             :   }
     344             : 
     345       14470 :   if (!succ_empty()) {
     346       11038 :     if (Indexes) OS << '\t';
     347             :     // Print the successors
     348       11038 :     OS.indent(2) << "successors: ";
     349       31285 :     for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
     350       20247 :       if (I != succ_begin())
     351        9209 :         OS << ", ";
     352       40494 :       OS << printMBBReference(**I);
     353       20247 :       if (!Probs.empty())
     354             :         OS << '('
     355       60741 :            << format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
     356             :            << ')';
     357             :     }
     358       11038 :     if (!Probs.empty() && IsStandalone) {
     359             :       // Print human readable probabilities as comments.
     360       11038 :       OS << "; ";
     361       31285 :       for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
     362       40494 :         const BranchProbability &BP = *getProbabilityIterator(I);
     363       20247 :         if (I != succ_begin())
     364        9209 :           OS << ", ";
     365       40494 :         OS << printMBBReference(**I) << '('
     366       20247 :            << format("%.2f%%",
     367       20247 :                      rint(((double)BP.getNumerator() / BP.getDenominator()) *
     368       20247 :                           100.0 * 100.0) /
     369       20247 :                          100.0)
     370             :            << ')';
     371             :       }
     372             :     }
     373             : 
     374             :     OS << '\n';
     375             :     HasLineAttributes = true;
     376             :   }
     377             : 
     378       20847 :   if (!livein_empty() && MRI.tracksLiveness()) {
     379        6374 :     if (Indexes) OS << '\t';
     380        6374 :     OS.indent(2) << "liveins: ";
     381             : 
     382             :     bool First = true;
     383       15463 :     for (const auto &LI : liveins()) {
     384        9089 :       if (!First)
     385        2715 :         OS << ", ";
     386             :       First = false;
     387       18178 :       OS << printReg(LI.PhysReg, TRI);
     388        9089 :       if (!LI.LaneMask.all())
     389           0 :         OS << ":0x" << PrintLaneMask(LI.LaneMask);
     390             :     }
     391             :     HasLineAttributes = true;
     392             :   }
     393             : 
     394        8096 :   if (HasLineAttributes)
     395             :     OS << '\n';
     396             : 
     397             :   bool IsInBundle = false;
     398       69052 :   for (const MachineInstr &MI : instrs()) {
     399       54582 :     if (Indexes) {
     400             :       if (Indexes->hasIndex(MI))
     401        4913 :         OS << Indexes->getInstructionIndex(MI);
     402             :       OS << '\t';
     403             :     }
     404             : 
     405       54592 :     if (IsInBundle && !MI.isInsideBundle()) {
     406           2 :       OS.indent(2) << "}\n";
     407             :       IsInBundle = false;
     408             :     }
     409             : 
     410      109162 :     OS.indent(IsInBundle ? 4 : 2);
     411       54582 :     MI.print(OS, MST, IsStandalone, /*SkipOpers=*/false, /*SkipDebugLoc=*/false,
     412             :              /*AddNewLine=*/false, &TII);
     413             : 
     414       54582 :     if (!IsInBundle && MI.getFlag(MachineInstr::BundledSucc)) {
     415           2 :       OS << " {";
     416             :       IsInBundle = true;
     417             :     }
     418             :     OS << '\n';
     419             :   }
     420             : 
     421       14470 :   if (IsInBundle)
     422           0 :     OS.indent(2) << "}\n";
     423             : 
     424       14470 :   if (IrrLoopHeaderWeight && IsStandalone) {
     425           0 :     if (Indexes) OS << '\t';
     426           0 :     OS.indent(2) << "; Irreducible loop header weight: "
     427           0 :                  << IrrLoopHeaderWeight.getValue() << '\n';
     428             :   }
     429             : }
     430             : 
     431       84421 : void MachineBasicBlock::printAsOperand(raw_ostream &OS,
     432             :                                        bool /*PrintType*/) const {
     433       84421 :   OS << "%bb." << getNumber();
     434       84421 : }
     435             : 
     436       18123 : void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) {
     437             :   LiveInVector::iterator I = find_if(
     438             :       LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
     439       18123 :   if (I == LiveIns.end())
     440             :     return;
     441             : 
     442             :   I->LaneMask &= ~LaneMask;
     443       17916 :   if (I->LaneMask.none())
     444             :     LiveIns.erase(I);
     445             : }
     446             : 
     447             : MachineBasicBlock::livein_iterator
     448         510 : MachineBasicBlock::removeLiveIn(MachineBasicBlock::livein_iterator I) {
     449             :   // Get non-const version of iterator.
     450             :   LiveInVector::iterator LI = LiveIns.begin() + (I - LiveIns.begin());
     451         510 :   return LiveIns.erase(LI);
     452             : }
     453             : 
     454      302151 : bool MachineBasicBlock::isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) const {
     455             :   livein_iterator I = find_if(
     456             :       LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
     457      349605 :   return I != livein_end() && (I->LaneMask & LaneMask).any();
     458             : }
     459             : 
     460      344185 : void MachineBasicBlock::sortUniqueLiveIns() {
     461             :   llvm::sort(LiveIns.begin(), LiveIns.end(),
     462             :              [](const RegisterMaskPair &LI0, const RegisterMaskPair &LI1) {
     463             :                return LI0.PhysReg < LI1.PhysReg;
     464             :              });
     465             :   // Liveins are sorted by physreg now we can merge their lanemasks.
     466             :   LiveInVector::const_iterator I = LiveIns.begin();
     467             :   LiveInVector::const_iterator J;
     468             :   LiveInVector::iterator Out = LiveIns.begin();
     469     1824653 :   for (; I != LiveIns.end(); ++Out, I = J) {
     470      740234 :     unsigned PhysReg = I->PhysReg;
     471      740234 :     LaneBitmask LaneMask = I->LaneMask;
     472      740391 :     for (J = std::next(I); J != LiveIns.end() && J->PhysReg == PhysReg; ++J)
     473             :       LaneMask |= J->LaneMask;
     474      740234 :     Out->PhysReg = PhysReg;
     475      740234 :     Out->LaneMask = LaneMask;
     476             :   }
     477             :   LiveIns.erase(Out, LiveIns.end());
     478      344185 : }
     479             : 
     480             : unsigned
     481       54284 : MachineBasicBlock::addLiveIn(MCPhysReg PhysReg, const TargetRegisterClass *RC) {
     482             :   assert(getParent() && "MBB must be inserted in function");
     483             :   assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) && "Expected physreg");
     484             :   assert(RC && "Register class is required");
     485             :   assert((isEHPad() || this == &getParent()->front()) &&
     486             :          "Only the entry block and landing pads can have physreg live ins");
     487             : 
     488       54284 :   bool LiveIn = isLiveIn(PhysReg);
     489       54284 :   iterator I = SkipPHIsAndLabels(begin()), E = end();
     490       54284 :   MachineRegisterInfo &MRI = getParent()->getRegInfo();
     491       54284 :   const TargetInstrInfo &TII = *getParent()->getSubtarget().getInstrInfo();
     492             : 
     493             :   // Look for an existing copy.
     494       54284 :   if (LiveIn)
     495           0 :     for (;I != E && I->isCopy(); ++I)
     496           0 :       if (I->getOperand(1).getReg() == PhysReg) {
     497           0 :         unsigned VirtReg = I->getOperand(0).getReg();
     498           0 :         if (!MRI.constrainRegClass(VirtReg, RC))
     499           0 :           llvm_unreachable("Incompatible live-in register class.");
     500             :         return VirtReg;
     501             :       }
     502             : 
     503             :   // No luck, create a virtual register.
     504       54284 :   unsigned VirtReg = MRI.createVirtualRegister(RC);
     505      217136 :   BuildMI(*this, I, DebugLoc(), TII.get(TargetOpcode::COPY), VirtReg)
     506       54284 :     .addReg(PhysReg, RegState::Kill);
     507       54284 :   if (!LiveIn)
     508             :     addLiveIn(PhysReg);
     509             :   return VirtReg;
     510             : }
     511             : 
     512        1535 : void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
     513        1535 :   getParent()->splice(NewAfter->getIterator(), getIterator());
     514        1535 : }
     515             : 
     516       35008 : void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
     517       35008 :   getParent()->splice(++NewBefore->getIterator(), getIterator());
     518       35008 : }
     519             : 
     520      204215 : void MachineBasicBlock::updateTerminator() {
     521      204215 :   const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
     522             :   // A block with no successors has no concerns with fall-through edges.
     523      204215 :   if (this->succ_empty())
     524      145938 :     return;
     525             : 
     526      196633 :   MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
     527             :   SmallVector<MachineOperand, 4> Cond;
     528      196633 :   DebugLoc DL = findBranchDebugLoc();
     529      196633 :   bool B = TII->analyzeBranch(*this, TBB, FBB, Cond);
     530             :   (void) B;
     531             :   assert(!B && "UpdateTerminators requires analyzable predecessors!");
     532      196633 :   if (Cond.empty()) {
     533      132498 :     if (TBB) {
     534             :       // The block has an unconditional branch. If its successor is now its
     535             :       // layout successor, delete the branch.
     536       42172 :       if (isLayoutSuccessor(TBB))
     537       13387 :         TII->removeBranch(*this);
     538             :     } else {
     539             :       // The block has an unconditional fallthrough. If its successor is not its
     540             :       // layout successor, insert a branch. First we have to locate the only
     541             :       // non-landing-pad successor, as that is the fallthrough block.
     542      216745 :       for (succ_iterator SI = succ_begin(), SE = succ_end(); SI != SE; ++SI) {
     543      126419 :         if ((*SI)->isEHPad())
     544       36093 :           continue;
     545             :         assert(!TBB && "Found more than one non-landing-pad successor!");
     546       90326 :         TBB = *SI;
     547             :       }
     548             : 
     549             :       // If there is no non-landing-pad successor, the block has no fall-through
     550             :       // edges to be concerned with.
     551       90326 :       if (!TBB)
     552             :         return;
     553             : 
     554             :       // Finally update the unconditional successor to be reached via a branch
     555             :       // if it would not be reached by fallthrough.
     556       90326 :       if (!isLayoutSuccessor(TBB))
     557       26822 :         TII->insertBranch(*this, TBB, nullptr, Cond, DL);
     558             :     }
     559             :     return;
     560             :   }
     561             : 
     562       64135 :   if (FBB) {
     563             :     // The block has a non-fallthrough conditional branch. If one of its
     564             :     // successors is its layout successor, rewrite it to a fallthrough
     565             :     // conditional branch.
     566        5833 :     if (isLayoutSuccessor(TBB)) {
     567        4658 :       if (TII->reverseBranchCondition(Cond))
     568             :         return;
     569        4656 :       TII->removeBranch(*this);
     570        9312 :       TII->insertBranch(*this, FBB, nullptr, Cond, DL);
     571        1175 :     } else if (isLayoutSuccessor(FBB)) {
     572         708 :       TII->removeBranch(*this);
     573        1416 :       TII->insertBranch(*this, TBB, nullptr, Cond, DL);
     574             :     }
     575             :     return;
     576             :   }
     577             : 
     578             :   // Walk through the successors and find the successor which is not a landing
     579             :   // pad and is not the conditional branch destination (in TBB) as the
     580             :   // fallthrough successor.
     581             :   MachineBasicBlock *FallthroughBB = nullptr;
     582      174894 :   for (succ_iterator SI = succ_begin(), SE = succ_end(); SI != SE; ++SI) {
     583      116592 :     if ((*SI)->isEHPad() || *SI == TBB)
     584       58302 :       continue;
     585             :     assert(!FallthroughBB && "Found more than one fallthrough successor.");
     586             :     FallthroughBB = *SI;
     587             :   }
     588             : 
     589       58302 :   if (!FallthroughBB) {
     590          12 :     if (canFallThrough()) {
     591             :       // We fallthrough to the same basic block as the conditional jump targets.
     592             :       // Remove the conditional jump, leaving unconditional fallthrough.
     593             :       // FIXME: This does not seem like a reasonable pattern to support, but it
     594             :       // has been seen in the wild coming out of degenerate ARM test cases.
     595          11 :       TII->removeBranch(*this);
     596             : 
     597             :       // Finally update the unconditional successor to be reached via a branch if
     598             :       // it would not be reached by fallthrough.
     599          11 :       if (!isLayoutSuccessor(TBB))
     600           0 :         TII->insertBranch(*this, TBB, nullptr, Cond, DL);
     601             :       return;
     602             :     }
     603             : 
     604             :     // We enter here iff exactly one successor is TBB which cannot fallthrough
     605             :     // and the rest successors if any are EHPads.  In this case, we need to
     606             :     // change the conditional branch into unconditional branch.
     607           1 :     TII->removeBranch(*this);
     608             :     Cond.clear();
     609           2 :     TII->insertBranch(*this, TBB, nullptr, Cond, DL);
     610           1 :     return;
     611             :   }
     612             : 
     613             :   // The block has a fallthrough conditional branch.
     614       58290 :   if (isLayoutSuccessor(TBB)) {
     615        9240 :     if (TII->reverseBranchCondition(Cond)) {
     616             :       // We can't reverse the condition, add an unconditional branch.
     617             :       Cond.clear();
     618          26 :       TII->insertBranch(*this, FallthroughBB, nullptr, Cond, DL);
     619          13 :       return;
     620             :     }
     621        9227 :     TII->removeBranch(*this);
     622       18454 :     TII->insertBranch(*this, FallthroughBB, nullptr, Cond, DL);
     623       49050 :   } else if (!isLayoutSuccessor(FallthroughBB)) {
     624         695 :     TII->removeBranch(*this);
     625        1390 :     TII->insertBranch(*this, TBB, FallthroughBB, Cond, DL);
     626             :   }
     627             : }
     628             : 
     629           0 : void MachineBasicBlock::validateSuccProbs() const {
     630             : #ifndef NDEBUG
     631             :   int64_t Sum = 0;
     632             :   for (auto Prob : Probs)
     633             :     Sum += Prob.getNumerator();
     634             :   // Due to precision issue, we assume that the sum of probabilities is one if
     635             :   // the difference between the sum of their numerators and the denominator is
     636             :   // no greater than the number of successors.
     637             :   assert((uint64_t)std::abs(Sum - BranchProbability::getDenominator()) <=
     638             :              Probs.size() &&
     639             :          "The sum of successors's probabilities exceeds one.");
     640             : #endif // NDEBUG
     641           0 : }
     642             : 
     643      261992 : void MachineBasicBlock::addSuccessor(MachineBasicBlock *Succ,
     644             :                                      BranchProbability Prob) {
     645             :   // Probability list is either empty (if successor list isn't empty, this means
     646             :   // disabled optimization) or has the same size as successor list.
     647      441173 :   if (!(Probs.empty() && !Successors.empty()))
     648      261925 :     Probs.push_back(Prob);
     649      261992 :   Successors.push_back(Succ);
     650      261992 :   Succ->addPredecessor(this);
     651      261992 : }
     652             : 
     653       61629 : void MachineBasicBlock::addSuccessorWithoutProb(MachineBasicBlock *Succ) {
     654             :   // We need to make sure probability list is either empty or has the same size
     655             :   // of successor list. When this function is called, we can safely delete all
     656             :   // probability in the list.
     657             :   Probs.clear();
     658       61629 :   Successors.push_back(Succ);
     659       61629 :   Succ->addPredecessor(this);
     660       61629 : }
     661             : 
     662       11658 : void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ,
     663             :                                         bool NormalizeSuccProbs) {
     664       11658 :   succ_iterator I = find(Successors, Succ);
     665       11658 :   removeSuccessor(I, NormalizeSuccProbs);
     666       11658 : }
     667             : 
     668             : MachineBasicBlock::succ_iterator
     669       37158 : MachineBasicBlock::removeSuccessor(succ_iterator I, bool NormalizeSuccProbs) {
     670             :   assert(I != Successors.end() && "Not a current successor!");
     671             : 
     672             :   // If probability list is empty it means we don't use it (disabled
     673             :   // optimization).
     674       37158 :   if (!Probs.empty()) {
     675       36987 :     probability_iterator WI = getProbabilityIterator(I);
     676             :     Probs.erase(WI);
     677       36987 :     if (NormalizeSuccProbs)
     678             :       normalizeSuccProbs();
     679             :   }
     680             : 
     681       37158 :   (*I)->removePredecessor(this);
     682       74316 :   return Successors.erase(I);
     683             : }
     684             : 
     685       16879 : void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old,
     686             :                                          MachineBasicBlock *New) {
     687       16879 :   if (Old == New)
     688             :     return;
     689             : 
     690             :   succ_iterator E = succ_end();
     691             :   succ_iterator NewI = E;
     692             :   succ_iterator OldI = E;
     693       52866 :   for (succ_iterator I = succ_begin(); I != E; ++I) {
     694       36514 :     if (*I == Old) {
     695             :       OldI = I;
     696       16879 :       if (NewI != E)
     697             :         break;
     698             :     }
     699       36290 :     if (*I == New) {
     700             :       NewI = I;
     701         527 :       if (OldI != E)
     702             :         break;
     703             :     }
     704             :   }
     705             :   assert(OldI != E && "Old is not a successor of this block");
     706             : 
     707             :   // If New isn't already a successor, let it take Old's place.
     708       16879 :   if (NewI == E) {
     709       16352 :     Old->removePredecessor(this);
     710       16352 :     New->addPredecessor(this);
     711       16352 :     *OldI = New;
     712       16352 :     return;
     713             :   }
     714             : 
     715             :   // New is already a successor.
     716             :   // Update its probability instead of adding a duplicate edge.
     717         527 :   if (!Probs.empty()) {
     718         527 :     auto ProbIter = getProbabilityIterator(NewI);
     719         527 :     if (!ProbIter->isUnknown())
     720        1010 :       *ProbIter += *getProbabilityIterator(OldI);
     721             :   }
     722         527 :   removeSuccessor(OldI);
     723             : }
     724             : 
     725           4 : void MachineBasicBlock::copySuccessor(MachineBasicBlock *Orig,
     726             :                                       succ_iterator I) {
     727           4 :   if (Orig->Probs.empty())
     728           0 :     addSuccessor(*I, Orig->getSuccProbability(I));
     729             :   else
     730           4 :     addSuccessorWithoutProb(*I);
     731           4 : }
     732             : 
     733      339973 : void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) {
     734      339973 :   Predecessors.push_back(Pred);
     735      339973 : }
     736             : 
     737       53510 : void MachineBasicBlock::removePredecessor(MachineBasicBlock *Pred) {
     738             :   pred_iterator I = find(Predecessors, Pred);
     739             :   assert(I != Predecessors.end() && "Pred is not a predecessor of this block!");
     740       53510 :   Predecessors.erase(I);
     741       53510 : }
     742             : 
     743        9330 : void MachineBasicBlock::transferSuccessors(MachineBasicBlock *FromMBB) {
     744        9330 :   if (this == FromMBB)
     745             :     return;
     746             : 
     747       22844 :   while (!FromMBB->succ_empty()) {
     748        6757 :     MachineBasicBlock *Succ = *FromMBB->succ_begin();
     749             : 
     750             :     // If probability list is empty it means we don't use it (disabled optimization).
     751        6757 :     if (!FromMBB->Probs.empty()) {
     752        6719 :       auto Prob = *FromMBB->Probs.begin();
     753        6719 :       addSuccessor(Succ, Prob);
     754             :     } else
     755          38 :       addSuccessorWithoutProb(Succ);
     756             : 
     757        6757 :     FromMBB->removeSuccessor(Succ);
     758             :   }
     759             : }
     760             : 
     761             : void
     762        4833 : MachineBasicBlock::transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB) {
     763        4833 :   if (this == FromMBB)
     764             :     return;
     765             : 
     766        5742 :   while (!FromMBB->succ_empty()) {
     767         909 :     MachineBasicBlock *Succ = *FromMBB->succ_begin();
     768         909 :     if (!FromMBB->Probs.empty()) {
     769         861 :       auto Prob = *FromMBB->Probs.begin();
     770         861 :       addSuccessor(Succ, Prob);
     771             :     } else
     772          48 :       addSuccessorWithoutProb(Succ);
     773         909 :     FromMBB->removeSuccessor(Succ);
     774             : 
     775             :     // Fix up any PHI nodes in the successor.
     776             :     for (MachineBasicBlock::instr_iterator MI = Succ->instr_begin(),
     777        1460 :            ME = Succ->instr_end(); MI != ME && MI->isPHI(); ++MI)
     778        1790 :       for (unsigned i = 2, e = MI->getNumOperands()+1; i != e; i += 2) {
     779        1239 :         MachineOperand &MO = MI->getOperand(i);
     780        1239 :         if (MO.getMBB() == FromMBB)
     781             :           MO.setMBB(this);
     782             :       }
     783             :   }
     784             :   normalizeSuccProbs();
     785             : }
     786             : 
     787         983 : bool MachineBasicBlock::isPredecessor(const MachineBasicBlock *MBB) const {
     788         983 :   return is_contained(predecessors(), MBB);
     789             : }
     790             : 
     791     3297206 : bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const {
     792     3297206 :   return is_contained(successors(), MBB);
     793             : }
     794             : 
     795     2236131 : bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const {
     796             :   MachineFunction::const_iterator I(this);
     797     2236131 :   return std::next(I) == MachineFunction::const_iterator(MBB);
     798             : }
     799             : 
     800     1337745 : MachineBasicBlock *MachineBasicBlock::getFallThrough() {
     801     1337745 :   MachineFunction::iterator Fallthrough = getIterator();
     802             :   ++Fallthrough;
     803             :   // If FallthroughBlock is off the end of the function, it can't fall through.
     804     2675490 :   if (Fallthrough == getParent()->end())
     805             :     return nullptr;
     806             : 
     807             :   // If FallthroughBlock isn't a successor, no fallthrough is possible.
     808     1233897 :   if (!isSuccessor(&*Fallthrough))
     809             :     return nullptr;
     810             : 
     811             :   // Analyze the branches, if any, at the end of the block.
     812      817142 :   MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
     813             :   SmallVector<MachineOperand, 4> Cond;
     814      817142 :   const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
     815      817142 :   if (TII->analyzeBranch(*this, TBB, FBB, Cond)) {
     816             :     // If we couldn't analyze the branch, examine the last instruction.
     817             :     // If the block doesn't end in a known control barrier, assume fallthrough
     818             :     // is possible. The isPredicated check is needed because this code can be
     819             :     // called during IfConversion, where an instruction which is normally a
     820             :     // Barrier is predicated and thus no longer an actual control barrier.
     821       23733 :     return (empty() || !back().isBarrier() || TII->isPredicated(back()))
     822       13794 :                ? &*Fallthrough
     823             :                : nullptr;
     824             :   }
     825             : 
     826             :   // If there is no branch, control always falls through.
     827      803348 :   if (!TBB) return &*Fallthrough;
     828             : 
     829             :   // If there is some explicit branch to the fallthrough block, it can obviously
     830             :   // reach, even though the branch should get folded to fall through implicitly.
     831      653534 :   if (MachineFunction::iterator(TBB) == Fallthrough ||
     832      309455 :       MachineFunction::iterator(FBB) == Fallthrough)
     833             :     return &*Fallthrough;
     834             : 
     835             :   // If it's an unconditional branch to some block not the fall through, it
     836             :   // doesn't fall through.
     837      265544 :   if (Cond.empty()) return nullptr;
     838             : 
     839             :   // Otherwise, if it is conditional and has no explicit false block, it falls
     840             :   // through.
     841      255544 :   return (FBB == nullptr) ? &*Fallthrough : nullptr;
     842             : }
     843             : 
     844     1337743 : bool MachineBasicBlock::canFallThrough() {
     845     1337743 :   return getFallThrough() != nullptr;
     846             : }
     847             : 
     848        6190 : MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ,
     849             :                                                         Pass &P) {
     850        6190 :   if (!canSplitCriticalEdge(Succ))
     851             :     return nullptr;
     852             : 
     853        5910 :   MachineFunction *MF = getParent();
     854        5910 :   DebugLoc DL;  // FIXME: this is nowhere
     855             : 
     856        5910 :   MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
     857             :   MF->insert(std::next(MachineFunction::iterator(this)), NMBB);
     858             :   LLVM_DEBUG(dbgs() << "Splitting critical edge: " << printMBBReference(*this)
     859             :                     << " -- " << printMBBReference(*NMBB) << " -- "
     860             :                     << printMBBReference(*Succ) << '\n');
     861             : 
     862        5910 :   LiveIntervals *LIS = P.getAnalysisIfAvailable<LiveIntervals>();
     863        5910 :   SlotIndexes *Indexes = P.getAnalysisIfAvailable<SlotIndexes>();
     864        5910 :   if (LIS)
     865           0 :     LIS->insertMBBInMaps(NMBB);
     866        5910 :   else if (Indexes)
     867           0 :     Indexes->insertMBBInMaps(NMBB);
     868             : 
     869             :   // On some targets like Mips, branches may kill virtual registers. Make sure
     870             :   // that LiveVariables is properly updated after updateTerminator replaces the
     871             :   // terminators.
     872        5910 :   LiveVariables *LV = P.getAnalysisIfAvailable<LiveVariables>();
     873             : 
     874             :   // Collect a list of virtual registers killed by the terminators.
     875             :   SmallVector<unsigned, 4> KilledRegs;
     876        5910 :   if (LV)
     877        2132 :     for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
     878        6025 :          I != E; ++I) {
     879             :       MachineInstr *MI = &*I;
     880       10699 :       for (MachineInstr::mop_iterator OI = MI->operands_begin(),
     881       14592 :            OE = MI->operands_end(); OI != OE; ++OI) {
     882        9711 :         if (!OI->isReg() || OI->getReg() == 0 ||
     883       11012 :             !OI->isUse() || !OI->isKill() || OI->isUndef())
     884        4752 :           continue;
     885        2054 :         unsigned Reg = OI->getReg();
     886        2265 :         if (TargetRegisterInfo::isPhysicalRegister(Reg) ||
     887         211 :             LV->getVarInfo(Reg).removeKill(*MI)) {
     888        2054 :           KilledRegs.push_back(Reg);
     889             :           LLVM_DEBUG(dbgs() << "Removing terminator kill: " << *MI);
     890             :           OI->setIsKill(false);
     891             :         }
     892             :       }
     893             :     }
     894             : 
     895             :   SmallVector<unsigned, 4> UsedRegs;
     896        5910 :   if (LIS) {
     897           0 :     for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
     898           0 :          I != E; ++I) {
     899             :       MachineInstr *MI = &*I;
     900             : 
     901           0 :       for (MachineInstr::mop_iterator OI = MI->operands_begin(),
     902           0 :            OE = MI->operands_end(); OI != OE; ++OI) {
     903           0 :         if (!OI->isReg() || OI->getReg() == 0)
     904           0 :           continue;
     905             : 
     906           0 :         unsigned Reg = OI->getReg();
     907           0 :         if (!is_contained(UsedRegs, Reg))
     908           0 :           UsedRegs.push_back(Reg);
     909             :       }
     910             :     }
     911             :   }
     912             : 
     913        5910 :   ReplaceUsesOfBlockWith(Succ, NMBB);
     914             : 
     915             :   // If updateTerminator() removes instructions, we need to remove them from
     916             :   // SlotIndexes.
     917             :   SmallVector<MachineInstr*, 4> Terminators;
     918        5910 :   if (Indexes) {
     919           0 :     for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
     920           0 :          I != E; ++I)
     921           0 :       Terminators.push_back(&*I);
     922             :   }
     923             : 
     924        5910 :   updateTerminator();
     925             : 
     926        5910 :   if (Indexes) {
     927             :     SmallVector<MachineInstr*, 4> NewTerminators;
     928           0 :     for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
     929           0 :          I != E; ++I)
     930           0 :       NewTerminators.push_back(&*I);
     931             : 
     932           0 :     for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(),
     933           0 :         E = Terminators.end(); I != E; ++I) {
     934           0 :       if (!is_contained(NewTerminators, *I))
     935           0 :         Indexes->removeMachineInstrFromMaps(**I);
     936             :     }
     937             :   }
     938             : 
     939             :   // Insert unconditional "jump Succ" instruction in NMBB if necessary.
     940        5910 :   NMBB->addSuccessor(Succ);
     941        5910 :   if (!NMBB->isLayoutSuccessor(Succ)) {
     942             :     SmallVector<MachineOperand, 4> Cond;
     943        5628 :     const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
     944       11256 :     TII->insertBranch(*NMBB, Succ, nullptr, Cond, DL);
     945             : 
     946        5628 :     if (Indexes) {
     947           0 :       for (MachineInstr &MI : NMBB->instrs()) {
     948             :         // Some instructions may have been moved to NMBB by updateTerminator(),
     949             :         // so we first remove any instruction that already has an index.
     950             :         if (Indexes->hasIndex(MI))
     951           0 :           Indexes->removeMachineInstrFromMaps(MI);
     952           0 :         Indexes->insertMachineInstrInMaps(MI);
     953             :       }
     954             :     }
     955             :   }
     956             : 
     957             :   // Fix PHI nodes in Succ so they refer to NMBB instead of this
     958             :   for (MachineBasicBlock::instr_iterator
     959             :          i = Succ->instr_begin(),e = Succ->instr_end();
     960       14196 :        i != e && i->isPHI(); ++i)
     961       33563 :     for (unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2)
     962       50554 :       if (i->getOperand(ni+1).getMBB() == this)
     963             :         i->getOperand(ni+1).setMBB(NMBB);
     964             : 
     965             :   // Inherit live-ins from the successor
     966        6336 :   for (const auto &LI : Succ->liveins())
     967             :     NMBB->addLiveIn(LI);
     968             : 
     969             :   // Update LiveVariables.
     970        5910 :   const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
     971        5910 :   if (LV) {
     972             :     // Restore kills of virtual registers that were killed by the terminators.
     973        4186 :     while (!KilledRegs.empty()) {
     974             :       unsigned Reg = KilledRegs.pop_back_val();
     975        2054 :       for (instr_iterator I = instr_end(), E = instr_begin(); I != E;) {
     976        2054 :         if (!(--I)->addRegisterKilled(Reg, TRI, /* addIfNotFound= */ false))
     977             :           continue;
     978        2054 :         if (TargetRegisterInfo::isVirtualRegister(Reg))
     979         422 :           LV->getVarInfo(Reg).Kills.push_back(&*I);
     980             :         LLVM_DEBUG(dbgs() << "Restored terminator kill: " << *I);
     981             :         break;
     982             :       }
     983             :     }
     984             :     // Update relevant live-through information.
     985        2132 :     LV->addNewBlock(NMBB, this, Succ);
     986             :   }
     987             : 
     988        5910 :   if (LIS) {
     989             :     // After splitting the edge and updating SlotIndexes, live intervals may be
     990             :     // in one of two situations, depending on whether this block was the last in
     991             :     // the function. If the original block was the last in the function, all
     992             :     // live intervals will end prior to the beginning of the new split block. If
     993             :     // the original block was not at the end of the function, all live intervals
     994             :     // will extend to the end of the new split block.
     995             : 
     996             :     bool isLastMBB =
     997           0 :       std::next(MachineFunction::iterator(NMBB)) == getParent()->end();
     998             : 
     999             :     SlotIndex StartIndex = Indexes->getMBBEndIdx(this);
    1000             :     SlotIndex PrevIndex = StartIndex.getPrevSlot();
    1001             :     SlotIndex EndIndex = Indexes->getMBBEndIdx(NMBB);
    1002             : 
    1003             :     // Find the registers used from NMBB in PHIs in Succ.
    1004           0 :     SmallSet<unsigned, 8> PHISrcRegs;
    1005             :     for (MachineBasicBlock::instr_iterator
    1006             :          I = Succ->instr_begin(), E = Succ->instr_end();
    1007           0 :          I != E && I->isPHI(); ++I) {
    1008           0 :       for (unsigned ni = 1, ne = I->getNumOperands(); ni != ne; ni += 2) {
    1009           0 :         if (I->getOperand(ni+1).getMBB() == NMBB) {
    1010             :           MachineOperand &MO = I->getOperand(ni);
    1011           0 :           unsigned Reg = MO.getReg();
    1012           0 :           PHISrcRegs.insert(Reg);
    1013           0 :           if (MO.isUndef())
    1014           0 :             continue;
    1015             : 
    1016           0 :           LiveInterval &LI = LIS->getInterval(Reg);
    1017           0 :           VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
    1018             :           assert(VNI &&
    1019             :                  "PHI sources should be live out of their predecessors.");
    1020           0 :           LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
    1021             :         }
    1022             :       }
    1023             :     }
    1024             : 
    1025           0 :     MachineRegisterInfo *MRI = &getParent()->getRegInfo();
    1026           0 :     for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
    1027           0 :       unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
    1028           0 :       if (PHISrcRegs.count(Reg) || !LIS->hasInterval(Reg))
    1029           0 :         continue;
    1030             : 
    1031           0 :       LiveInterval &LI = LIS->getInterval(Reg);
    1032           0 :       if (!LI.liveAt(PrevIndex))
    1033           0 :         continue;
    1034             : 
    1035           0 :       bool isLiveOut = LI.liveAt(LIS->getMBBStartIdx(Succ));
    1036           0 :       if (isLiveOut && isLastMBB) {
    1037             :         VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
    1038             :         assert(VNI && "LiveInterval should have VNInfo where it is live.");
    1039           0 :         LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
    1040           0 :       } else if (!isLiveOut && !isLastMBB) {
    1041           0 :         LI.removeSegment(StartIndex, EndIndex);
    1042             :       }
    1043             :     }
    1044             : 
    1045             :     // Update all intervals for registers whose uses may have been modified by
    1046             :     // updateTerminator().
    1047           0 :     LIS->repairIntervalsInRange(this, getFirstTerminator(), end(), UsedRegs);
    1048             :   }
    1049             : 
    1050        5910 :   if (MachineDominatorTree *MDT =
    1051        5910 :           P.getAnalysisIfAvailable<MachineDominatorTree>())
    1052        5910 :     MDT->recordSplitCriticalEdge(this, Succ, NMBB);
    1053             : 
    1054        5910 :   if (MachineLoopInfo *MLI = P.getAnalysisIfAvailable<MachineLoopInfo>())
    1055        1332 :     if (MachineLoop *TIL = MLI->getLoopFor(this)) {
    1056             :       // If one or the other blocks were not in a loop, the new block is not
    1057             :       // either, and thus LI doesn't need to be updated.
    1058        1019 :       if (MachineLoop *DestLoop = MLI->getLoopFor(Succ)) {
    1059        1019 :         if (TIL == DestLoop) {
    1060             :           // Both in the same loop, the NMBB joins loop.
    1061        1808 :           DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
    1062         230 :         } else if (TIL->contains(DestLoop)) {
    1063             :           // Edge from an outer loop to an inner loop.  Add to the outer loop.
    1064           6 :           TIL->addBasicBlockToLoop(NMBB, MLI->getBase());
    1065         218 :         } else if (DestLoop->contains(TIL)) {
    1066             :           // Edge from an inner loop to an outer loop.  Add to the outer loop.
    1067         100 :           DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
    1068             :         } else {
    1069             :           // Edge from two loops with no containment relation.  Because these
    1070             :           // are natural loops, we know that the destination block must be the
    1071             :           // header of its loop (adding a branch into a loop elsewhere would
    1072             :           // create an irreducible loop).
    1073             :           assert(DestLoop->getHeader() == Succ &&
    1074             :                  "Should not create irreducible loops!");
    1075           9 :           if (MachineLoop *P = DestLoop->getParentLoop())
    1076           0 :             P->addBasicBlockToLoop(NMBB, MLI->getBase());
    1077             :         }
    1078             :       }
    1079             :     }
    1080             : 
    1081             :   return NMBB;
    1082             : }
    1083             : 
    1084        6190 : bool MachineBasicBlock::canSplitCriticalEdge(
    1085             :     const MachineBasicBlock *Succ) const {
    1086             :   // Splitting the critical edge to a landing pad block is non-trivial. Don't do
    1087             :   // it in this generic function.
    1088        6190 :   if (Succ->isEHPad())
    1089             :     return false;
    1090             : 
    1091        6190 :   const MachineFunction *MF = getParent();
    1092             : 
    1093             :   // Performance might be harmed on HW that implements branching using exec mask
    1094             :   // where both sides of the branches are always executed.
    1095       12380 :   if (MF->getTarget().requiresStructuredCFG())
    1096             :     return false;
    1097             : 
    1098             :   // We may need to update this's terminator, but we can't do that if
    1099             :   // AnalyzeBranch fails. If this uses a jump table, we won't touch it.
    1100        6101 :   const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
    1101        6101 :   MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
    1102             :   SmallVector<MachineOperand, 4> Cond;
    1103             :   // AnalyzeBanch should modify this, since we did not allow modification.
    1104        6101 :   if (TII->analyzeBranch(*const_cast<MachineBasicBlock *>(this), TBB, FBB, Cond,
    1105        6101 :                          /*AllowModify*/ false))
    1106             :     return false;
    1107             : 
    1108             :   // Avoid bugpoint weirdness: A block may end with a conditional branch but
    1109             :   // jumps to the same MBB is either case. We have duplicate CFG edges in that
    1110             :   // case that we can't handle. Since this never happens in properly optimized
    1111             :   // code, just skip those edges.
    1112        5910 :   if (TBB && TBB == FBB) {
    1113             :     LLVM_DEBUG(dbgs() << "Won't split critical edge after degenerate "
    1114             :                       << printMBBReference(*this) << '\n');
    1115             :     return false;
    1116             :   }
    1117        5910 :   return true;
    1118             : }
    1119             : 
    1120             : /// Prepare MI to be removed from its bundle. This fixes bundle flags on MI's
    1121             : /// neighboring instructions so the bundle won't be broken by removing MI.
    1122      651264 : static void unbundleSingleMI(MachineInstr *MI) {
    1123             :   // Removing the first instruction in a bundle.
    1124      651264 :   if (MI->isBundledWithSucc() && !MI->isBundledWithPred())
    1125           6 :     MI->unbundleFromSucc();
    1126             :   // Removing the last instruction in a bundle.
    1127      651264 :   if (MI->isBundledWithPred() && !MI->isBundledWithSucc())
    1128         537 :     MI->unbundleFromPred();
    1129             :   // If MI is not bundled, or if it is internal to a bundle, the neighbor flags
    1130             :   // are already fine.
    1131      651264 : }
    1132             : 
    1133             : MachineBasicBlock::instr_iterator
    1134      651175 : MachineBasicBlock::erase(MachineBasicBlock::instr_iterator I) {
    1135      651175 :   unbundleSingleMI(&*I);
    1136      651175 :   return Insts.erase(I);
    1137             : }
    1138             : 
    1139          89 : MachineInstr *MachineBasicBlock::remove_instr(MachineInstr *MI) {
    1140          89 :   unbundleSingleMI(MI);
    1141             :   MI->clearFlag(MachineInstr::BundledPred);
    1142             :   MI->clearFlag(MachineInstr::BundledSucc);
    1143         178 :   return Insts.remove(MI);
    1144             : }
    1145             : 
    1146             : MachineBasicBlock::instr_iterator
    1147       99750 : MachineBasicBlock::insert(instr_iterator I, MachineInstr *MI) {
    1148             :   assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
    1149             :          "Cannot insert instruction with bundle flags");
    1150             :   // Set the bundle flags when inserting inside a bundle.
    1151      199301 :   if (I != instr_end() && I->isBundledWithPred()) {
    1152             :     MI->setFlag(MachineInstr::BundledPred);
    1153             :     MI->setFlag(MachineInstr::BundledSucc);
    1154             :   }
    1155       99750 :   return Insts.insert(I, MI);
    1156             : }
    1157             : 
    1158             : /// This method unlinks 'this' from the containing function, and returns it, but
    1159             : /// does not delete it.
    1160           0 : MachineBasicBlock *MachineBasicBlock::removeFromParent() {
    1161             :   assert(getParent() && "Not embedded in a function!");
    1162           0 :   getParent()->remove(this);
    1163           0 :   return this;
    1164             : }
    1165             : 
    1166             : /// This method unlinks 'this' from the containing function, and deletes it.
    1167        3530 : void MachineBasicBlock::eraseFromParent() {
    1168             :   assert(getParent() && "Not embedded in a function!");
    1169        3530 :   getParent()->erase(this);
    1170        3530 : }
    1171             : 
    1172             : /// Given a machine basic block that branched to 'Old', change the code and CFG
    1173             : /// so that it branches to 'New' instead.
    1174       15135 : void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
    1175             :                                                MachineBasicBlock *New) {
    1176             :   assert(Old != New && "Cannot replace self with self!");
    1177             : 
    1178             :   MachineBasicBlock::instr_iterator I = instr_end();
    1179       38405 :   while (I != instr_begin()) {
    1180             :     --I;
    1181       38071 :     if (!I->isTerminator()) break;
    1182             : 
    1183             :     // Scan the operands of this machine instruction, replacing any uses of Old
    1184             :     // with New.
    1185       62300 :     for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
    1186      101040 :       if (I->getOperand(i).isMBB() &&
    1187       22980 :           I->getOperand(i).getMBB() == Old)
    1188             :         I->getOperand(i).setMBB(New);
    1189             :   }
    1190             : 
    1191             :   // Update the successor information.
    1192       15135 :   replaceSuccessor(Old, New);
    1193       15135 : }
    1194             : 
    1195             : /// Various pieces of code can cause excess edges in the CFG to be inserted.  If
    1196             : /// we have proven that MBB can only branch to DestA and DestB, remove any other
    1197             : /// MBB successors from the CFG.  DestA and DestB can be null.
    1198             : ///
    1199             : /// Besides DestA and DestB, retain other edges leading to LandingPads
    1200             : /// (currently there can be only one; we don't check or require that here).
    1201             : /// Note it is possible that DestA and/or DestB are LandingPads.
    1202     1318455 : bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
    1203             :                                              MachineBasicBlock *DestB,
    1204             :                                              bool IsCond) {
    1205             :   // The values of DestA and DestB frequently come from a call to the
    1206             :   // 'TargetInstrInfo::AnalyzeBranch' method. We take our meaning of the initial
    1207             :   // values from there.
    1208             :   //
    1209             :   // 1. If both DestA and DestB are null, then the block ends with no branches
    1210             :   //    (it falls through to its successor).
    1211             :   // 2. If DestA is set, DestB is null, and IsCond is false, then the block ends
    1212             :   //    with only an unconditional branch.
    1213             :   // 3. If DestA is set, DestB is null, and IsCond is true, then the block ends
    1214             :   //    with a conditional branch that falls through to a successor (DestB).
    1215             :   // 4. If DestA and DestB is set and IsCond is true, then the block ends with a
    1216             :   //    conditional branch followed by an unconditional branch. DestA is the
    1217             :   //    'true' destination and DestB is the 'false' destination.
    1218             : 
    1219             :   bool Changed = false;
    1220             : 
    1221             :   MachineBasicBlock *FallThru = getNextNode();
    1222             : 
    1223     1318455 :   if (!DestA && !DestB) {
    1224             :     // Block falls through to successor.
    1225             :     DestA = FallThru;
    1226             :     DestB = FallThru;
    1227      716700 :   } else if (DestA && !DestB) {
    1228      687532 :     if (IsCond)
    1229             :       // Block ends in conditional jump that falls through to successor.
    1230             :       DestB = FallThru;
    1231             :   } else {
    1232             :     assert(DestA && DestB && IsCond &&
    1233             :            "CFG in a bad state. Cannot correct CFG edges");
    1234             :   }
    1235             : 
    1236             :   // Remove superfluous edges. I.e., those which aren't destinations of this
    1237             :   // basic block, duplicate edges, or landing pads.
    1238             :   SmallPtrSet<const MachineBasicBlock*, 8> SeenMBBs;
    1239             :   MachineBasicBlock::succ_iterator SI = succ_begin();
    1240     3211716 :   while (SI != succ_end()) {
    1241     1893261 :     const MachineBasicBlock *MBB = *SI;
    1242     5679783 :     if (!SeenMBBs.insert(MBB).second ||
    1243     2143662 :         (MBB != DestA && MBB != DestB && !MBB->isEHPad())) {
    1244             :       // This is a superfluous edge, remove it.
    1245         188 :       SI = removeSuccessor(SI);
    1246             :       Changed = true;
    1247             :     } else {
    1248             :       ++SI;
    1249             :     }
    1250             :   }
    1251             : 
    1252     1318455 :   if (Changed)
    1253             :     normalizeSuccProbs();
    1254     1318455 :   return Changed;
    1255             : }
    1256             : 
    1257             : /// Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE
    1258             : /// instructions.  Return UnknownLoc if there is none.
    1259             : DebugLoc
    1260      630670 : MachineBasicBlock::findDebugLoc(instr_iterator MBBI) {
    1261             :   // Skip debug declarations, we don't want a DebugLoc from them.
    1262             :   MBBI = skipDebugInstructionsForward(MBBI, instr_end());
    1263      630670 :   if (MBBI != instr_end())
    1264             :     return MBBI->getDebugLoc();
    1265        2751 :   return {};
    1266             : }
    1267             : 
    1268             : /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
    1269             : /// instructions.  Return UnknownLoc if there is none.
    1270        1589 : DebugLoc MachineBasicBlock::findPrevDebugLoc(instr_iterator MBBI) {
    1271        1589 :   if (MBBI == instr_begin()) return {};
    1272             :   // Skip debug declarations, we don't want a DebugLoc from them.
    1273             :   MBBI = skipDebugInstructionsBackward(std::prev(MBBI), instr_begin());
    1274             :   if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
    1275           0 :   return {};
    1276             : }
    1277             : 
    1278             : /// Find and return the merged DebugLoc of the branch instructions of the block.
    1279             : /// Return UnknownLoc if there is none.
    1280             : DebugLoc
    1281      673391 : MachineBasicBlock::findBranchDebugLoc() {
    1282      673391 :   DebugLoc DL;
    1283      673391 :   auto TI = getFirstTerminator();
    1284     1129306 :   while (TI != end() && !TI->isBranch())
    1285             :     ++TI;
    1286             : 
    1287      673391 :   if (TI != end()) {
    1288             :     DL = TI->getDebugLoc();
    1289      470616 :     for (++TI ; TI != end() ; ++TI)
    1290       14805 :       if (TI->isBranch())
    1291       29610 :         DL = DILocation::getMergedLocation(DL, TI->getDebugLoc());
    1292             :   }
    1293      673391 :   return DL;
    1294             : }
    1295             : 
    1296             : /// Return probability of the edge from this block to MBB.
    1297             : BranchProbability
    1298     1410942 : MachineBasicBlock::getSuccProbability(const_succ_iterator Succ) const {
    1299     1410942 :   if (Probs.empty())
    1300         602 :     return BranchProbability(1, succ_size());
    1301             : 
    1302     2820680 :   const auto &Prob = *getProbabilityIterator(Succ);
    1303     1410340 :   if (Prob.isUnknown()) {
    1304             :     // For unknown probabilities, collect the sum of all known ones, and evenly
    1305             :     // ditribute the complemental of the sum to each unknown probability.
    1306             :     unsigned KnownProbNum = 0;
    1307             :     auto Sum = BranchProbability::getZero();
    1308      511959 :     for (auto &P : Probs) {
    1309      579605 :       if (!P.isUnknown()) {
    1310             :         Sum += P;
    1311          21 :         KnownProbNum++;
    1312             :       }
    1313             :     }
    1314      511959 :     return Sum.getCompl() / (Probs.size() - KnownProbNum);
    1315             :   } else
    1316      898381 :     return Prob;
    1317             : }
    1318             : 
    1319             : /// Set successor probability of a given iterator.
    1320         952 : void MachineBasicBlock::setSuccProbability(succ_iterator I,
    1321             :                                            BranchProbability Prob) {
    1322             :   assert(!Prob.isUnknown());
    1323         952 :   if (Probs.empty())
    1324             :     return;
    1325        1898 :   *getProbabilityIterator(I) = Prob;
    1326             : }
    1327             : 
    1328             : /// Return probability iterator corresonding to the I successor iterator
    1329             : MachineBasicBlock::const_probability_iterator
    1330     1430587 : MachineBasicBlock::getProbabilityIterator(
    1331             :     MachineBasicBlock::const_succ_iterator I) const {
    1332             :   assert(Probs.size() == Successors.size() && "Async probability list!");
    1333     2861174 :   const size_t index = std::distance(Successors.begin(), I);
    1334             :   assert(index < Probs.size() && "Not a current successor!");
    1335     2861174 :   return Probs.begin() + index;
    1336             : }
    1337             : 
    1338             : /// Return probability iterator corresonding to the I successor iterator.
    1339             : MachineBasicBlock::probability_iterator
    1340       38968 : MachineBasicBlock::getProbabilityIterator(MachineBasicBlock::succ_iterator I) {
    1341             :   assert(Probs.size() == Successors.size() && "Async probability list!");
    1342       38968 :   const size_t index = std::distance(Successors.begin(), I);
    1343             :   assert(index < Probs.size() && "Not a current successor!");
    1344       38968 :   return Probs.begin() + index;
    1345             : }
    1346             : 
    1347             : /// Return whether (physical) register "Reg" has been <def>ined and not <kill>ed
    1348             : /// as of just before "MI".
    1349             : ///
    1350             : /// Search is localised to a neighborhood of
    1351             : /// Neighborhood instructions before (searching for defs or kills) and N
    1352             : /// instructions after (searching just for defs) MI.
    1353             : MachineBasicBlock::LivenessQueryResult
    1354         677 : MachineBasicBlock::computeRegisterLiveness(const TargetRegisterInfo *TRI,
    1355             :                                            unsigned Reg, const_iterator Before,
    1356             :                                            unsigned Neighborhood) const {
    1357             :   unsigned N = Neighborhood;
    1358             : 
    1359             :   // Start by searching backwards from Before, looking for kills, reads or defs.
    1360         677 :   const_iterator I(Before);
    1361             :   // If this is the first insn in the block, don't search backwards.
    1362         677 :   if (I != begin()) {
    1363             :     do {
    1364             :       --I;
    1365             : 
    1366             :       MachineOperandIteratorBase::PhysRegInfo Info =
    1367        1993 :           ConstMIOperands(*I).analyzePhysReg(Reg, TRI);
    1368             : 
    1369             :       // Defs happen after uses so they take precedence if both are present.
    1370             : 
    1371             :       // Register is dead after a dead def of the full register.
    1372        1993 :       if (Info.DeadDef)
    1373         424 :         return LQR_Dead;
    1374             :       // Register is (at least partially) live after a def.
    1375        1588 :       if (Info.Defined) {
    1376          18 :         if (!Info.PartialDeadDef)
    1377             :           return LQR_Live;
    1378             :         // As soon as we saw a partial definition (dead or not),
    1379             :         // we cannot tell if the value is partial live without
    1380             :         // tracking the lanemasks. We are not going to do this,
    1381             :         // so fall back on the remaining of the analysis.
    1382           0 :         break;
    1383             :       }
    1384             :       // Register is dead after a full kill or clobber and no def.
    1385        1570 :       if (Info.Killed || Info.Clobbered)
    1386             :         return LQR_Dead;
    1387             :       // Register must be live if we read it.
    1388        1569 :       if (Info.Read)
    1389             :         return LQR_Live;
    1390        2986 :     } while (I != begin() && --N > 0);
    1391             :   }
    1392             : 
    1393             :   // Did we get to the start of the block?
    1394         253 :   if (I == begin()) {
    1395             :     // If so, the register's state is definitely defined by the live-in state.
    1396        2302 :     for (MCRegAliasIterator RAI(Reg, TRI, /*IncludeSelf=*/true); RAI.isValid();
    1397         913 :          ++RAI)
    1398        1826 :       if (isLiveIn(*RAI))
    1399           0 :         return LQR_Live;
    1400             : 
    1401         238 :     return LQR_Dead;
    1402             :   }
    1403             : 
    1404             :   N = Neighborhood;
    1405             : 
    1406             :   // Try searching forwards from Before, looking for reads or defs.
    1407          15 :   I = const_iterator(Before);
    1408             :   // If this is the last insn in the block, don't search forwards.
    1409          15 :   if (I != end()) {
    1410         127 :     for (++I; I != end() && N > 0; ++I, --N) {
    1411             :       MachineOperandIteratorBase::PhysRegInfo Info =
    1412          70 :           ConstMIOperands(*I).analyzePhysReg(Reg, TRI);
    1413             : 
    1414             :       // Register is live when we read it here.
    1415          70 :       if (Info.Read)
    1416          14 :         return LQR_Live;
    1417             :       // Register is dead if we can fully overwrite or clobber it here.
    1418          70 :       if (Info.FullyDefined || Info.Clobbered)
    1419             :         return LQR_Dead;
    1420             :     }
    1421             :   }
    1422             : 
    1423             :   // At this point we have no idea of the liveness of the register.
    1424             :   return LQR_Unknown;
    1425             : }
    1426             : 
    1427             : const uint32_t *
    1428      385692 : MachineBasicBlock::getBeginClobberMask(const TargetRegisterInfo *TRI) const {
    1429             :   // EH funclet entry does not preserve any registers.
    1430      385692 :   return isEHFuncletEntry() ? TRI->getNoPreservedMask() : nullptr;
    1431             : }
    1432             : 
    1433             : const uint32_t *
    1434      385692 : MachineBasicBlock::getEndClobberMask(const TargetRegisterInfo *TRI) const {
    1435             :   // If we see a return block with successors, this must be a funclet return,
    1436             :   // which does not preserve any registers. If there are no successors, we don't
    1437             :   // care what kind of return it is, putting a mask after it is a no-op.
    1438      602051 :   return isReturnBlock() && !succ_empty() ? TRI->getNoPreservedMask() : nullptr;
    1439             : }
    1440             : 
    1441        5854 : void MachineBasicBlock::clearLiveIns() {
    1442             :   LiveIns.clear();
    1443        5854 : }
    1444             : 
    1445     4987914 : MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
    1446             :   assert(getParent()->getProperties().hasProperty(
    1447             :       MachineFunctionProperties::Property::TracksLiveness) &&
    1448             :       "Liveness information is accurate");
    1449     4987914 :   return LiveIns.begin();
    1450             : }

Generated by: LCOV version 1.13