LLVM: include/llvm/Transforms/Utils/BasicBlockUtils.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H

15#define LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H

16

17

18

26#include

27

28namespace llvm {

47

48

49

51

52

53

54

55

59 bool KeepOneInputPHIs = false);

60

61

63 bool KeepOneInputPHIs = false);

64

65

66

67

68

69

70

73 bool KeepOneInputPHIs = false);

74

75

76

77

80 bool KeepOneInputPHIs = false);

81

82

83

84

85

89

90

91

92

93

97

98

99

100

101

102

103

104

105

106

111 bool PredecessorWithTwoSuccessors = false, DominatorTree *DT = nullptr);

112

113

114

115

116

117

118

119

123

124

125

126

128

129

130

132

133

134

135

136

139

140

141

143

144

145

146

147

148

150

151

152

153

154

164

165

166

168

174

179

184

189

194

199};

200

201

202

203

204

206 BasicBlock *SplitBB,

207 BasicBlock *DestBB);

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

227 const CriticalEdgeSplittingOptions &Options =

228 CriticalEdgeSplittingOptions(),

229 const Twine &BBName = "");

230

231

232

235 const CriticalEdgeSplittingOptions &Options =

236 CriticalEdgeSplittingOptions(),

237 const Twine &BBName = "");

238

239

240

241

242inline BasicBlock *

247 unsigned i = 0;

248 while (true) {

252 ++i;

253 }

254}

255

256

257

260 CriticalEdgeSplittingOptions());

261

262

263

265 DominatorTree *DT = nullptr,

266 LoopInfo *LI = nullptr,

267 MemorySSAUpdater *MSSAU = nullptr,

268 const Twine &BBName = "");

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

294SplitCallBrEdge(BasicBlock *CallBrBlock, BasicBlock *Succ, unsigned SuccIdx,

295 DomTreeUpdater *DTU = nullptr, CycleInfo *CI = nullptr,

296 LoopInfo *LI = nullptr, bool *UpdatedLI = nullptr);

297

298

300

301

302

304 BasicBlock *NewPred, PHINode *Until = nullptr);

305

306

307

310 LandingPadInst *OriginalPad = nullptr,

311 PHINode *LandingPadReplacement = nullptr,

312 const CriticalEdgeSplittingOptions &Options =

313 CriticalEdgeSplittingOptions(),

314 const Twine &BBName = "");

315

316

317

318

319

320

321

322

323

324

325

327 DominatorTree *DT, LoopInfo *LI = nullptr,

328 MemorySSAUpdater *MSSAU = nullptr,

329 const Twine &BBName = "", bool Before = false);

333 const Twine &BBName = "", bool Before = false) {

335}

336

337

338

339

340

341

342

343

344

346 DomTreeUpdater *DTU = nullptr,

347 LoopInfo *LI = nullptr,

348 MemorySSAUpdater *MSSAU = nullptr,

349 const Twine &BBName = "", bool Before = false);

353 const Twine &BBName = "", bool Before = false) {

355}

356

357

358

359

360

361

364 DomTreeUpdater *DTU, LoopInfo *LI,

365 MemorySSAUpdater *MSSAU,

366 const Twine &BBName = "");

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

391 DominatorTree *DT, LoopInfo *LI = nullptr,

392 MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false);

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

410 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,

411 MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false);

412

413

414

415

416

417

418

419

420

421

422

423

426 const char *Suffix2, SmallVectorImpl<BasicBlock *> &NewBBs,

427 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,

428 MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false);

429

430

431

432

433

435 BasicBlock *Pred,

436 DomTreeUpdater *DTU = nullptr);

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

461 bool Unreachable, MDNode *BranchWeights = nullptr,

462 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,

463 BasicBlock *ThenBlock = nullptr);

464

466 bool Unreachable,

467 MDNode *BranchWeights = nullptr,

472 Unreachable, BranchWeights, DTU, LI,

473 ThenBlock);

474}

475

476

477

480 bool Unreachable, MDNode *BranchWeights = nullptr,

481 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,

482 BasicBlock *ElseBlock = nullptr);

483

485 bool Unreachable,

486 MDNode *BranchWeights = nullptr,

491 Unreachable, BranchWeights, DTU, LI,

492 ElseBlock);

493}

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

513 Instruction **ElseTerm, MDNode *BranchWeights = nullptr,

514 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr);

515

519 MDNode *BranchWeights = nullptr,

522{

524 ElseTerm, BranchWeights, DTU, LI);

525}

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

556 BasicBlock **ElseBlock, bool UnreachableThen = false,

557 bool UnreachableElse = false, MDNode *BranchWeights = nullptr,

558 DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr);

559

563 bool UnreachableThen = false,

564 bool UnreachableElse = false,

565 MDNode *BranchWeights = nullptr,

569 ElseBlock, UnreachableThen, UnreachableElse, BranchWeights, DTU, LI);

