LLVM: include/llvm/CodeGen/LiveIntervals.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19#ifndef LLVM_CODEGEN_LIVEINTERVALS_H

20#define LLVM_CODEGEN_LIVEINTERVALS_H

21

36#include

37#include

38#include

39

40namespace llvm {

41

43

54

55class LiveIntervals {

58

65 std::unique_ptr LICalc;

66

67

69

70

72

73

74

76

77

78

79

80

81

82

83

84

85

86

87

89

90

91

92

93

94

96

97

98

100

101

102 LiveIntervals() = default;

104 : Indexes(&SI), DomTree(&DT) {

105 analyze(MF);

106 }

107

109

111

112public:

115

117 MachineFunctionAnalysisManager::Invalidator &Inv);

118

119

120

125

126

127

132

135 return *VirtRegIntervals[Reg.id()];

136

138 }

139

143

145 return VirtRegIntervals.inBounds(Reg.id()) && VirtRegIntervals[Reg.id()];

146 }

147

148

151 VirtRegIntervals.grow(Reg.id());

152 auto &Interval = VirtRegIntervals[Reg.id()];

155 }

156

159 computeVirtRegInterval(LI);

160 return LI;

161 }

162

163

164

165

169

170

176

177

178

181

182

183

184

185

186

187

190

191

192

193

194

195

196

198

199

200

201

202

203

204

205

206

207

208

209

210

213

217

218

219

220

221

222

223

224

227

228

229

230

231

235 "Use pruneValue on the main LiveRange and on each subrange");

236 }

237

239

240

241

243 return !Indexes->hasIndex(Instr);

244 }

245

246

248 return Indexes->getInstructionIndex(Instr);

249 }

250

251

253 return Indexes->getInstructionFromIndex(index);

254 }

255

256

258 return Indexes->getMBBStartIdx(mbb);

259 }

260

261

263 return Indexes->getMBBEndIdx(mbb);

264 }

265

269

273

275 return Indexes->getMBBFromIndex(index);

276 }

277

279 Indexes->insertMBBInMaps(MBB);

280 assert(unsigned(MBB->getNumber()) == RegMaskBlocks.size() &&

281 "Blocks must be added in order.");

282 RegMaskBlocks.push_back(std::make_pair(RegMaskSlots.size(), 0));

283 }

284

286 return Indexes->insertMachineInstrInMaps(MI);

287 }

288

292 Indexes->insertMachineInstrInMaps(*I);

293 }

294

296 Indexes->removeMachineInstrFromMaps(MI);

297 }

298

300 return Indexes->replaceMachineInstrInMaps(MI, NewMI);

301 }

302

304

305

308

309

311 clear();

312 analyze(MF);

313 }

314

316

317

318

320

321

322

324

325

327

328

329

330

331

332

334

335

336

337

338

339

340

341

342

344 bool UpdateFlags = false);

345

346

347

348

349

350

351

352

353

354

359

360

361

362

363

364

365

366

367

368

369

370

371

372

374

375

376

378 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];

380 }

381

382

383

385

386

387

389 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];

391 }

392

393

394

395

396

397

398

401

402

403

404

405

406

407

408

409

410

411

412

413

414

416 LiveRange *LR = RegUnitRanges[static_cast<unsigned>(Unit)];

417 if (!LR) {

418

419

420 RegUnitRanges[static_cast<unsigned>(Unit)] = LR =

422 computeRegUnitRange(*LR, Unit);

423 }

424 return *LR;

425 }

426

427

428

430 return RegUnitRanges[static_cast<unsigned>(Unit)];

431 }

432

434 return RegUnitRanges[static_cast<unsigned>(Unit)];

435 }

436

437

438

440 delete RegUnitRanges[static_cast<unsigned>(Unit)];

441 RegUnitRanges[static_cast<unsigned>(Unit)] = nullptr;

442 }

443

444

445

446

447

449 for (MCRegUnit Unit : TRI->regunits(Reg))

451 }

452

453

454

455

457

458

459

461

462

466

467

468

469

471

472private:

473

474 void computeVirtRegs();

475

476

477 void computeRegMasks();

478

479

480

481

482

483

484

485

488

490

492 void dumpInstrs() const;

493

494 void computeLiveInRegUnits();

497

499 void extendSegmentsToUses(LiveRange &Segments, ShrinkToUsesWorkList &WorkList,

501

502

503

504

505

510

511 class HMEditor;

512};

