LLVM: lib/CodeGen/MachineBasicBlock.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

31#include "llvm/Config/llvm-config.h"

39#include

40#include

41using namespace llvm;

42

43#define DEBUG_TYPE "codegen"

44

46 "print-slotindexes",

47 cl::desc("When printing machine IR, annotate instructions and blocks with "

48 "SlotIndexes when available"),

50

52 : BB(B), Number(-1), xParent(&MF) {

53 Insts.Parent = this;

54 if (B)

55 IrrLoopHeaderWeight = B->getIrrLoopHeaderWeight();

56}

57

58MachineBasicBlock::~MachineBasicBlock() = default;

59

60

62 if (!CachedMCSymbol) {

65

66

67

68

72 Suffix += ".cold";

74 Suffix += ".eh";

75 } else {

76

77

78

79 Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str();

80 }

81 CachedMCSymbol = Ctx.getOrCreateSymbol(MF->getName() + Suffix);

82 } else {

83

84

85 CachedMCSymbol = Ctx.createBlockSymbol(

88 }

89 }

90 return CachedMCSymbol;

91}

92

94 if (!CachedEHContMCSymbol) {

100 }

101 return CachedEHContMCSymbol;

102}

103

105 if (!CachedEndMCSymbol) {

110 false);

111 }

112 return CachedEndMCSymbol;

113}

114

116 MBB.print(OS);

117 return OS;

118}

119

123

124

125

126

127

128

129

130

135

136

139 MI.addRegOperandsToUseLists(RegInfo);

140}

141

144 N->getParent()->removeFromMBBNumbering(N->Number);

145 N->Number = -1;

146}

147

148

149

151 assert(N->getParent() && "machine instruction already in a basic block");

152 N->setParent(Parent);

153

154

155

157 N->addRegOperandsToUseLists(MF->getRegInfo());

158 MF->handleInsertion(*N);

159}

160

161

162

164 assert(N->getParent() && "machine instruction not in a basic block");

165

166

168 MF->handleRemoval(*N);

169 N->removeRegOperandsFromUseLists(MF->getRegInfo());

170 }

171

172 N->setParent(nullptr);

173}

174

175

176

178 instr_iterator First,

179 instr_iterator Last) {

180 assert(Parent->getParent() == FromList.Parent->getParent() &&

181 "cannot transfer MachineInstrs between MachineFunctions");

182

183

184 if (this == &FromList)

185 return;

186

187 assert(Parent != FromList.Parent && "Two lists have the same parent?");

188

189

190

192 First->setParent(Parent);

193}

194

196 assert(MI->getParent() && "MI is still in a block!");

197 Parent->getParent()->deleteMachineInstr(MI);

198}

199

202 while (I != E && I->isPHI())

203 ++I;

204 assert((I == E || I->isInsideBundle()) &&

205 "First non-phi MI cannot be inside a bundle!");

206 return I;

207}

208

212

214 while (I != E && (I->isPHI() || I->isPosition() ||

215 TII->isBasicBlockPrologue(*I)))

216 ++I;

217

218

219 assert((I == E || I->isInsideBundle()) &&

220 "First non-phi / non-label instruction is inside a bundle!");

221 return I;

222}

223

226 Register Reg, bool SkipPseudoOp) {

228

230 while (I != E && (I->isPHI() || I->isPosition() || I->isDebugInstr() ||

231 (SkipPseudoOp && I->isPseudoProbe()) ||

232 TII->isBasicBlockPrologue(*I, Reg)))

233 ++I;

234

235

236 assert((I == E || I->isInsideBundle()) &&

237 "First non-phi / non-label / non-debug "

238 "instruction is inside a bundle!");

239 return I;

240}

241

244 while (I != B && ((--I)->isTerminator() || I->isDebugInstr()))

245 ;

246 while (I != E && I->isTerminator())

247 ++I;

248 return I;

249}

250

253 while (I != B && ((--I)->isTerminator() || I->isDebugInstr()))

254 ;

255 while (I != E && I->isTerminator())

256 ++I;

257 return I;

258}

259

263

269

272

274 while (I != B) {

275 --I;

276

277 if (I->isDebugInstr() || I->isInsideBundle())

278 continue;

279 if (SkipPseudoOp && I->isPseudoProbe())

280 continue;

281 return I;

282 }

283

284 return end();

285}

286

288 for (const MachineBasicBlock *Succ : successors())

289 if (Succ->isEHPad())

290 return true;

291 return false;

292}

293

297

298#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

302#endif

303

305 for (const MachineBasicBlock *Succ : successors()) {

306 if (Succ->isInlineAsmBrIndirectTarget())

307 return true;

308 }

309 return false;

310}

311

314 return false;

315 return true;

316}

317

320 return LBB->hasName();

321 return false;

322}

323

326 return LBB->getName();

327 else

329}

330

331

333 std::string Name;

338 else

340 return Name;

341}

342

344 bool IsStandalone) const {

346 if (!MF) {

347 OS << "Can't print out MachineBasicBlock because parent MachineFunction"

348 << " is null\n";

349 return;

350 }

352 const Module *M = F.getParent();

355 print(OS, MST, Indexes, IsStandalone);

356}

357

360 bool IsStandalone) const {

362 if (!MF) {

363 OS << "Can't print out MachineBasicBlock because parent MachineFunction"

364 << " is null\n";

365 return;

366 }

367

370

372 OS << ":\n";

373

377 bool HasLineAttributes = false;

378

379

381 if (Indexes) OS << '\t';

382

383 OS << "; predecessors: ";

387 OS << '\n';

388 HasLineAttributes = true;

389 }

390

392 if (Indexes) OS << '\t';

393

394 OS.indent(2) << "successors: ";

398 if (!Probs.empty())

399 OS << '('

401 << ')';

402 }

403 if (!Probs.empty() && IsStandalone) {

404

405 OS << "; ";

412 100.0 * 100.0) /

413 100.0)

414 << ')';

415 }

416 }

417

418 OS << '\n';

419 HasLineAttributes = true;