570}

571

572

573

574

575

576LLVM_ABI std::pair<Instruction *, Value *>

578

579

580

581

582

583

584

585

586

589 std::function<void(IRBuilderBase &, Value *)> Func);

590

591

592

593

594

595

596

597

598

601 std::function<void(IRBuilderBase &, Value *)> Func);

602

603

604

605

606

607

608

609

610

612 BasicBlock *&IfFalse);

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

636 bool IgnoreBlocksWithoutPHI,

637 BranchProbabilityInfo *BPI = nullptr,

638 BlockFrequencyInfo *BFI = nullptr);

639

640

641

643

644

645

647

648

649

651

652}

653

654#endif

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

This file declares the LLVM IR specialization of the GenericCycle templates.

static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))

const SmallVectorImpl< MachineOperand > & Cond

This file implements a set that has insertion order iteration characteristics.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

LLVM Basic Block Representation.

InstListType::iterator iterator

Instruction iterators...

BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...

Conditional or Unconditional Branch instruction.

Analysis providing branch probability information.

Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.

Common base class shared among various IRBuilders.

LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY

Return the number of successors that this instruction has.

LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY

Return the specified successor. This instruction must be a terminator.

The landingpad instruction holds all of the information necessary to generate correct exception handl...

Represents a single loop in the control flow graph.

Provides a lazy, caching interface for making common memory aliasing information queries,...

PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...

Return a value (possibly void), from a function.

A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

Provides information about what library functions are available for the current target.

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

LLVM Value Representation.

self_iterator getIterator()

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI void ReplaceInstWithInst(BasicBlock *BB, BasicBlock::iterator &BI, Instruction *I)

Replace the instruction specified by BI with the instruction specified by I.

LLVM_ABI bool RemoveRedundantDbgInstrs(BasicBlock *BB)

Try to remove redundant dbg.value instructions from given basic block.

LLVM_ABI bool IsBlockFollowedByDeoptOrUnreachable(const BasicBlock *BB)

Check if we can prove that all paths starting from this block converge to a block that either has a @...

LLVM_ABI BranchInst * GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue, BasicBlock *&IfFalse)

Check whether BB is the merge point of a if-region.

LLVM_ABI void detachDeadBlocks(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< DominatorTree::UpdateType > *Updates, bool KeepOneInputPHIs=false)

Replace contents of every block in BBs with single unreachable instruction.

LLVM_ABI bool hasOnlySimpleTerminator(const Function &F)

LLVM_ABI ReturnInst * FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred, DomTreeUpdater *DTU=nullptr)

This method duplicates the specified return instruction into a predecessor which ends in an unconditi...

LLVM_ABI std::pair< Instruction *, Value * > SplitBlockAndInsertSimpleForLoop(Value *End, BasicBlock::iterator SplitBefore)

Insert a for (int i = 0; i < End; i++) loop structure (with the exception that End is assumed > 0,...

LLVM_ABI BasicBlock * splitBlockBefore(BasicBlock *Old, BasicBlock::iterator SplitPt, DomTreeUpdater *DTU, LoopInfo *LI, MemorySSAUpdater *MSSAU, const Twine &BBName="")

Split the specified block at the specified instruction SplitPt.

LLVM_ABI Instruction * SplitBlockAndInsertIfElse(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ElseBlock=nullptr)

Similar to SplitBlockAndInsertIfThen, but the inserted block is on the false path of the branch.

LLVM_ABI BasicBlock * SplitCallBrEdge(BasicBlock *CallBrBlock, BasicBlock *Succ, unsigned SuccIdx, DomTreeUpdater *DTU=nullptr, CycleInfo *CI=nullptr, LoopInfo *LI=nullptr, bool *UpdatedLI=nullptr)

Create a new intermediate target block for a callbr edge.

LLVM_ABI void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)

Delete the specified block, which must have no predecessors.

LLVM_ABI void ReplaceInstWithValue(BasicBlock::iterator &BI, Value *V)

Replace all uses of an instruction (specified by BI) with a value, then remove and delete the origina...

LLVM_ABI BasicBlock * SplitKnownCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")

If it is known that an edge is critical, SplitKnownCriticalEdge can be called directly,...

LLVM_ABI bool SplitIndirectBrCriticalEdges(Function &F, bool IgnoreBlocksWithoutPHI, BranchProbabilityInfo *BPI=nullptr, BlockFrequencyInfo *BFI=nullptr)

LLVM_ABI bool DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr)

Examine each PHI in the given block and delete it if it is dead.

LLVM_ABI bool HasLoopOrEntryConvergenceToken(const BasicBlock *BB)

Check if the given basic block contains any loop or entry convergent intrinsic instructions.

LLVM_ABI void InvertBranch(BranchInst *PBI, IRBuilderBase &Builder)

LLVM_ABI bool EliminateUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)

