LLVM: include/llvm/Analysis/CGSCCPassManager.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88#ifndef LLVM_ANALYSIS_CGSCCPASSMANAGER_H

89#define LLVM_ANALYSIS_CGSCCPASSMANAGER_H

90

97#include

98#include

99

100namespace llvm {

101

105

107

108

109#define DEBUG_TYPE "cgscc"

110

111

113

116

117

118

119

120

121

122

125

126

127

128

129template <>

137

138

139

140

141

142

146

147

148template

151 : PassInfoMixin<RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC,

152 CGSCCAnalysisManager, LazyCallGraph &,

153 CGSCCUpdateResult &>> {

156 (void)AM.template getResult(C, CG);

158 }

161 auto ClassName = AnalysisT::name();

162 auto PassName = MapClassName2PassName(ClassName);

163 OS << "require<" << PassName << '>';

164 }

165};

166

167

168using CGSCCAnalysisManagerModuleProxy =

170

171

172

173

174template <> class CGSCCAnalysisManagerModuleProxy::Result {

175public:

177 : InnerAM(&InnerAM), G(&G) {}

178

179

181

182

183

184

185

186

187

188

189

190

191

193 ModuleAnalysisManager::Invalidator &Inv);

194

195private:

198};

199

200

201

202template <>

203LLVM_ABI CGSCCAnalysisManagerModuleProxy::Result

205

206

207

209

212

213

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

234

235

236

237

238

239

240

241

242

243

244

245

246

248

249

250

251

252

253

254

256

257

258

259

260

261

262

263

264

266

267

268

269

270

271

272

273

274

275

276

277

278

279

281

282

283

284

285

286

287

290

291

292

294

295

296

297

298

299

300

301

302

304};

305

306

307

308

309

310

311

312

313

314

316 : public PassInfoMixin {

317public:

321

324

327

332

338

339

341

344 OS << "cgscc(";

345 Pass->printPipeline(OS, MapClassName2PassName);

346 OS << ')';

347 }

348

350

351private:

352 std::unique_ptr Pass;

353};

354

355

356

357template

358ModuleToPostOrderCGSCCPassAdaptor

360 using PassModelT =

363

364

366 std::unique_ptr<ModuleToPostOrderCGSCCPassAdaptor::PassConceptT>(

367 new PassModelT(std::forward(Pass))));

368}

369

370

371

372

373

374

375

376

377

380public:

382 public:

383 explicit Result() : FAM(nullptr) {}

385

387

392

394 CGSCCAnalysisManager::Invalidator &Inv);

395

396 private:

398 };

399

400

403

404private:

406

408};

409

412

413

416

417

418

419

420

421

422

427

428

429

430

431

432

433

438

439

440

441

442

443

444

445

446

449public:

451

453 bool EagerlyInvalidate, bool NoRerun)

454 : Pass(std::move(Pass)), EagerlyInvalidate(EagerlyInvalidate),

455 NoRerun(NoRerun) {}

456

458 : Pass(std::move(Arg.Pass)), EagerlyInvalidate(Arg.EagerlyInvalidate),

459 NoRerun(Arg.NoRerun) {}

460

465

470

471

475

478 OS << "function";

479 if (EagerlyInvalidate || NoRerun) {

480 OS << "<";

481 if (EagerlyInvalidate)

482 OS << "eager-inv";

483 if (EagerlyInvalidate && NoRerun)

484 OS << ";";

485 if (NoRerun)

486 OS << "no-rerun";

487 OS << ">";

488 }

489 OS << '(';

490 Pass->printPipeline(OS, MapClassName2PassName);

491 OS << ')';

492 }

493

495

496private:

497 std::unique_ptr Pass;

498 bool EagerlyInvalidate;

499 bool NoRerun;

500};

501

502

503

504template

505CGSCCToFunctionPassAdaptor

507 bool EagerlyInvalidate = false,

508 bool NoRerun = false) {

509 using PassModelT =

511

512

514 std::unique_ptrCGSCCToFunctionPassAdaptor::PassConceptT(

515 new PassModelT(std::forward(Pass))),

516 EagerlyInvalidate, NoRerun);

517}

518

519

520

521

522

523

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

548public:

552

554 int MaxIterations)

555 : Pass(std::move(Pass)), MaxIterations(MaxIterations) {}