420 }

421

423 if (Indexes) OS << '\t';

424 OS.indent(2) << "liveins: ";

425

427 for (const auto &LI : liveins()) {

429 if (!LI.LaneMask.all())

431 }

432 HasLineAttributes = true;

433 }

434

435 if (HasLineAttributes)

436 OS << '\n';

437

438 bool IsInBundle = false;

443 OS << '\t';

444 }

445

446 if (IsInBundle && MI.isInsideBundle()) {

447 OS.indent(2) << "}\n";

448 IsInBundle = false;

449 }

450

451 OS.indent(IsInBundle ? 4 : 2);

452 MI.print(OS, MST, IsStandalone, false, false,

453 false, &TII);

454

456 OS << " {";

457 IsInBundle = true;

458 }

459 OS << '\n';

460 }

461

462 if (IsInBundle)

463 OS.indent(2) << "}\n";

464

465 if (IrrLoopHeaderWeight && IsStandalone) {

466 if (Indexes) OS << '\t';

467 OS.indent(2) << "; Irreducible loop header weight: " << *IrrLoopHeaderWeight

468 << '\n';

469 }

470}

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

491 bool hasAttributes = false;

492

493 auto PrintBBRef = [&](const BasicBlock *bb) {

494 os << "%ir-block.";

495 if (bb->hasName()) {

496 os << bb->getName();

497 } else {

498 int slot = -1;

499

500 if (moduleSlotTracker) {

502 } else if (bb->getParent()) {

506 }

507

508 if (slot == -1)

509 os << "";

510 else

511 os << slot;

512 }

513 };

514

517 if (bb->hasName()) {

518 os << '.' << bb->getName();

519 } else {

520 hasAttributes = true;

521 os << " (";

522 PrintBBRef(bb);

523 }

524 }

525 }

526

529 os << (hasAttributes ? ", " : " (");

530 os << "machine-block-address-taken";

531 hasAttributes = true;

532 }

534 os << (hasAttributes ? ", " : " (");

535 os << "ir-block-address-taken ";

537 hasAttributes = true;

538 }

540 os << (hasAttributes ? ", " : " (");

541 os << "landing-pad";

542 hasAttributes = true;

543 }

545 os << (hasAttributes ? ", " : " (");

546 os << "inlineasm-br-indirect-target";

547 hasAttributes = true;

548 }

550 os << (hasAttributes ? ", " : " (");

551 os << "ehfunclet-entry";

552 hasAttributes = true;

553 }

555 os << (hasAttributes ? ", " : " (");

557 hasAttributes = true;

558 }

560 os << (hasAttributes ? ", " : " (");

561 os << "bbsections ";

564 os << "Exception";

565 break;

567 os << "Cold";

568 break;

569 default:

571 }

572 hasAttributes = true;

573 }

574 if (getBBID().has_value()) {

575 os << (hasAttributes ? ", " : " (");

576 os << "bb_id " << getBBID()->BaseID;

577 if (getBBID()->CloneID != 0)

578 os << " " << getBBID()->CloneID;

579 hasAttributes = true;

580 }

581 if (CallFrameSize != 0) {

582 os << (hasAttributes ? ", " : " (");

583 os << "call-frame-size " << CallFrameSize;

584 hasAttributes = true;

585 }

586 }

587

588 if (hasAttributes)

589 os << ')';

590}

591

593 bool ) const {

594 OS << '%';

596}

597

599 LiveInVector::iterator I = find_if(

601 if (I == LiveIns.end())

602 return;

603

604 I->LaneMask &= ~LaneMask;

605 if (I->LaneMask.none())

606 LiveIns.erase(I);

607}

608

612

613 for (MCPhysReg S : TRI->subregs_inclusive(Reg))

615

616

617 for (MCPhysReg Super : TRI->superregs(Reg)) {

619 if (Reg == SRI.getSubReg()) {

620 unsigned SubRegIndex = SRI.getSubRegIndex();

621 LaneBitmask SubRegLaneMask = TRI->getSubRegIndexLaneMask(SubRegIndex);

623 break;

624 }

625 }

626 }

627}

628

631

632 LiveInVector::iterator LI = LiveIns.begin() + (I - LiveIns.begin());

633 return LiveIns.erase(LI);

634}

635

639 return I != livein_end() && (I->LaneMask & LaneMask).any();

640}

641

646 });

647

648 LiveInVector::const_iterator I = LiveIns.begin();

649 LiveInVector::const_iterator J;

650 LiveInVector::iterator Out = LiveIns.begin();

651 for (; I != LiveIns.end(); ++Out, I = J) {

654 for (J = std::next(I); J != LiveIns.end() && J->PhysReg == PhysReg; ++J)

655 LaneMask |= J->LaneMask;

656 Out->PhysReg = PhysReg;

657 Out->LaneMask = LaneMask;

658 }

659 LiveIns.erase(Out, LiveIns.end());

660}

661

664 assert(getParent() && "MBB must be inserted in function");

666 assert(RC && "Register class is required");

668 "Only the entry block and landing pads can have physreg live ins");

669

670 bool LiveIn = isLiveIn(PhysReg);

674

675

676 if (LiveIn)

677 for (;I != E && I->isCopy(); ++I)

678 if (I->getOperand(1).getReg() == PhysReg) {

679 Register VirtReg = I->getOperand(0).getReg();

680 if (MRI.constrainRegClass(VirtReg, RC))

682 return VirtReg;

683 }

684

685

686 Register VirtReg = MRI.createVirtualRegister(RC);

689 if (!LiveIn)

691 return VirtReg;

692}

693

697

701

704 if (TerminatorI == MBB.end())

705 return -1;

706 const MachineInstr &Terminator = *TerminatorI;

708 return TII->getJumpTableIndex(Terminator);

709}

710

712 MachineBasicBlock *PreviousLayoutSuccessor) {

714 << "\n");

715

717

719 return;

720

721 MachineBasicBlock *TBB = nullptr, *FBB = nullptr;