Delete all basic blocks from F that are not reachable from its entry node.

LLVM_ABI bool MergeBlockSuccessorsIntoGivenBlocks(SmallPtrSetImpl< BasicBlock * > &MergeBlocks, Loop *L=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)

Merge block(s) sucessors, if possible.

LLVM_ABI void SplitBlockAndInsertIfThenElse(Value *Cond, BasicBlock::iterator SplitBefore, Instruction **ThenTerm, Instruction **ElseTerm, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)

SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen, but also creates the ElseBlock...

LLVM_ABI BasicBlock * ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ, LandingPadInst *OriginalPad=nullptr, PHINode *LandingPadReplacement=nullptr, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")

Split the edge connect the specficed blocks in the case that Succ is an Exception Handling Block.

LLVM_ABI void SplitLandingPadPredecessors(BasicBlock *OrigBB, ArrayRef< BasicBlock * > Preds, const char *Suffix, const char *Suffix2, SmallVectorImpl< BasicBlock * > &NewBBs, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)

This method transforms the landing pad, OrigBB, by introducing two new basic blocks into the function...

LLVM_ABI BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)

This method introduces at least one new basic block into the function and moves some of the predecess...

LLVM_ABI void createPHIsForSplitLoopExit(ArrayRef< BasicBlock * > Preds, BasicBlock *SplitBB, BasicBlock *DestBB)

When a loop exit edge is split, LCSSA form may require new PHIs in the new exit block.

LLVM_ABI bool MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, MemoryDependenceResults *MemDep=nullptr, bool PredecessorWithTwoSuccessors=false, DominatorTree *DT=nullptr)

Attempts to merge a block into its predecessor, if possible.

LLVM_ABI BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")

If this edge is a critical edge, insert a new node to split the critical edge.

LLVM_ABI bool FoldSingleEntryPHINodes(BasicBlock *BB, MemoryDependenceResults *MemDep=nullptr)

We know that BB has one predecessor.

ArrayRef(const T &OneElt) -> ArrayRef< T >

LLVM_ABI void updatePhiNodes(BasicBlock *DestBB, BasicBlock *OldPred, BasicBlock *NewPred, PHINode *Until=nullptr)

Replaces all uses of OldPred with the NewPred block in all PHINodes in a block.

LLVM_ABI Printable printBasicBlock(const BasicBlock *BB)

Print BasicBlock BB as an operand or print "" if BB is a nullptr.

LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)

Split the specified block at the specified instruction.

LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)

Split the containing block at the specified instruction - everything before SplitBefore stays in the ...

LLVM_ABI void DeleteDeadBlocks(ArrayRef< BasicBlock * > BBs, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)

Delete the specified blocks from BB.

LLVM_ABI BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")

Split the edge connecting the specified blocks, and return the newly created basic block between From...

LLVM_ABI void setUnwindEdgeTo(Instruction *TI, BasicBlock *Succ)

Sets the unwind edge of an instruction to a particular successor.

LLVM_ABI void SplitBlockAndInsertForEachLane(ElementCount EC, Type *IndexTy, BasicBlock::iterator InsertBefore, std::function< void(IRBuilderBase &, Value *)> Func)

Utility function for performing a given action on each lane of a vector with EC elements.

GenericCycleInfo< SSAContext > CycleInfo

Option class for critical edge splitting.

Definition BasicBlockUtils.h:155

bool PreserveLCSSA

Definition BasicBlockUtils.h:162

CriticalEdgeSplittingOptions(DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, PostDominatorTree *PDT=nullptr)

Definition BasicBlockUtils.h:169

CriticalEdgeSplittingOptions & setMergeIdenticalEdges()

Definition BasicBlockUtils.h:175

DominatorTree * DT

Definition BasicBlockUtils.h:156

bool IgnoreUnreachableDests

Definition BasicBlockUtils.h:163

bool KeepOneInputPHIs

Definition BasicBlockUtils.h:161

CriticalEdgeSplittingOptions & setKeepOneInputPHIs()

Definition BasicBlockUtils.h:180

bool MergeIdenticalEdges

Definition BasicBlockUtils.h:160

bool PreserveLoopSimplify

SplitCriticalEdge is guaranteed to preserve loop-simplify form if LI is provided.

Definition BasicBlockUtils.h:167

CriticalEdgeSplittingOptions & unsetPreserveLoopSimplify()

Definition BasicBlockUtils.h:195

LoopInfo * LI

Definition BasicBlockUtils.h:158

PostDominatorTree * PDT

Definition BasicBlockUtils.h:157

CriticalEdgeSplittingOptions & setPreserveLCSSA()

Definition BasicBlockUtils.h:185

CriticalEdgeSplittingOptions & setIgnoreUnreachableDests()

Definition BasicBlockUtils.h:190

MemorySSAUpdater * MSSAU

Definition BasicBlockUtils.h:159