513

523

525 : public PassInfoMixin {

527

528public:

533};

534

537

538public:

540

542

545

546

548

549

553

555};

556

557}

558

559#endif

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

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

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

This file implements an indexed map.

A common definition of LaneBitmask for use in TableGen and CodeGen.

std::pair< uint64_t, uint64_t > Interval

SI Optimize VGPR LiveRange

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

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

A live range for subregisters.

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

Definition LiveIntervals.h:514

LiveIntervals Result

Definition LiveIntervals.h:519

LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

static bool isRequired()

Definition LiveIntervals.h:532

LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

LiveIntervalsPrinterPass(raw_ostream &OS)

Definition LiveIntervals.h:529

LiveIntervals & getLIS()

Definition LiveIntervals.h:554

void print(raw_ostream &O, const Module *=nullptr) const override

Implement the dump method.

Definition LiveIntervals.h:550

void releaseMemory() override

releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...

Definition LiveIntervals.h:544

LiveIntervalsWrapperPass()

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...

static char ID

Definition LiveIntervals.h:539

Definition LiveIntervals.h:55

LLVM_ABI ~LiveIntervals()

LLVM_ABI void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< Register > OrigRegs)

Update live intervals for instructions in a range of iterators.

void removeAllRegUnitsForPhysReg(MCRegister Reg)

Remove associated live ranges for the register units associated with Reg.

Definition LiveIntervals.h:448

bool hasInterval(Register Reg) const

Definition LiveIntervals.h:144

SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const

Return the first index in the given basic block.

Definition LiveIntervals.h:257

MachineInstr * getInstructionFromIndex(SlotIndex index) const

Returns the instruction associated with the given index.

Definition LiveIntervals.h:252

LLVM_ABI bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const

Returns true if VNI is killed by any PHI-def values in LI.

SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)

Definition LiveIntervals.h:285

LLVM_ABI bool checkRegMaskInterference(const LiveInterval &LI, BitVector &UsableRegs)

Test if LI is live across any register mask instructions, and compute a bit mask of physical register...

LiveIntervals(LiveIntervals &&)=default

LLVM_ABI void handleMove(MachineInstr &MI, bool UpdateFlags=false)

Call this method to notify LiveIntervals that instruction MI has been moved within a basic block.

void insertMBBInMaps(MachineBasicBlock *MBB)

Definition LiveIntervals.h:278

SlotIndexes * getSlotIndexes() const

Definition LiveIntervals.h:238

const LiveInterval & getInterval(Register Reg) const

Definition LiveIntervals.h:140

ArrayRef< const uint32_t * > getRegMaskBits() const

Returns an array of register mask pointers corresponding to getRegMaskSlots().

Definition LiveIntervals.h:384

LiveInterval & getOrCreateEmptyInterval(Register Reg)

Return an existing interval for Reg.

Definition LiveIntervals.h:166

void reanalyze(MachineFunction &MF)

Definition LiveIntervals.h:310

MachineDominatorTree & getDomTree()

Definition LiveIntervals.h:315

LLVM_ABI void addKillFlags(const VirtRegMap *)

Add kill flags to any instruction that kills a virtual register.

SlotIndex getInstructionIndex(const MachineInstr &Instr) const

Returns the base index of the given instruction.

Definition LiveIntervals.h:247

void removeRegUnit(MCRegUnit Unit)

Remove computed live range for register unit Unit.

Definition LiveIntervals.h:439

LLVM_ABI bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)

void RemoveMachineInstrFromMaps(MachineInstr &MI)

Definition LiveIntervals.h:295

VNInfo::Allocator & getVNInfoAllocator()

Definition LiveIntervals.h:303

ArrayRef< const uint32_t * > getRegMaskBitsInBlock(unsigned MBBNum) const

Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum).

Definition LiveIntervals.h:388

SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const

Return the last index in the given basic block.

Definition LiveIntervals.h:262

static LLVM_ABI float getSpillWeight(bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr &MI, ProfileSummaryInfo *PSI=nullptr)

Calculate the spill weight to assign to a single instruction.

ArrayRef< SlotIndex > getRegMaskSlots() const

Returns a sorted array of slot indices of all instructions with register mask operands.

Definition LiveIntervals.h:373

friend class LiveIntervalsWrapperPass