724 bool B = TII->analyzeBranch(*this, TBB, FBB, Cond);

725 (void) B;

726 assert(B && "UpdateTerminators requires analyzable predecessors!");

727 if (Cond.empty()) {

728 if (TBB) {

729

730

732 TII->removeBranch(*this);

733 } else {

734

735

736

737

738

739

740

741 if (!PreviousLayoutSuccessor || isSuccessor(PreviousLayoutSuccessor) ||

742 PreviousLayoutSuccessor->isEHPad())

743 return;

744

745

746

748 TII->insertBranch(*this, PreviousLayoutSuccessor, nullptr, Cond, DL);

749 }

750 return;

751 }

752

753 if (FBB) {

754

755

756

758 if (TII->reverseBranchCondition(Cond))

759 return;

760 TII->removeBranch(*this);

761 TII->insertBranch(*this, FBB, nullptr, Cond, DL);

763 TII->removeBranch(*this);

764 TII->insertBranch(*this, TBB, nullptr, Cond, DL);

765 }

766 return;

767 }

768

769

770 assert(PreviousLayoutSuccessor);

773

774 if (PreviousLayoutSuccessor == TBB) {

775

776

777

778 TII->removeBranch(*this);

780 Cond.clear();

781 TII->insertBranch(*this, TBB, nullptr, Cond, DL);

782 }

783 return;

784 }

785

786

788 if (TII->reverseBranchCondition(Cond)) {

789

790 Cond.clear();

791 TII->insertBranch(*this, PreviousLayoutSuccessor, nullptr, Cond, DL);

792 return;

793 }

794 TII->removeBranch(*this);

795 TII->insertBranch(*this, PreviousLayoutSuccessor, nullptr, Cond, DL);

797 TII->removeBranch(*this);

798 TII->insertBranch(*this, TBB, PreviousLayoutSuccessor, Cond, DL);

799 }

800}

801

803#ifndef NDEBUG

804 int64_t Sum = 0;

805 for (auto Prob : Probs)

806 Sum += Prob.getNumerator();

807

808

809

811 Probs.size() &&

812 "The sum of successors's probabilities exceeds one.");

813#endif

814}

815

818

819

820 if (!(Probs.empty() && !Successors.empty()))

821 Probs.push_back(Prob);

822 Successors.push_back(Succ);

823 Succ->addPredecessor(this);

824}

825

827

828

829

830 Probs.clear();

831 Successors.push_back(Succ);

832 Succ->addPredecessor(this);

833}

834

836 MachineBasicBlock *New,

837 bool NormalizeSuccProbs) {

839 assert(OldI != succ_end() && "Old is not a successor of this block!");

841 "New is already a successor of this block!");

842

843

844

845

846

847

849 : *getProbabilityIterator(OldI));

850 if (NormalizeSuccProbs)

852}

853

855 bool NormalizeSuccProbs) {

858}

859

862 assert(I != Successors.end() && "Not a current successor!");

863

864

865

866 if (!Probs.empty()) {

867 probability_iterator WI = getProbabilityIterator(I);

868 Probs.erase(WI);

869 if (NormalizeSuccProbs)

871 }

872

873 (*I)->removePredecessor(this);

874 return Successors.erase(I);

875}

876

878 MachineBasicBlock *New) {

879 if (Old == New)

880 return;

881

886 if (*I == Old) {

887 OldI = I;

888 if (NewI != E)

889 break;

890 }

891 if (*I == New) {

892 NewI = I;

893 if (OldI != E)

894 break;

895 }

896 }

897 assert(OldI != E && "Old is not a successor of this block");

898

899

900 if (NewI == E) {

901 Old->removePredecessor(this);

902 New->addPredecessor(this);

903 *OldI = New;

904 return;

905 }

906

907

908

909 if (!Probs.empty()) {

910 auto ProbIter = getProbabilityIterator(NewI);

911 if (!ProbIter->isUnknown())

912 *ProbIter += *getProbabilityIterator(OldI);

913 }

915}

916

919 if (!Orig->Probs.empty())

921 else

923}

924

927}

928

929void MachineBasicBlock::removePredecessor(MachineBasicBlock *Pred) {

931 assert(I != Predecessors.end() && "Pred is not a predecessor of this block!");

932 Predecessors.erase(I);

933}

934

936 if (this == FromMBB)

937 return;

938

940 MachineBasicBlock *Succ = *FromMBB->succ_begin();

941

942

943

944 if (!FromMBB->Probs.empty()) {

945 auto Prob = *FromMBB->Probs.begin();

947 } else

949

951 }

952}

953

954void

956 if (this == FromMBB)

957 return;

958

960 MachineBasicBlock *Succ = *FromMBB->succ_begin();

961 if (!FromMBB->Probs.empty()) {

962 auto Prob = *FromMBB->Probs.begin();

964 } else

967

968

970 }

972}

973

977

981

986

988 return Successors.size() == 1 ? Successors[0] : nullptr;

989}

990

992 return Predecessors.size() == 1 ? Predecessors[0] : nullptr;

993}

994

997 ++Fallthrough;

998

1000 return nullptr;

1001

1002

1004 return nullptr;

1005

1006

1007 MachineBasicBlock *TBB = nullptr, *FBB = nullptr;

1010 if (TII->analyzeBranch(*this, TBB, FBB, Cond)) {

1011

1012

1013

1014

1015

1016 return (empty() || back().isBarrier() || TII->isPredicated(back()))

1017 ? &*Fallthrough

1018 : nullptr;

1019 }

1020

1021

1022 if (TBB) return &*Fallthrough;

1023

1024

1025

1028 return &*Fallthrough;

1029

1030

1031

1032 if (Cond.empty()) return nullptr;

1033

1034

1035

1036 return (FBB == nullptr) ? &*Fallthrough : nullptr;

1037}

1038

1042

1044 bool UpdateLiveIns,

1047 ++SplitPoint;

1048

1049 if (SplitPoint == end()) {

1050

1051 return this;

1052 }

1053

1055

