1//===-- llvm/CodeGen/MachineBasicBlock.cpp ----------------------*- C++ -*-===// 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 7//===----------------------------------------------------------------------===// 9// Collect the sequence of machine instructions for a basic block. 11//===----------------------------------------------------------------------===// 32#include "llvm/Config/llvm-config.h" 45#define DEBUG_TYPE "codegen" 49cl::desc(
"When printing machine IR, annotate instructions and blocks with " 50"SlotIndexes when available"),
54 : BB(
B),
Number(-1), xParent(&MF) {
57 IrrLoopHeaderWeight =
B->getIrrLoopHeaderWeight();
60MachineBasicBlock::~MachineBasicBlock() =
default;
62/// Return the MCSymbol for this basic block. 68// We emit a non-temporary symbol -- with a descriptive name -- if it begins 69// a section (with basic block sections). Otherwise we fall back to use temp 78// For symbols that represent basic block sections, we add ".__part." to 79// allow tools like symbolizers to know that this represents a part of 80// the original function. 85// If the block occurs as label in inline assembly, parsing the assembly 86// needs an actual label name => set AlwaysEmit in these cases. 96if (!CachedEHCatchretMCSymbol) {
103return CachedEHCatchretMCSymbol;
107if (!CachedEndMCSymbol) {
112/*AlwaysEmit=*/false);
114return CachedEndMCSymbol;
126/// When an MBB is added to an MF, we need to update the parent pointer of the 127/// MBB, the MBB numbering, and any instructions in the MBB to be on the right 128/// operand list for registers. 130/// MBBs start out as #-1. When a MBB is added to a MachineFunction, it 131/// gets the next available unique MBB number. If it is removed from a 132/// MachineFunction, it goes back to being #-1. 138// Make sure the instructions have their operands in the reginfo lists. 141MI.addRegOperandsToUseLists(RegInfo);
146N->getParent()->removeFromMBBNumbering(
N->Number);
150/// When we add an instruction to a basic block list, we update its parent 151/// pointer and add its operands from reg use/def lists if appropriate. 153assert(!
N->getParent() &&
"machine instruction already in a basic block");
156// Add the instruction's register operands to their corresponding 160 MF->handleInsertion(*
N);
163/// When we remove an instruction from a basic block list, we update its parent 164/// pointer and remove its operands from reg use/def lists if appropriate. 166assert(
N->getParent() &&
"machine instruction not in a basic block");
168// Remove from the use/def lists. 170 MF->handleRemoval(*
N);
174N->setParent(
nullptr);
177/// When moving a range of instructions from one MBB list to another, we need to 178/// update the parent pointers and the use/def lists. 181 instr_iterator
Last) {
182assert(Parent->getParent() == FromList.Parent->getParent() &&
183"cannot transfer MachineInstrs between MachineFunctions");
185// If it's within the same BB, there's nothing to do. 186if (
this == &FromList)
189assert(Parent != FromList.Parent &&
"Two lists have the same parent?");
191// If splicing between two blocks within the same function, just update the 194First->setParent(Parent);
198assert(!
MI->getParent() &&
"MI is still in a block!");
199 Parent->getParent()->deleteMachineInstr(
MI);
204while (
I != E &&
I->isPHI())
206assert((
I == E || !
I->isInsideBundle()) &&
207"First non-phi MI cannot be inside a bundle!");
216while (
I != E && (
I->isPHI() ||
I->isPosition() ||
217TII->isBasicBlockPrologue(*
I)))
219// FIXME: This needs to change if we wish to bundle labels 221assert((
I == E || !
I->isInsideBundle()) &&
222"First non-phi / non-label instruction is inside a bundle!");
232while (
I != E && (
I->isPHI() ||
I->isPosition() ||
I->isDebugInstr() ||
233 (SkipPseudoOp &&
I->isPseudoProbe()) ||
234TII->isBasicBlockPrologue(*
I, Reg)))
236// FIXME: This needs to change if we wish to bundle labels / dbg_values 238assert((
I == E || !
I->isInsideBundle()) &&
239"First non-phi / non-label / non-debug " 240"instruction is inside a bundle!");
246while (
I !=
B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
248while (
I != E && !
I->isTerminator())
255while (
I !=
B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
257while (
I != E && !
I->isTerminator())
268// Skip over begin-of-block dbg_value instructions. 274// Skip over end-of-block dbg_value instructions. 278// Return instruction that starts a bundle. 279if (
I->isDebugInstr() ||
I->isInsideBundle())
281if (SkipPseudoOp &&
I->isPseudoProbe())
285// The block is all debug values. 300#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 308if (Succ->isInlineAsmBrIndirectTarget())
322return LBB->hasName();
328return LBB->getName();
333/// Return a hopefully unique identifier for this block. 346bool IsStandalone)
const{
349OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 357print(
OS, MST, Indexes, IsStandalone);
362bool IsStandalone)
const{
365OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 379bool HasLineAttributes =
false;
381// Print the preds of this block according to the CFG. 383if (Indexes)
OS <<
'\t';
384// Don't indent(2), align with previous line attributes. 385OS <<
"; predecessors: ";
390 HasLineAttributes =
true;
394if (Indexes)
OS <<
'\t';
395// Print the successors 405if (!Probs.empty() && IsStandalone) {
406// Print human readable probabilities as comments. 421 HasLineAttributes =
true;
425if (Indexes)
OS <<
'\t';
429for (
constauto &LI :
liveins()) {
431if (!LI.LaneMask.all())
434 HasLineAttributes =
true;
437if (HasLineAttributes)
440bool IsInBundle =
false;
448if (IsInBundle && !
MI.isInsideBundle()) {
454MI.
print(
OS, MST, IsStandalone,
/*SkipOpers=*/false,
/*SkipDebugLoc=*/false,
455/*AddNewLine=*/false, &
TII);
467if (IrrLoopHeaderWeight && IsStandalone) {
468if (Indexes)
OS <<
'\t';
469OS.
indent(2) <<
"; Irreducible loop header weight: " << *IrrLoopHeaderWeight
474/// Print the basic block's name as: 476/// bb.{number}[.{ir-name}] [(attributes...)] 478/// The {ir-name} is only printed when the \ref PrintNameIr flag is passed 479/// (which is the default). If the IR block has no name, it is identified 480/// numerically using the attribute syntax as "(%ir-block.{ir-slot})". 482/// When the \ref PrintNameAttributes flag is passed, additional attributes 483/// of the block are printed when set. 485/// \param printNameFlags Combination of \ref PrintNameFlag flags indicating 486/// the parts to print. 487/// \param moduleSlotTracker Optional ModuleSlotTracker. This method will 488/// incorporate its own tracker when necessary to 489/// determine the block's IR name. 493bool hasAttributes =
false;
502if (moduleSlotTracker) {
504 }
elseif (bb->getParent()) {
511 os <<
"<ir-block badref>";
520 os <<
'.' << bb->getName();
531 os << (hasAttributes ?
", " :
" (");
532 os <<
"machine-block-address-taken";
536 os << (hasAttributes ?
", " :
" (");
537 os <<
"ir-block-address-taken ";
542 os << (hasAttributes ?
", " :
" (");
547 os << (hasAttributes ?
", " :
" (");
548 os <<
"inlineasm-br-indirect-target";
552 os << (hasAttributes ?
", " :
" (");
553 os <<
"ehfunclet-entry";
557 os << (hasAttributes ?
", " :
" (");
562 os << (hasAttributes ?
", " :
" (");
577 os << (hasAttributes ?
", " :
" (");
578 os <<
"bb_id " <<
getBBID()->BaseID;
583if (CallFrameSize != 0) {
584 os << (hasAttributes ?
", " :
" (");
585 os <<
"call-frame-size " << CallFrameSize;
595bool/*PrintType*/)
const{
603if (
I == LiveIns.end())
606I->LaneMask &= ~LaneMask;
607if (
I->LaneMask.none())
613// Get non-const version of iterator. 614 LiveInVector::iterator LI = LiveIns.begin() + (
I - LiveIns.begin());
615return LiveIns.erase(LI);
621returnI !=
livein_end() && (
I->LaneMask & LaneMask).any();
629// Liveins are sorted by physreg now we can merge their lanemasks. 630 LiveInVector::const_iterator
I = LiveIns.begin();
631 LiveInVector::const_iterator J;
632 LiveInVector::iterator Out = LiveIns.begin();
633for (;
I != LiveIns.end(); ++Out,
I = J) {
636for (J = std::next(
I); J != LiveIns.end() && J->PhysReg == PhysReg; ++J)
637 LaneMask |= J->LaneMask;
638 Out->PhysReg = PhysReg;
639 Out->LaneMask = LaneMask;
641 LiveIns.erase(Out, LiveIns.end());
648assert(RC &&
"Register class is required");
650"Only the entry block and landing pads can have physreg live ins");
657// Look for an existing copy. 659for (;
I != E &&
I->isCopy(); ++
I)
660if (
I->getOperand(1).getReg() == PhysReg) {
661Register VirtReg =
I->getOperand(0).getReg();
662if (!
MRI.constrainRegClass(VirtReg, RC))
667// No luck, create a virtual register. 686if (TerminatorI ==
MBB.
end())
690returnTII->getJumpTableIndex(Terminator);
699// A block with no successors has no concerns with fall-through edges. 708assert(!
B &&
"UpdateTerminators requires analyzable predecessors!");
711// The block has an unconditional branch. If its successor is now its 712// layout successor, delete the branch. 716// The block has an unconditional fallthrough, or the end of the block is 719// Unfortunately, whether the end of the block is unreachable is not 720// immediately obvious; we must fall back to checking the successor list, 721// and assuming that if the passed in block is in the succesor list and 722// not an EHPad, it must be the intended target. 723if (!PreviousLayoutSuccessor || !
isSuccessor(PreviousLayoutSuccessor) ||
724 PreviousLayoutSuccessor->
isEHPad())
727// If the unconditional successor block is not the current layout 728// successor, insert a branch to jump to it. 736// The block has a non-fallthrough conditional branch. If one of its 737// successors is its layout successor, rewrite it to a fallthrough 738// conditional branch. 751// We now know we're going to fallthrough to PreviousLayoutSuccessor. 752assert(PreviousLayoutSuccessor);
756if (PreviousLayoutSuccessor ==
TBB) {
757// We had a fallthrough to the same basic block as the conditional jump 758// targets. Remove the conditional jump, leaving an unconditional 759// fallthrough or an unconditional jump. 768// The block has a fallthrough conditional branch. 771// We can't reverse the condition, add an unconditional branch. 787for (
auto Prob : Probs)
788 Sum += Prob.getNumerator();
789// Due to precision issue, we assume that the sum of probabilities is one if 790// the difference between the sum of their numerators and the denominator is 791// no greater than the number of successors. 794"The sum of successors's probabilities exceeds one.");
800// Probability list is either empty (if successor list isn't empty, this means 801// disabled optimization) or has the same size as successor list. 802if (!(Probs.empty() && !Successors.empty()))
803 Probs.push_back(Prob);
804 Successors.push_back(Succ);
805 Succ->addPredecessor(
this);
809// We need to make sure probability list is either empty or has the same size 810// of successor list. When this function is called, we can safely delete all 811// probability in the list. 813 Successors.push_back(Succ);
814 Succ->addPredecessor(
this);
819bool NormalizeSuccProbs) {
821assert(OldI !=
succ_end() &&
"Old is not a successor of this block!");
823"New is already a successor of this block!");
825// Add a new successor with equal probability as the original one. Note 826// that we directly copy the probability using the iterator rather than 827// getting a potentially synthetic probability computed when unknown. This 828// preserves the probabilities as-is and then we can renormalize them and 829// query them effectively afterward. 831 : *getProbabilityIterator(OldI));
832if (NormalizeSuccProbs)
837bool NormalizeSuccProbs) {
844assert(
I != Successors.end() &&
"Not a current successor!");
846// If probability list is empty it means we don't use it (disabled 849 probability_iterator WI = getProbabilityIterator(
I);
851if (NormalizeSuccProbs)
855 (*I)->removePredecessor(
this);
856return Successors.erase(
I);
879assert(OldI != E &&
"Old is not a successor of this block");
881// If New isn't already a successor, let it take Old's place. 883 Old->removePredecessor(
this);
884 New->addPredecessor(
this);
889// New is already a successor. 890// Update its probability instead of adding a duplicate edge. 892auto ProbIter = getProbabilityIterator(NewI);
893if (!ProbIter->isUnknown())
894 *ProbIter += *getProbabilityIterator(OldI);
901if (!Orig->Probs.empty())
908 Predecessors.push_back(Pred);
913assert(
I != Predecessors.end() &&
"Pred is not a predecessor of this block!");
914 Predecessors.erase(
I);
924// If probability list is empty it means we don't use it (disabled 926if (!FromMBB->Probs.empty()) {
927auto Prob = *FromMBB->Probs.begin();
943if (!FromMBB->Probs.empty()) {
944auto Prob = *FromMBB->Probs.begin();
950// Fix up any PHI nodes in the successor. 970return Successors.size() == 1 ? Successors[0] :
nullptr;
974return Predecessors.size() == 1 ? Predecessors[0] :
nullptr;
980// If FallthroughBlock is off the end of the function, it can't fall through. 984// If FallthroughBlock isn't a successor, no fallthrough is possible. 988// Analyze the branches, if any, at the end of the block. 993// If we couldn't analyze the branch, examine the last instruction. 994// If the block doesn't end in a known control barrier, assume fallthrough 995// is possible. The isPredicated check is needed because this code can be 996// called during IfConversion, where an instruction which is normally a 997// Barrier is predicated and thus no longer an actual control barrier. 1003// If there is no branch, control always falls through. 1004if (!
TBB)
return &*Fallthrough;
1006// If there is some explicit branch to the fallthrough block, it can obviously 1007// reach, even though the branch should get folded to fall through implicitly. 1010return &*Fallthrough;
1012// If it's an unconditional branch to some block not the fall through, it 1013// doesn't fall through. 1014if (
Cond.empty())
returnnullptr;
1016// Otherwise, if it is conditional and has no explicit false block, it falls 1018return (FBB ==
nullptr) ? &*Fallthrough :
nullptr;
1031if (SplitPoint ==
end()) {
1032// Don't bother with a new block. 1040// Make sure we add any physregs we define in the block as liveins to the 1066// Returns `true` if there are possibly other users of the jump table at 1067// `JumpTableIndex` except for the ones in `IgnoreMBB`. 1070int JumpTableIndex) {
1071assert(JumpTableIndex >= 0 &&
"need valid index");
1074// Take any basic block from the table; every user of the jump table must 1075// show up in the predecessor list. 1084returntrue;
// can't rule out other users if there isn't any block. 1088if (Pred == &IgnoreMBB)
1094/*AllowModify=*/false)) {
1095// analyzable direct jump 1100if (PredJTI == JumpTableIndex)
1104// Be conservative for unanalyzable jumps. 1118 : MF(MF), Indexes(Indexes) {
1124for (
autoMI : Insertions)
1129// This is called before MI is inserted into block so defer index update. 1135if (Indexes && !Insertions.
remove(&
MI))
1140#define GET_RESULT(RESULT, GETTER, INFIX) \ 1143 auto *Wrapper = P->getAnalysisIfAvailable<RESULT##INFIX##WrapperPass>(); \ 1144 return Wrapper ? &Wrapper->GETTER() : nullptr; \ 1146 return MFAM->getCachedResult<RESULT##Analysis>(*MF); \ 1152assert((
P || MFAM) &&
"Need a way to get analysis results!");
1162// Is there an indirect jump with jump table? 1163bool ChangedIndirectJump =
false;
1168 ChangedIndirectJump =
true;
1183// On some targets like Mips, branches may kill virtual registers. Make sure 1184// that LiveVariables is properly updated after updateTerminator replaces the 1188// Collect a list of virtual registers killed by the terminators. 1194if (MO.getReg() == 0 || !MO.isKill() || MO.isUndef())
1200 MO.setIsKill(
false);
1210if (!MO.isReg() || MO.getReg() == 0)
1222// Since we replaced all uses of Succ with NMBB, that should also be treated 1223// as the fallthrough successor 1224if (Succ == PrevFallthrough)
1225 PrevFallthrough = NMBB;
1227if (!ChangedIndirectJump) {
1232// Insert unconditional "jump Succ" instruction in NMBB if necessary. 1239// In original 'this' BB, there must be a branch instruction targeting at 1240// Succ. We can not find it out since currently getBranchDestBlock was not 1241// implemented for all targets. However, if the merged DL has column or line 1242// number, the scope and non-zero column and line number is same with that 1243// branch instruction so we can safely use it. 1250// Fix PHI nodes in Succ so they refer to NMBB instead of this. 1253// Inherit live-ins from the successor 1254for (
constauto &LI : Succ->
liveins())
1257// Update LiveVariables. 1260// Restore kills of virtual registers that were killed by the terminators. 1261while (!KilledRegs.
empty()) {
1264if (!(--
I)->addRegisterKilled(Reg,
TRI,
/* AddIfNotFound= */false))
1272// Update relevant live-through information. 1273if (LiveInSets !=
nullptr)
1280// After splitting the edge and updating SlotIndexes, live intervals may be 1281// in one of two situations, depending on whether this block was the last in 1282// the function. If the original block was the last in the function, all 1283// live intervals will end prior to the beginning of the new split block. If 1284// the original block was not at the end of the function, all live intervals 1285// will extend to the end of the new split block. 1294// Find the registers used from NMBB in PHIs in Succ. 1298I != E &&
I->isPHI(); ++
I) {
1299for (
unsigned ni = 1, ne =
I->getNumOperands(); ni != ne; ni += 2) {
1300if (
I->getOperand(ni+1).getMBB() == NMBB) {
1310"PHI sources should be live out of their predecessors.");
1319for (
unsigned i = 0, e =
MRI->getNumVirtRegs(); i != e; ++i) {
1325if (!LI.
liveAt(PrevIndex))
1331assert(VNI &&
"LiveInterval should have VNInfo where it is live.");
1333// Update subranges with live values 1335VNInfo *VNI = SR.getVNInfoAt(PrevIndex);
1342 SR.removeSegment(StartIndex, EndIndex);
1346// Update all intervals for registers whose uses may have been modified by 1347// updateTerminator(). 1356// If one or the other blocks were not in a loop, the new block is not 1357// either, and thus LI doesn't need to be updated. 1358if (
MachineLoop *DestLoop = MLI->getLoopFor(Succ)) {
1359if (TIL == DestLoop) {
1360// Both in the same loop, the NMBB joins loop. 1361 DestLoop->addBasicBlockToLoop(NMBB, *MLI);
1362 }
elseif (TIL->contains(DestLoop)) {
1363// Edge from an outer loop to an inner loop. Add to the outer loop. 1364 TIL->addBasicBlockToLoop(NMBB, *MLI);
1365 }
elseif (DestLoop->contains(TIL)) {
1366// Edge from an inner loop to an outer loop. Add to the outer loop. 1367 DestLoop->addBasicBlockToLoop(NMBB, *MLI);
1369// Edge from two loops with no containment relation. Because these 1370// are natural loops, we know that the destination block must be the 1371// header of its loop (adding a branch into a loop elsewhere would 1372// create an irreducible loop). 1373assert(DestLoop->getHeader() == Succ &&
1374"Should not create irreducible loops!");
1376P->addBasicBlockToLoop(NMBB, *MLI);
1386// Splitting the critical edge to a landing pad block is non-trivial. Don't do 1387// it in this generic function. 1391// Splitting the critical edge to a callbr's indirect block isn't advised. 1392// Don't do it in this generic function. 1397// Performance might be harmed on HW that implements branching using exec mask 1398// where both sides of the branches are always executed. 1402// Do we have an Indirect jump with a jumptable that we can rewrite? 1407// We may need to update this's terminator, but we can't do that if 1408// analyzeBranch fails. 1412// AnalyzeBanch should modify this, since we did not allow modification. 1414/*AllowModify*/false))
1417// Avoid bugpoint weirdness: A block may end with a conditional branch but 1418// jumps to the same MBB is either case. We have duplicate CFG edges in that 1419// case that we can't handle. Since this never happens in properly optimized 1420// code, just skip those edges. 1429/// Prepare MI to be removed from its bundle. This fixes bundle flags on MI's 1430/// neighboring instructions so the bundle won't be broken by removing MI. 1432// Removing the first instruction in a bundle. 1433if (
MI->isBundledWithSucc() && !
MI->isBundledWithPred())
1434MI->unbundleFromSucc();
1435// Removing the last instruction in a bundle. 1436if (
MI->isBundledWithPred() && !
MI->isBundledWithSucc())
1437MI->unbundleFromPred();
1438// If MI is not bundled, or if it is internal to a bundle, the neighbor flags 1457assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
1458"Cannot insert instruction with bundle flags");
1459// Set the bundle flags when inserting inside a bundle. 1467/// This method unlinks 'this' from the containing function, and returns it, but 1468/// does not delete it. 1475/// This method unlinks 'this' from the containing function, and deletes it. 1481/// Given a machine basic block that branched to 'Old', change the code and CFG 1482/// so that it branches to 'New' instead. 1485assert(Old != New &&
"Cannot replace self with self!");
1490if (!
I->isTerminator())
break;
1492// Scan the operands of this machine instruction, replacing any uses of Old 1495if (MO.isMBB() && MO.getMBB() == Old)
1499// Update the successor information. 1506for (
unsigned i = 2, e =
MI.getNumOperands() + 1; i != e; i += 2) {
1513/// Find the next valid DebugLoc starting at MBBI, skipping any debug 1514/// instructions. Return UnknownLoc if there is none. 1517// Skip debug declarations, we don't want a DebugLoc from them. 1520returnMBBI->getDebugLoc();
1527// Skip debug declarations, we don't want a DebugLoc from them. 1529if (!
MBBI->isDebugInstr())
1530returnMBBI->getDebugLoc();
1534/// Find the previous valid DebugLoc preceding MBBI, skipping any debug 1535/// instructions. Return UnknownLoc if there is none. 1539// Skip debug instructions, we don't want a DebugLoc from them. 1541if (!
MBBI->isDebugInstr())
1542returnMBBI->getDebugLoc();
1549// Skip debug declarations, we don't want a DebugLoc from them. 1552returnMBBI->getDebugLoc();
1556/// Find and return the merged DebugLoc of the branch instructions of the block. 1557/// Return UnknownLoc if there is none. 1562while (TI !=
end() && !TI->isBranch())
1566DL = TI->getDebugLoc();
1567for (++TI ; TI !=
end() ; ++TI)
1574/// Return probability of the edge from this block to MBB. 1580constauto &Prob = *getProbabilityIterator(Succ);
1581if (Prob.isUnknown()) {
1582// For unknown probabilities, collect the sum of all known ones, and evenly 1583// ditribute the complemental of the sum to each unknown probability. 1584unsigned KnownProbNum = 0;
1586for (
constauto &
P : Probs) {
1587if (!
P.isUnknown()) {
1592return Sum.getCompl() / (Probs.size() - KnownProbNum);
1597/// Set successor probability of a given iterator. 1603 *getProbabilityIterator(
I) = Prob;
1606/// Return probability iterator corresonding to the I successor iterator 1607MachineBasicBlock::const_probability_iterator
1608MachineBasicBlock::getProbabilityIterator(
1610assert(Probs.size() == Successors.size() &&
"Async probability list!");
1611constsize_t index = std::distance(Successors.begin(),
I);
1612assert(index < Probs.size() &&
"Not a current successor!");
1613return Probs.begin() + index;
1616/// Return probability iterator corresonding to the I successor iterator. 1617MachineBasicBlock::probability_iterator
1619assert(Probs.size() == Successors.size() &&
"Async probability list!");
1620constsize_t index = std::distance(Successors.begin(),
I);
1621assert(index < Probs.size() &&
"Not a current successor!");
1622return Probs.begin() + index;
1625/// Return whether (physical) register "Reg" has been <def>ined and not <kill>ed 1626/// as of just before "MI". 1628/// Search is localised to a neighborhood of 1629/// Neighborhood instructions before (searching for defs or kills) and N 1630/// instructions after (searching just for defs) MI. 1634unsigned Neighborhood)
const{
1635unsignedN = Neighborhood;
1637// Try searching forwards from Before, looking for reads or defs. 1639for (;
I !=
end() &&
N > 0; ++
I) {
1640if (
I->isDebugOrPseudoInstr())
1647// Register is live when we read it here. 1650// Register is dead if we can fully overwrite or clobber it here. 1651if (
Info.FullyDefined ||
Info.Clobbered)
1655// If we reached the end, it is safe to clobber Reg at the end of a block of 1656// no successor has it live in. 1660if (
TRI->regsOverlap(LI.PhysReg, Reg))
1671// Start by searching backwards from Before, looking for kills, reads or defs. 1673// If this is the first insn in the block, don't search backwards. 1678if (
I->isDebugOrPseudoInstr())
1685// Defs happen after uses so they take precedence if both are present. 1687// Register is dead after a dead def of the full register. 1690// Register is (at least partially) live after a def. 1692if (!
Info.PartialDeadDef)
1694// As soon as we saw a partial definition (dead or not), 1695// we cannot tell if the value is partial live without 1696// tracking the lanemasks. We are not going to do this, 1697// so fall back on the remaining of the analysis. 1700// Register is dead after a full kill or clobber and no def. 1703// Register must be live if we read it. 1710// If all the instructions before this in the block are debug instructions, 1712while (
I !=
begin() && std::prev(
I)->isDebugOrPseudoInstr())
1715// Did we get to the start of the block? 1717// If so, the register's state is definitely defined by the live-in state. 1719if (
TRI->regsOverlap(LI.PhysReg, Reg))
1725// At this point we have no idea of the liveness of the register. 1731// EH funclet entry does not preserve any registers. 1737// If we see a return block with successors, this must be a funclet return, 1738// which does not preserve any registers. If there are no successors, we don't 1739// care what kind of return it is, putting a mask after it is a no-op. 1748 std::vector<RegisterMaskPair> &OldLiveIns) {
1749assert(OldLiveIns.empty() &&
"Vector must be empty");
1756"Liveness information is accurate");
1757return LiveIns.begin();
1764"Liveness information is accurate");
1767MCPhysReg ExceptionPointer = 0, ExceptionSelector = 0;
1780for (
autoI = R.begin(), E = R.end();
I != E; ++
I) {
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Analysis containing CSE Info
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define GET_RESULT(RESULT, GETTER, INFIX)
static bool jumpTableHasOtherUses(const MachineFunction &MF, const MachineBasicBlock &IgnoreMBB, int JumpTableIndex)
static void unbundleSingleMI(MachineInstr *MI)
Prepare MI to be removed from its bundle.
static int findJumpTableIndex(const MachineBasicBlock &MBB)
static cl::opt< bool > PrintSlotIndexes("print-slotindexes", cl::desc("When printing machine IR, annotate instructions and blocks with " "SlotIndexes when available"), cl::init(true), cl::Hidden)
unsigned const TargetRegisterInfo * TRI
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)
This file contains some templates that are useful if you are working with the STL at all.
This file contains some functions that are useful when dealing with strings.
This file describes how to lower LLVM code to machine code.
SlotIndexUpdateDelegate(MachineFunction &MF, SlotIndexes *Indexes)
~SlotIndexUpdateDelegate()
void MF_HandleRemoval(MachineInstr &MI) override
Callback before a removal. This should not modify the MI directly.
void MF_HandleInsertion(MachineInstr &MI) override
Callback after an insertion. This should not modify the MI directly.
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
static uint32_t getDenominator()
static BranchProbability getUnknown()
uint32_t getNumerator() const
static BranchProbability getZero()
static DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
bool hasPersonalityFn() const
Check whether this function has a personality function.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void splitCriticalEdge(BasicBlockT *FromBB, BasicBlockT *ToBB, BasicBlockT *NewBB)
Apply updates that the critical edge (FromBB, ToBB) has been split with NewBB.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Remove the branching code at the end of the specific MBB.
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
Reverses the branch condition of the specified condition list, returning false on success and true if...
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Insert branch code into the end of the specified MachineBasicBlock.
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator_range< subrange_iterator > subranges()
void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< Register > OrigRegs)
Update live intervals for instructions in a range of iterators.
bool hasInterval(Register Reg) const
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
void insertMBBInMaps(MachineBasicBlock *MBB)
LiveInterval & getInterval(Register Reg)
A set of physical registers with utility functions to track liveness when walking backward/forward th...
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
bool liveAt(SlotIndex index) const
void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified interval from this live range.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
VarInfo & getVarInfo(Register Reg)
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
void addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB)
addNewBlock - Add a new basic block BB between DomBB and SuccBB.
Context object for machine code objects.
MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findPrevDebugLoc (it also searches towards the beginning of this MBB) exce...
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
bool hasEHPadSuccessor() const
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
livein_iterator livein_end() const
iterator getFirstTerminatorForward()
Finds the first terminator in a block by scanning forward.
bool isEHPad() const
Returns true if the block is a landing pad.
void replacePhiUsesWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it.
instr_iterator instr_begin()
MachineInstrBundleIterator< const MachineInstr > const_iterator
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
SmallVectorImpl< MachineBasicBlock * >::const_iterator const_succ_iterator
MCSymbol * getEHCatchretSymbol() const
Return the EHCatchret Symbol for this basic block.
void moveBefore(MachineBasicBlock *NewAfter)
Move 'this' block before or after the specified block.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
iterator_range< livein_iterator > liveins() const
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
reverse_instr_iterator instr_rbegin()
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
bool hasName() const
Check if there is a name of corresponding LLVM basic block.
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
std::optional< UniqueBBID > getBBID() const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)
Split the old successor into old plus new and updates the probability info.
@ PrintNameIr
Add IR name where available.
@ PrintNameAttributes
Print attributes.
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
const MachineBasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor.
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
bool canFallThrough()
Return true if the block can implicitly transfer control to the block after it by falling off the end...
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the first non-debug instruction in the basic block, or end().
succ_iterator succ_begin()
bool livein_empty() const
void removeLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
void validateSuccProbs() const
Validate successors' probabilities and check if the sum of them is approximate one.
bool isIRBlockAddressTaken() const
Test whether this block is the target of an IR BlockAddress.
LiveInVector::const_iterator livein_iterator
MCSymbol * getEndSymbol() const
Returns the MCSymbol marking the end of this basic block.
void clearLiveIns()
Clear live in list.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, MCRegister Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
livein_iterator livein_begin() const
unsigned succ_size() const
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the start of this basic block.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
bool isEntryBlock() const
Returns true if this is the entry block of the function.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
SmallVectorImpl< MachineBasicBlock * >::iterator succ_iterator
BasicBlock * getAddressTakenIRBlock() const
Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
const MachineBasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
liveout_iterator liveout_begin() const
Iterator scanning successor basic blocks' liveins to determine the registers potentially live at the ...
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findDebugLoc (it also searches towards the end of this MBB) except that th...
void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
reverse_instr_iterator instr_rend()
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
Instructions::iterator instr_iterator
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
DebugLoc findPrevDebugLoc(instr_iterator MBBI)
Find the previous valid DebugLoc preceding MBBI, skipping any debug instructions.
MachineBasicBlock * splitAt(MachineInstr &SplitInst, bool UpdateLiveIns=true, LiveIntervals *LIS=nullptr)
Split a basic block into 2 pieces at SplitPoint.
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
instr_iterator instr_end()
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
bool isBeginSection() const
Returns true if this block begins any section.
unsigned getCallFrameSize() const
Return the call frame size on entry to this basic block.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
iterator_range< succ_iterator > successors()
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
reverse_iterator rbegin()
bool isMachineBlockAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const
Print the basic block's name as:
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
Align getAlignment() const
Return alignment of the basic block.
bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const
Check if the edge between this block and the given successor Succ, can be split.
bool isLegalToHoistInto() const
Returns true if it is legal to hoist instructions into this block.
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool mayHaveInlineAsmBr() const
Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
@ LQR_Dead
Register is known to be fully dead.
@ LQR_Live
Register is known to be (at least partially) live.
@ LQR_Unknown
Register liveness not decidable from local neighborhood.
void moveAfter(MachineBasicBlock *NewBefore)
const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the end of the basic block.
bool sizeWithoutDebugLargerThan(unsigned Limit) const
bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
MachineBasicBlock * removeFromParent()
This method unlinks 'this' from the containing function, and returns it, but does not delete it.
Instructions::reverse_iterator reverse_instr_iterator
bool hasProperty(Property P) const
unsigned addToMBBNumbering(MachineBasicBlock *MBB)
Adds the MBB to the internal numbering.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
MCContext & getContext() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void resetDelegate(Delegate *delegate)
Reset the currently registered delegate - otherwise assert.
Function & getFunction()
Return the LLVM function that this machine code represents.
void remove(iterator MBBI)
const MachineFunctionProperties & getProperties() const
Get the function properties.
void setDelegate(Delegate *delegate)
Set the delegate.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
void splice(iterator InsertPt, iterator MBBI)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void erase(iterator MBBI)
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
BasicBlockListType::const_iterator const_iterator
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
Representation of each machine instruction.
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
const std::vector< MachineJumpTableEntry > & getJumpTables() const
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getMBB() const
void setMBB(MachineBasicBlock *MBB)
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Manage lifetime of a slot tracker for printing IR.
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
void incorporateFunction(const Function &F)
Incorporate the given function.
A Module instance is used to store all the information related to an LLVM module.
Pass interface - Implemented by all 'passes'.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
Simple wrapper around std::function<void(raw_ostream&)>.
Wrapper class representing virtual and physical registers.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
bool remove(const value_type &X)
Remove an item from the set vector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
void removeMachineInstrFromMaps(MachineInstr &MI, bool AllowBundled=false)
Removes machine instruction (bundle) MI from the mapping.
void insertMBBInMaps(MachineBasicBlock *mbb)
Add the given MachineBasicBlock into the maps.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
virtual Register getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
virtual Register getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool requiresStructuredCFG() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetLowering * getTargetLowering() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
VNInfo - Value Number Information.
StringRef getName() const
Return a constant reference to the value's name.
self_iterator getIterator()
MachineBasicBlock * getNextNode()
Get the next node, or nullptr for the list tail.
iterator erase(iterator where)
pointer remove(iterator &IT)
iterator insert(iterator where, pointer New)
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Kill
The last use of a register.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
PhysRegInfo AnalyzePhysRegInBundle(const MachineInstr &MI, Register Reg, const TargetRegisterInfo *TRI)
AnalyzePhysRegInBundle - Analyze how the current instruction or bundle uses a physical register.
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
IterT skipDebugInstructionsBackward(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It, then continue decrementing it while it points to a debug instruction.
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
This represents a simple continuous liveness interval for a value.
bool removeKill(MachineInstr &MI)
removeKill - Delete a kill corresponding to the specified machine instruction.
std::vector< MachineInstr * > Kills
Kills - List of MachineInstruction's which are the last use of this virtual register (kill it) in the...
static const MBBSectionID ExceptionSectionID
static const MBBSectionID ColdSectionID
enum llvm::MBBSectionID::SectionType Type
Pair of physical register and lane mask.
MachineJumpTableEntry - One jump table in the jump table info.
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
Information about how a physical register Reg is used by a set of operands.
static void deleteNode(NodeTy *V)
void removeNodeFromList(NodeTy *)
void addNodeToList(NodeTy *)
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callback before transferring nodes to this list.
Template traits for intrusive list.