Definition LiveIntervals.h:57

ArrayRef< SlotIndex > getRegMaskSlotsInBlock(unsigned MBBNum) const

Returns a sorted array of slot indices of all instructions with register mask operands in the basic b...

Definition LiveIntervals.h:377

LiveInterval & getInterval(Register Reg)

Definition LiveIntervals.h:133

void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)

Definition LiveIntervals.h:289

friend class LiveIntervalsAnalysis

Definition LiveIntervals.h:56

LLVM_ABI void pruneValue(LiveRange &LR, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints)

If LR has a live value at Kill, prune its live range by removing any liveness reachable from Kill.

void removeInterval(Register Reg)

Interval removal.

Definition LiveIntervals.h:171

bool isNotInMIMap(const MachineInstr &Instr) const

Returns true if the specified machine instr has been removed or was never entered in the map.

Definition LiveIntervals.h:242

LLVM_ABI void handleMoveIntoNewBundle(MachineInstr &BundleStart, bool UpdateFlags=false)

Update intervals of operands of all instructions in the newly created bundle specified by BundleStart...

void pruneValue(LiveInterval &, SlotIndex, SmallVectorImpl< SlotIndex > *)

This function should not be used.

Definition LiveIntervals.h:232

LiveRange & getRegUnit(MCRegUnit Unit)

Return the live range for register unit Unit.

Definition LiveIntervals.h:415

LLVM_ABI MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const

If LI is confined to a single basic block, return a pointer to that block.

const LiveRange * getCachedRegUnit(MCRegUnit Unit) const

Definition LiveIntervals.h:433

LiveRange * getCachedRegUnit(MCRegUnit Unit)

Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...

Definition LiveIntervals.h:429

LLVM_ABI void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)

Remove value number and related live segments of LI and its subranges that start at position Pos.

LLVM_ABI LiveInterval::Segment addSegmentToEndOfBlock(Register Reg, MachineInstr &startInst)

Given a register and an instruction, adds a live segment from that instruction to the end of its MBB.

LLVM_ABI bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)

After removing some uses of a register, shrink its live range to just the remaining uses.

LLVM_ABI void constructMainRangeFromSubranges(LiveInterval &LI)

For live interval LI with correct SubRanges construct matching information for the main live range.

LiveInterval & createEmptyInterval(Register Reg)

Interval creation.

Definition LiveIntervals.h:149

LLVM_ABI void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)

Extend the live range LR to reach all points in Indices.

LLVM_ABI void dump() const

void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices)

Definition LiveIntervals.h:214

bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const

Definition LiveIntervals.h:270

LLVM_ABI void print(raw_ostream &O) const

Implement the dump method.

LLVM_ABI void removePhysRegDefAt(MCRegister Reg, SlotIndex Pos)

Remove value numbers and related live segments starting at position Pos that are part of any liverang...

LLVM_ABI void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval * > &SplitLIs)

Split separate components in LiveInterval LI into separate intervals.

MachineBasicBlock * getMBBFromIndex(SlotIndex index) const

Definition LiveIntervals.h:274

bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const

Definition LiveIntervals.h:266

LiveInterval & createAndComputeVirtRegInterval(Register Reg)

Definition LiveIntervals.h:157

SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)

Definition LiveIntervals.h:299

This class represents the liveness of a register, stack slot, etc.

bool liveAt(SlotIndex index) const

Wrapper class representing physical registers. Should be passed by value.

MachineInstrBundleIterator< MachineInstr > iterator

MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...

DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...

MachineFunctionPass(char &ID)

Representation of each machine instruction.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

A Module instance is used to store all the information related to an LLVM module.

A set of analyses that are preserved following a run of a transformation pass.

Analysis providing profile information.

Wrapper class representing virtual and physical registers.

SlotIndex - An opaque wrapper around machine indexes.

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

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

TargetInstrInfo - Interface to description of machine instruction set.

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

VNInfo - Value Number Information.

BumpPtrAllocator Allocator

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI cl::opt< bool > UseSegmentSetForPhysRegs

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

A CRTP mix-in that provides informational APIs needed for analysis passes.

A special type used by analysis passes to provide an address that identifies that particular analysis...

static constexpr LaneBitmask getAll()

This represents a simple continuous liveness interval for a value.

A CRTP mix-in to automatically provide informational APIs needed for passes.