556

557

558

562

565 OS << "devirt<" << MaxIterations << ">(";

566 Pass->printPipeline(OS, MapClassName2PassName);

567 OS << ')';

568 }

569

570private:

571 std::unique_ptr Pass;

572 int MaxIterations;

573};

574

575

576

577template

579 int MaxIterations) {

580 using PassModelT =

583

584

586 std::unique_ptrDevirtSCCRepeatedPass::PassConceptT(

587 new PassModelT(std::forward(Pass))),

588 MaxIterations);

589}

590

591

592#undef DEBUG_TYPE

593

594}

595

596#endif

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

#define LLVM_TEMPLATE_ABI

This header defines various interfaces for pass management in LLVM.

Implements a lazy call graph analysis and related passes for the new pass manager.

This file implements a map that provides insertion order iteration.

FunctionAnalysisManager FAM

static const char PassName[]

A container for analyses that lazily runs them and caches their results.

CGSCCAnalysisManager & getManager()

Accessor for the analysis manager.

Definition CGSCCPassManager.h:180

Result(CGSCCAnalysisManager &InnerAM, LazyCallGraph &G)

Definition CGSCCPassManager.h:176

Adaptor that maps from a SCC to its functions.

Definition CGSCCPassManager.h:448

CGSCCToFunctionPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool EagerlyInvalidate, bool NoRerun)

Definition CGSCCPassManager.h:452

void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)

Definition CGSCCPassManager.h:476

CGSCCToFunctionPassAdaptor & operator=(CGSCCToFunctionPassAdaptor RHS)

Definition CGSCCPassManager.h:466

static bool isRequired()

Definition CGSCCPassManager.h:494

CGSCCToFunctionPassAdaptor(CGSCCToFunctionPassAdaptor &&Arg)

Definition CGSCCPassManager.h:457

friend void swap(CGSCCToFunctionPassAdaptor &LHS, CGSCCToFunctionPassAdaptor &RHS)

Definition CGSCCPassManager.h:461

detail::PassConcept< Function, FunctionAnalysisManager > PassConceptT

Definition CGSCCPassManager.h:450

A helper that repeats an SCC pass each time an indirect call is refined to a direct call by that pass...

Definition CGSCCPassManager.h:547

void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)

Definition CGSCCPassManager.h:563

detail::PassConcept< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > PassConceptT

Definition CGSCCPassManager.h:549

DevirtSCCRepeatedPass(std::unique_ptr< PassConceptT > Pass, int MaxIterations)

Definition CGSCCPassManager.h:553

Result()

Definition CGSCCPassManager.h:383

LLVM_ABI bool invalidate(LazyCallGraph::SCC &C, const PreservedAnalyses &PA, CGSCCAnalysisManager::Invalidator &Inv)

void updateFAM(FunctionAnalysisManager &FAM)

Definition CGSCCPassManager.h:386

FunctionAnalysisManager & getManager()

Accessor for the analysis manager.

Definition CGSCCPassManager.h:388

Result(FunctionAnalysisManager &FAM)

Definition CGSCCPassManager.h:384

A proxy from a FunctionAnalysisManager to an SCC.

Definition CGSCCPassManager.h:379

LLVM_ABI Result run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &)

Computes the FunctionAnalysisManager and stores it in the result proxy.

An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...

Result run(Module &IR, AnalysisManager< Module, ExtraArgTs... > &AM, ExtraArgTs...)

A node in the call graph.

An SCC of the call graph.

A lazily constructed view of the call graph of a module.

The core module pass which does a post-order walk of the SCCs and runs a CGSCC pass over each one.

Definition CGSCCPassManager.h:316

LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)

Runs the CGSCC pass across every SCC in the module.

ModuleToPostOrderCGSCCPassAdaptor & operator=(ModuleToPostOrderCGSCCPassAdaptor RHS)

Definition CGSCCPassManager.h:334

detail::PassConcept< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > PassConceptT

Definition CGSCCPassManager.h:318

ModuleToPostOrderCGSCCPassAdaptor(std::unique_ptr< PassConceptT > Pass)

Definition CGSCCPassManager.h:322

static bool isRequired()

Definition CGSCCPassManager.h:349

friend void swap(ModuleToPostOrderCGSCCPassAdaptor &LHS, ModuleToPostOrderCGSCCPassAdaptor &RHS)