1057 if (UpdateLiveIns) {

1058

1059

1062 LiveRegs.addLiveOuts(*this);

1065 }

1066

1068

1070 SplitBB->splice(SplitBB->begin(), this, SplitPoint, end());

1071

1074

1075 if (UpdateLiveIns)

1077

1078 if (LIS)

1080

1081 return SplitBB;

1082}

1083

1084

1085

1088 int JumpTableIndex) {

1089 assert(JumpTableIndex >= 0 && "need valid index");

1092

1093

1096 if (B != nullptr) {

1098 break;

1099 }

1100 }

1101 if (MBB == nullptr)

1102 return true;

1106 if (Pred == &IgnoreMBB)

1107 continue;

1110 Cond.clear();

1111 if (TII.analyzeBranch(*Pred, DummyT, DummyF, Cond,

1112 false)) {

1113

1114 continue;

1115 }

1117 if (PredJTI >= 0) {

1118 if (PredJTI == JumpTableIndex)

1119 return true;

1120 continue;

1121 }

1122

1123 return true;

1124 }

1125 return false;

1126}

1127

1129private:

1133

1134public:

1136 : MF(MF), Indexes(Indexes) {

1137 MF.setDelegate(this);

1138 }

1139

1141 MF.resetDelegate(this);

1142 for (auto MI : Insertions)

1143 Indexes->insertMachineInstrInMaps(*MI);

1144 }

1145

1147

1148 if (Indexes)

1149 Insertions.insert(&MI);

1150 }

1151

1153 if (Indexes && !Insertions.remove(&MI))

1154 Indexes->removeMachineInstrFromMaps(MI);

1155 }

1156};

1157

1161#define GET_RESULT(RESULT, GETTER, INFIX) \

1162 [MF, P, MFAM]() { \

1163 if (P) { \

1164 auto *Wrapper = P->getAnalysisIfAvailable<RESULT##INFIX##WrapperPass>(); \

1165 return Wrapper ? &Wrapper->GETTER() : nullptr; \

1166 } \

1167 return MFAM->getCachedResult<RESULT##Analysis>(*MF); \

1168 }()

1169

1170 assert((P || MFAM) && "Need a way to get analysis results!");

1176 return SplitCriticalEdge(Succ, {LIS, Indexes, LV, MLI}, LiveInSets, MDTU);

1177#undef GET_RESULT

1178}

1179

1184 return nullptr;

1185

1187 MachineBasicBlock *PrevFallthrough = getNextNode();

1188

1191

1192

1193 bool ChangedIndirectJump = false;

1195 if (JTI >= 0) {

1198 ChangedIndirectJump = true;

1199 }

1200

1205 auto *LIS = Analyses.LIS;

1206 if (LIS)

1208 else if (Analyses.SI)

1210

1211

1212

1213

1214 auto *LV = Analyses.LV;

1215

1217 if (LV)

1221 if (MO.getReg() == 0 || !MO.isKill() || MO.isUndef())

1222 continue;

1224 if (Reg.isPhysical() || LV->getVarInfo(Reg).removeKill(MI)) {

1227 MO.setIsKill(false);

1228 }

1229 }

1230 }

1231

1233 if (LIS) {

1237 if (!MO.isReg() || MO.getReg() == 0)

1238 continue;

1239

1243 }

1244 }

1245 }

1246

1248

1249

1250

1251 if (Succ == PrevFallthrough)

1252 PrevFallthrough = NMBB;

1253 auto *Indexes = Analyses.SI;

1254 if (!ChangedIndirectJump) {

1257 }

1258

1259

1265

1266

1267

1268

1269

1270

1272 if (MergedDL && (MergedDL.getLine() || MergedDL.getCol()))

1273 DL = MergedDL;

1274 TII->insertBranch(*NMBB, Succ, nullptr, Cond, DL);

1275 }

1276

1277

1279

1280

1281 for (const auto &LI : Succ->liveins())

1283

1284

1286 if (LV) {

1287

1288 while (!KilledRegs.empty()) {

1291 if (!(--I)->addRegisterKilled(Reg, TRI, false))

1292 continue;

1293 if (Reg.isVirtual())

1294 LV->getVarInfo(Reg).Kills.push_back(&*I);

1295 LLVM_DEBUG(dbgs() << "Restored terminator kill: " << *I);

1296 break;

1297 }

1298 }

1299

1300 if (LiveInSets != nullptr)

1301 LV->addNewBlock(NMBB, this, Succ, *LiveInSets);

1302 else

1303 LV->addNewBlock(NMBB, this, Succ);

1304 }

1305

1306 if (LIS) {

1307

1308

1309

1310

1311

1312

1313

1314 bool isLastMBB =

1316

1317 SlotIndex StartIndex = Indexes->getMBBEndIdx(this);

1319 SlotIndex EndIndex = Indexes->getMBBEndIdx(NMBB);

1320

1321

1325 I != E && I->isPHI(); ++I) {

1326 for (unsigned ni = 1, ne = I->getNumOperands(); ni != ne; ni += 2) {

1327 if (I->getOperand(ni+1).getMBB() == NMBB) {

1330 PHISrcRegs.insert(Reg);

1332 continue;

1333

1337 "PHI sources should be live out of their predecessors.");

1341 }

1342 }

1343 }

1344

1346 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {

1348 if (PHISrcRegs.count(Reg) || !LIS->hasInterval(Reg))

1349 continue;

1350

1352 if (!LI.liveAt(PrevIndex))

1353 continue;

1354

1358 assert(VNI && "LiveInterval should have VNInfo where it is live.");

1360

1361 for (auto &SR : LI.subranges()) {

1362 VNInfo *VNI = SR.getVNInfoAt(PrevIndex);

1363 if (VNI)

1365 }

1366 } else if (isLiveOut && !isLastMBB) {

1369 SR.removeSegment(StartIndex, EndIndex);

1370 }

1371 }

1372

1373

1374

1376 }

1377

1378 if (MDTU)

1380

1382 if (MachineLoop *TIL = MLI->getLoopFor(this)) {

1383

1384

1385 if (MachineLoop *DestLoop = MLI->getLoopFor(Succ)) {

1386 if (TIL == DestLoop) {

1387

1388 DestLoop->addBasicBlockToLoop(NMBB, *MLI);

1389 } else if (TIL->contains(DestLoop)) {

1390

1391 TIL->addBasicBlockToLoop(NMBB, *MLI);

1392 } else if (DestLoop->contains(TIL)) {

1393

1394 DestLoop->addBasicBlockToLoop(NMBB, *MLI);

1395 } else {

1396

1397

1398

1399

1400 assert(DestLoop->getHeader() == Succ &&

1401 "Should not create irreducible loops!");

1402 if (MachineLoop *P = DestLoop->getParentLoop())

1403 P->addBasicBlockToLoop(NMBB, *MLI);

1404 }

1405 }

1406 }

1407

1408 return NMBB;

1409}

1410

1413

1414

1416 return false;

1417

1418

1419

1421 return false;

1422

1424

1425

1426

1428 if (!MLI)

1429 return false;

1431

1432

1433

1434 if (!L || L->getHeader() != Succ)

1435 return false;

1436 }

1437

1438

1441 return true;

1442

1443

1444

1446 MachineBasicBlock *TBB = nullptr, *FBB = nullptr;

1448

1449 if (TII->analyzeBranch(*const_cast<MachineBasicBlock *>(this), TBB, FBB, Cond,

1450 false))

1451 return false;

1452

1453

1454

1455

1456

1457 if (TBB && TBB == FBB) {

1458 LLVM_DEBUG(dbgs() << "Won't split critical edge after degenerate "

1460 return false;

1461 }

1462 return true;

1463}

1464

1465

1466

1468

1469 if (MI->isBundledWithSucc() && MI->isBundledWithPred())

1470 MI->unbundleFromSucc();

1471

1472 if (MI->isBundledWithPred() && MI->isBundledWithSucc())

1473 MI->unbundleFromPred();

1474

1475

1476}

1477

1481 return Insts.erase(I);

1482}

1483

1488 return Insts.remove(MI);

1489}

1490

1493 assert(MI->isBundledWithPred() && MI->isBundledWithSucc() &&

1494 "Cannot insert instruction with bundle flags");

1495

1496 if (I != instr_end() && I->isBundledWithPred()) {

1499 }

1500 return Insts.insert(I, MI);

1501}

1502

1503

1504

1510

1511

1516

1517

1518

1520 MachineBasicBlock *New) {

1521 assert(Old != New && "Cannot replace self with self!");

1522

1525 --I;

1526 if (I->isTerminator()) break;

1527

1528

1529

1531 if (MO.isMBB() && MO.getMBB() == Old)

1532 MO.setMBB(New);

1533 }

1534

1535

1537}

1538

1540 MachineBasicBlock *New) {

1542 for (unsigned i = 2, e = MI.getNumOperands() + 1; i != e; i += 2) {

1544 if (MO.getMBB() == Old)

1546 }

1547}

1548

1549

1550

1553

1556 return MBBI->getDebugLoc();

1557 return {};

1558}

1559

1563

1565 if (MBBI->isDebugInstr())

1566 return MBBI->getDebugLoc();

1567 return {};

1568}

1569

1570

1571

1574 return {};

1575

1577 if (MBBI->isDebugInstr())

1578 return MBBI->getDebugLoc();

1579 return {};

1580}

1581

1584 return {};

1585

1588 return MBBI->getDebugLoc();

1589 return {};

1590}

1591

1592

1593

1598 while (TI != end() && !TI->isBranch())

1599 ++TI;

1600

1601 if (TI != end()) {

1602 DL = TI->getDebugLoc();

1603 for (++TI ; TI != end() ; ++TI)

1604 if (TI->isBranch())

1606 }

1607 return DL;

1608}

1609

1610

1613 if (Probs.empty())

1615

1616 const auto &Prob = *getProbabilityIterator(Succ);

1617 if (!Prob.isUnknown())

1618 return Prob;

1619

1620

1621 unsigned KnownProbNum = 0;

1623 for (const auto &P : Probs) {

1624 if (P.isUnknown()) {

1625 Sum += P;

1626 KnownProbNum++;

1627 }

1628 }

1629 return Sum.getCompl() / (Probs.size() - KnownProbNum);

1630}

1631

1634 return true;

1636 return true;

1637

1640

1641

1642

1645

1647}

1648

1649

1653 if (Probs.empty())

1654 return;

1655 *getProbabilityIterator(I) = Prob;

1656}

1657

1658

1659MachineBasicBlock::const_probability_iterator

1660MachineBasicBlock::getProbabilityIterator(

1662 assert(Probs.size() == Successors.size() && "Async probability list!");

1663 const size_t index = std::distance(Successors.begin(), I);

1664 assert(index < Probs.size() && "Not a current successor!");

1665 return Probs.begin() + index;

1666}

1667

1668

1669MachineBasicBlock::probability_iterator

1671 assert(Probs.size() == Successors.size() && "Async probability list!");

1672 const size_t index = std::distance(Successors.begin(), I);

1673 assert(index < Probs.size() && "Not a current successor!");

1674 return Probs.begin() + index;

1675}

1676

1677

1678

1679

1680

1681

1682

1686 unsigned Neighborhood) const {

1687 unsigned N = Neighborhood;

1688

1689

1691 for (; I != end() && N > 0; ++I) {

1692 if (I->isDebugOrPseudoInstr())

1693 continue;

1694

1695 --N;

1696

1698

1699

1700 if (Info.Read)

1702

1703 if (Info.FullyDefined || Info.Clobbered)

1705 }

1706

1707

1708

1709 if (I == end()) {

1710 for (MachineBasicBlock *S : successors()) {

1712 if (TRI->regsOverlap(LI.PhysReg, Reg))

1714 }

1715 }

1716

1718 }

1719

1720

1721 N = Neighborhood;

1722

1723

1725