Definition CGSCCPassManager.h:328

ModuleToPostOrderCGSCCPassAdaptor(ModuleToPostOrderCGSCCPassAdaptor &&Arg)

Definition CGSCCPassManager.h:325

void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)

Definition CGSCCPassManager.h:342

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

An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...

Manages a sequence of passes over a particular unit of IR.

PreservedAnalyses run(LazyCallGraph::SCC &IR, CGSCCAnalysisManager &AM, ExtraArgTs... ExtraArgs)

Pass interface - Implemented by all 'passes'.

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

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

Definition CGSCCPassManager.h:525

Result run(Function &F, FunctionAnalysisManager &FAM)

Definition CGSCCPassManager.h:530

static LLVM_ABI AnalysisKey Key

Definition CGSCCPassManager.h:527

Implements a dense probed hash-table based set with some number of buckets stored inline.

A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...

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

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.

An efficient, type-erasing, non-owning reference to a callable.

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

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy

A proxy from a CGSCCAnalysisManager to a Function.

Definition CGSCCPassManager.h:414

template class LLVM_TEMPLATE_ABI AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & >

DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)

A function to deduce a function pass type and wrap it in the templated adaptor.

Definition CGSCCPassManager.h:578

LLVM_ABI LazyCallGraph::SCC & updateCGAndAnalysisManagerForFunctionPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)

Helper to update the call graph after running a function pass.

template class LLVM_TEMPLATE_ABI OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function >

LLVM_ABI LazyCallGraph::SCC & updateCGAndAnalysisManagerForCGSCCPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)

Helper to update the call graph after running a CGSCC pass.

PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > CGSCCPassManager

The CGSCC pass manager.

Definition CGSCCPassManager.h:143

AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager

The CGSCC analysis manager.

Definition CGSCCPassManager.h:123

ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)

A function to deduce a function pass type and wrap it in the templated adaptor.

Definition CGSCCPassManager.h:359

CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)

A function to deduce a function pass type and wrap it in the templated adaptor.

Definition CGSCCPassManager.h:506

template class LLVM_TEMPLATE_ABI AllAnalysesOn< LazyCallGraph::SCC >

Extern template declaration for the analysis set for this IR unit.

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy

A proxy from a ModuleAnalysisManager to an SCC.

Definition CGSCCPassManager.h:214

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

AnalysisManager< Module > ModuleAnalysisManager

Convenience typedef for the Module analysis manager.

Implement std::hash so that hash_code can be used in STL containers.

void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)

Implement std::swap in terms of BitVector swap.

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

Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...

Definition CGSCCPassManager.h:233

SmallMapVector< Value *, WeakTrackingVH, 16 > IndirectVHs

Weak VHs to keep track of indirect calls for the purposes of detecting devirtualization.

Definition CGSCCPassManager.h:303

SmallPriorityWorklist< LazyCallGraph::SCC *, 1 > & CWorklist

Worklist of the SCCs queued for processing.

Definition CGSCCPassManager.h:247

SmallDenseSet< std::pair< LazyCallGraph::Node *, LazyCallGraph::SCC * >, 4 > & InlinedInternalEdges

A hacky area where the inliner can retain history about inlining decisions that mutated the call grap...

Definition CGSCCPassManager.h:289

SmallVector< Function *, 4 > & DeadFunctions

Functions that a pass has considered to be dead to be removed at the end of the call graph walk in ba...

Definition CGSCCPassManager.h:293

SmallPtrSetImpl< LazyCallGraph::SCC * > & InvalidatedSCCs

The set of invalidated SCCs which should be skipped if they are found in CWorklist.

Definition CGSCCPassManager.h:255

LazyCallGraph::SCC * UpdatedC

If non-null, the updated current SCC being processed.

Definition CGSCCPassManager.h:265

PreservedAnalyses CrossSCCPA

Preserved analyses across SCCs.

Definition CGSCCPassManager.h:280

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

void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)

Definition CGSCCPassManager.h:159

PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &)

Definition CGSCCPassManager.h:154

A utility pass template to force an analysis result to be available.

Definition CGSCCPassManager.h:528

A MapVector that performs no allocations if smaller than a certain size.

Template for the abstract base class used to dispatch polymorphically over pass objects.

A template wrapper used to implement the polymorphic API.