1727 do {

1728 --I;

1729

1730 if (I->isDebugOrPseudoInstr())

1731 continue;

1732

1733 --N;

1734

1736

1737

1738

1739

1740 if (Info.DeadDef)

1742

1743 if (Info.Defined) {

1744 if (!Info.PartialDeadDef)

1746

1747

1748

1749

1750 break;

1751 }

1752

1753 if (Info.Killed || Info.Clobbered)

1755

1756 if (Info.Read)

1758

1759 } while (I != begin() && N > 0);

1760 }

1761

1762

1763

1764 while (I != begin() && std::prev(I)->isDebugOrPseudoInstr())

1765 --I;

1766

1767

1769

1771 if (TRI->regsOverlap(LI.PhysReg, Reg))

1773

1775 }

1776

1777

1779}

1780

1786

1794

1796 LiveIns.clear();

1797}

1798

1800 std::vector &OldLiveIns) {

1801 assert(OldLiveIns.empty() && "Vector must be empty");

1803}

1804

1806 assert(getParent()->getProperties().hasTracksLiveness() &&

1807 "Liveness information is accurate");

1808 return LiveIns.begin();

1809}

1810

1814 MCRegister ExceptionPointer, ExceptionSelector;

1819 }

1820

1821 return liveout_iterator(*this, ExceptionPointer, ExceptionSelector, false);

1822}

1823

1825 unsigned Cntr = 0;

1827 for (auto I = R.begin(), E = R.end(); I != E; ++I) {

1828 if (++Cntr > Limit)

1829 return true;

1830 }

1831 return false;

1832}

1833

1835 const MachineBasicBlock &PredMBB) {

1837 Phi.removePHIIncomingValueFor(PredMBB);

1838}

1839

unsigned const MachineRegisterInfo * MRI

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

const TargetInstrInfo & TII

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

MachineBasicBlock MachineBasicBlock::iterator MBBI

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

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)

Definition MachineBasicBlock.cpp:1086

static void unbundleSingleMI(MachineInstr *MI)

Prepare MI to be removed from its bundle.

Definition MachineBasicBlock.cpp:1467

static int findJumpTableIndex(const MachineBasicBlock &MBB)

Definition MachineBasicBlock.cpp:702

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)

Register const TargetRegisterInfo * TRI

uint64_t IntrinsicInst * II

const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB

const SmallVectorImpl< MachineOperand > & Cond

static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)

This file describes how to lower LLVM code to machine code.

SlotIndexUpdateDelegate(MachineFunction &MF, SlotIndexes *Indexes)

Definition MachineBasicBlock.cpp:1135

void MF_HandleRemoval(MachineInstr &MI) override

Callback before a removal. This should not modify the MI directly.

Definition MachineBasicBlock.cpp:1152

void MF_HandleInsertion(MachineInstr &MI) override

Callback after an insertion. This should not modify the MI directly.

Definition MachineBasicBlock.cpp:1146

~SlotIndexUpdateDelegate() override

Definition MachineBasicBlock.cpp:1140

LLVM Basic Block Representation.

static uint32_t getDenominator()

static BranchProbability getUnknown()

uint32_t getNumerator() const

static BranchProbability getZero()

static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)

LLVM_ABI unsigned getLine() const

static LLVM_ABI DebugLoc getMergedLocation(DebugLoc LocA, DebugLoc LocB)

When two instructions are combined into a single instruction we also need to combine the original loc...

LLVM_ABI unsigned getCol() const

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.

A helper class to return the specified delimiter string after the first invocation of operator String...

LiveInterval - This class represents the liveness of a register, or stack slot.

iterator_range< subrange_iterator > subranges()

void insertMBBInMaps(MachineBasicBlock *MBB)

A set of physical registers with utility functions to track liveness when walking backward/forward th...

LLVM_ABI iterator addSegment(Segment S)

Add the specified Segment to this range, merging segments as appropriate.

bool liveAt(SlotIndex index) const

LLVM_ABI 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.

LoopT * getLoopFor(const BlockT *BB) const

Return the inner most loop that BB lives in.

Context object for machine code objects.

LLVM_ABI MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)

Get or create a symbol for a basic block.

LLVM_ABI 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.

Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices.

bool isValid() const

Returns true if this iterator is not yet at the end.

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.

LLVM_ABI DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI)

Has exact same behavior as findPrevDebugLoc (it also searches towards the beginning of this MBB) exce...

Definition MachineBasicBlock.cpp:1582

LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)

Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...

Definition MachineBasicBlock.cpp:955

LLVM_ABI bool hasEHPadSuccessor() const

Definition MachineBasicBlock.cpp:287

void normalizeSuccProbs()

Normalize probabilities of all successors so that the sum of them becomes one.

livein_iterator livein_end() const

LLVM_ABI iterator getFirstTerminatorForward()

Finds the first terminator in a block by scanning forward.

Definition MachineBasicBlock.cpp:260

bool isEHPad() const

Returns true if the block is a landing pad.

LLVM_ABI 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.

Definition MachineBasicBlock.cpp:1539

LLVM_ABI MachineInstr * remove_instr(MachineInstr *I)

Remove the possibly bundled instruction from the instruction list without deleting it.

Definition MachineBasicBlock.cpp:1484

instr_iterator instr_begin()

MachineInstrBundleIterator< const MachineInstr > const_iterator

LLVM_ABI MCSymbol * getSymbol() const

Return the MCSymbol for this basic block.

Definition MachineBasicBlock.cpp:61

LLVM_ABI void moveBefore(MachineBasicBlock *NewAfter)

Move 'this' block before or after the specified block.

Definition MachineBasicBlock.cpp:694

LLVM_ABI void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)

Replace successor OLD with NEW and update probability info.

Definition MachineBasicBlock.cpp:877

LLVM_ABI MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)

Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...

Definition MachineBasicBlock.cpp:995

LLVM_ABI void transferSuccessors(MachineBasicBlock *FromMBB)

Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...

Definition MachineBasicBlock.cpp:935

MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)

bool hasLabelMustBeEmitted() const

Test whether this block must have its label emitted.

LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)

Insert MI into the instruction list before I, possibly inside a bundle.

Definition MachineBasicBlock.cpp:1492

LLVM_ABI BranchProbability getSuccProbability(const_succ_iterator Succ) const

Return probability of the edge from this block to MBB.

Definition MachineBasicBlock.cpp:1612

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...

LLVM_ABI iterator SkipPHIsAndLabels(iterator I)

Return the first instruction in MBB after I that is not a PHI or a label.

Definition MachineBasicBlock.cpp:210

LLVM_ABI void addSuccessorWithoutProb(MachineBasicBlock *Succ)

Add Succ as a successor of this MachineBasicBlock.

Definition MachineBasicBlock.cpp:826

SmallVectorImpl< MachineBasicBlock * >::const_iterator const_succ_iterator

LLVM_ABI bool hasName() const

Check if there is a name of corresponding LLVM basic block.

Definition MachineBasicBlock.cpp:318

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.

LLVM_ABI MCSymbol * getEHContSymbol() const

Return the Windows EH Continuation Symbol for this basic block.

Definition MachineBasicBlock.cpp:93

LLVM_ABI void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)

Split the old successor into old plus new and updates the probability info.

Definition MachineBasicBlock.cpp:835

@ PrintNameIr

Add IR name where available.

@ PrintNameAttributes

Print attributes.

LLVM_ABI void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)

Update the terminator instructions in block to account for changes to block layout which may have bee...

Definition MachineBasicBlock.cpp:711

LLVM_ABI const MachineBasicBlock * getSinglePredecessor() const

Return the predecessor of this block if it has a single predecessor.

Definition MachineBasicBlock.cpp:991

LLVM_ABI 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.

Definition MachineBasicBlock.cpp:225

LLVM_ABI bool canFallThrough()

Return true if the block can implicitly transfer control to the block after it by falling off the end...

Definition MachineBasicBlock.cpp:1039

LLVM_ABI void setSuccProbability(succ_iterator I, BranchProbability Prob)

Set successor probability of a given iterator.

Definition MachineBasicBlock.cpp:1650

LLVM_ABI iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)

Returns an iterator to the first non-debug instruction in the basic block, or end().

Definition MachineBasicBlock.cpp:265

succ_iterator succ_begin()

bool livein_empty() const

LLVM_ABI void removeLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll())

Remove the specified register from the live in set.

Definition MachineBasicBlock.cpp:598

LLVM_ABI void printAsOperand(raw_ostream &OS, bool PrintType=true) const

Definition MachineBasicBlock.cpp:592

LLVM_ABI void validateSuccProbs() const

Validate successors' probabilities and check if the sum of them is approximate one.

Definition MachineBasicBlock.cpp:802

bool isIRBlockAddressTaken() const

Test whether this block is the target of an IR BlockAddress.

LiveInVector::const_iterator livein_iterator

LLVM_ABI MCSymbol * getEndSymbol() const

Returns the MCSymbol marking the end of this basic block.

Definition MachineBasicBlock.cpp:104

LLVM_ABI void clearLiveIns()

Clear live in list.

Definition MachineBasicBlock.cpp:1795

bool isEHFuncletEntry() const

Returns true if this is the entry block of an EH funclet.

LLVM_ABI 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.

Definition MachineBasicBlock.cpp:1684

LLVM_ABI iterator getFirstTerminator()

Returns an iterator to the first terminator instruction of this basic block.

Definition MachineBasicBlock.cpp:242

LLVM_ABI livein_iterator livein_begin() const

Definition MachineBasicBlock.cpp:1805

unsigned succ_size() const

bool isReturnBlock() const

Convenience function that returns true if the block ends in a return instruction.

LLVM_ABI const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const

Get the clobber mask for the start of this basic block.

Definition MachineBasicBlock.cpp:1782

LLVM_ABI void removePHIsIncomingValuesForPredecessor(const MachineBasicBlock &PredMBB)

Iterate over block PHI instructions and remove all incoming values for PredMBB.

Definition MachineBasicBlock.cpp:1834

MBBSectionID getSectionID() const

Returns the section ID of this basic block.

LLVM_ABI void dump() const

Definition MachineBasicBlock.cpp:299

LLVM_ABI bool isEntryBlock() const

Returns true if this is the entry block of the function.

Definition MachineBasicBlock.cpp:294

LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())

Add Succ as a successor of this MachineBasicBlock.

Definition MachineBasicBlock.cpp:816

LLVM_ABI void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)

Copy a successor (and any probability info) from original block to this block's.

Definition MachineBasicBlock.cpp:917

SmallVectorImpl< MachineBasicBlock * >::iterator succ_iterator

BasicBlock * getAddressTakenIRBlock() const

Retrieves the BasicBlock which corresponds to this MachineBasicBlock.

LLVM_ABI void sortUniqueLiveIns()

Sorts and uniques the LiveIns vector.

Definition MachineBasicBlock.cpp:642

LLVM_ABI const MachineBasicBlock * getSingleSuccessor() const

Return the successor of this block if it has a single successor.

Definition MachineBasicBlock.cpp:987

LLVM_ABI liveout_iterator liveout_begin() const

Iterator scanning successor basic blocks' liveins to determine the registers potentially live at the ...

Definition MachineBasicBlock.cpp:1811

LLVM_ABI void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)

Remove successor from the successors list of this MachineBasicBlock.

Definition MachineBasicBlock.cpp:854

LLVM_ABI iterator getFirstNonPHI()

Returns a pointer to the first instruction in this block that is not a PHINode instruction.

Definition MachineBasicBlock.cpp:200

LLVM_ABI bool isPredecessor(const MachineBasicBlock *MBB) const

Return true if the specified MBB is a predecessor of this block.

Definition MachineBasicBlock.cpp:974

bool hasSuccessorProbabilities() const

Return true if any of the successors have probabilities attached to them.

LLVM_ABI DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI)

Has exact same behavior as findDebugLoc (it also searches towards the end of this MBB) except that th...

Definition MachineBasicBlock.cpp:1560

LLVM_ABI void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const

Definition MachineBasicBlock.cpp:343

reverse_instr_iterator instr_rend()

LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)

Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.

Definition MachineBasicBlock.cpp:1552

Instructions::iterator instr_iterator

LLVM_ABI iterator getLastNonDebugInstr(bool SkipPseudoOp=true)

Returns an iterator to the last non-debug instruction in the basic block, or end().

Definition MachineBasicBlock.cpp:271

LLVM_ABI 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...

Definition MachineBasicBlock.cpp:1519

LLVM_ABI bool isLayoutSuccessor(const MachineBasicBlock *MBB) const

Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...

Definition MachineBasicBlock.cpp:982

LLVM_ABI DebugLoc findPrevDebugLoc(instr_iterator MBBI)

Find the previous valid DebugLoc preceding MBBI, skipping any debug instructions.

Definition MachineBasicBlock.cpp:1572

LLVM_ABI MachineBasicBlock * splitAt(MachineInstr &SplitInst, bool UpdateLiveIns=true, LiveIntervals *LIS=nullptr)

Split a basic block into 2 pieces at SplitPoint.

Definition MachineBasicBlock.cpp:1043

LLVM_ABI bool canSplitCriticalEdge(const MachineBasicBlock *Succ, const MachineLoopInfo *MLI=nullptr) const

Check if the edge between this block and the given successor Succ, can be split.

Definition MachineBasicBlock.cpp:1411

LLVM_ABI void eraseFromParent()

This method unlinks 'this' from the containing function and deletes it.

Definition MachineBasicBlock.cpp:1512

friend class MachineFunction

LLVM_ABI void removeLiveInOverlappedWith(MCRegister Reg)

Remove the specified register from any overlapped live in.

Definition MachineBasicBlock.cpp:609

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.

LLVM_ABI instr_iterator erase(instr_iterator I)

Remove an instruction from the instruction list and delete it.

Definition MachineBasicBlock.cpp:1479

LLVM_ABI std::string getFullName() const

Return a formatted string to identify this block and its parent function.

Definition MachineBasicBlock.cpp:332

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.

LLVM_ABI DebugLoc findBranchDebugLoc()

Find and return the merged DebugLoc of the branch instructions of the block.

Definition MachineBasicBlock.cpp:1595

iterator_range< succ_iterator > successors()

LLVM_ABI instr_iterator getFirstInstrTerminator()

Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.

Definition MachineBasicBlock.cpp:251

reverse_iterator rbegin()

bool isMachineBlockAddressTaken() const

Test whether this block is used as something other than the target of a terminator,...

LLVM_ABI void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const

Print the basic block's name as:

Definition MachineBasicBlock.cpp:488

LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const

Return true if the specified MBB is a successor of this block.

Definition MachineBasicBlock.cpp:978

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.

MachineInstrBundleIterator< MachineInstr > iterator

LLVM_ABI bool isLegalToHoistInto() const

Returns true if it is legal to hoist instructions into this block.

Definition MachineBasicBlock.cpp:312

LLVM_ABI bool canPredictBranchProbabilities() const

Definition MachineBasicBlock.cpp:1632

LLVM_ABI StringRef getName() const

Return the name of the corresponding LLVM basic block, or an empty string.

Definition MachineBasicBlock.cpp:324

LLVM_ABI bool mayHaveInlineAsmBr() const

Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...

Definition MachineBasicBlock.cpp:304

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.

LLVM_ABI void moveAfter(MachineBasicBlock *NewBefore)

Definition MachineBasicBlock.cpp:698

LLVM_ABI const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const

Get the clobber mask for the end of the basic block.

Definition MachineBasicBlock.cpp:1788

LLVM_ABI bool sizeWithoutDebugLargerThan(unsigned Limit) const

Definition MachineBasicBlock.cpp:1824

LLVM_ABI bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const

Return true if the specified register is in the live in set.

Definition MachineBasicBlock.cpp:636

LLVM_ABI MachineBasicBlock * removeFromParent()

This method unlinks 'this' from the containing function, and returns it, but does not delete it.

Definition MachineBasicBlock.cpp:1505

Instructions::reverse_iterator reverse_instr_iterator

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.

Function & getFunction()

Return the LLVM function that this machine code represents.

BasicBlockListType::iterator iterator

void remove(iterator MBBI)

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)

CreateMachineInstr - Allocate a new MachineInstr.

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.

LLVM_ABI 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'.

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.

SlotIndex - An opaque wrapper around machine indexes.

SlotIndex getPrevSlot() const

Returns the previous slot in the index list.

void insertMBBInMaps(MachineBasicBlock *mbb)

Add the given MachineBasicBlock into the maps.

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...

iterator erase(const_iterator CI)

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 TargetInstrInfo * getInstrInfo() const

virtual const TargetRegisterInfo * getRegisterInfo() const =0

Return the target's register information.

virtual const TargetLowering * getTargetLowering() const

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

The instances of the Type class are immutable: once they are created, they are never changed.

VNInfo - Value Number Information.

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

self_iterator getIterator()

MachineBasicBlock * getNextNode()

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.

LLVM_ABI 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.

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

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)

LLVM_ABI 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.

uint16_t MCPhysReg

An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...

PredIterator< BasicBlock, Value::user_iterator > pred_iterator

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.

bool equal(L &&LRange, R &&RRange)

Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.

IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)

Decrement It, then continue decrementing it while it points to a debug instruction.

LLVM_ABI 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.

LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)

Prints a machine basic block reference.

Definition MachineBasicBlock.cpp:120

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.

constexpr 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.

LLVM_ABI static const MBBSectionID ExceptionSectionID

LLVM_ABI static const MBBSectionID ColdSectionID

Pair of physical register and lane mask.

Split the critical edge from this block to the given successor block, and return the newly created bl...

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 *)

When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering,...

void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)

Callback before transferring nodes to this list.

Template traits for intrusive list.