1 //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines interfaces to access the target independent code generation 11 // passes provided by the LLVM backend. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CODEGEN_PASSES_H 16 #define LLVM_CODEGEN_PASSES_H 17 18 #include "llvm/Pass.h" 19 #include "llvm/Target/TargetMachine.h" 20 #include <functional> 21 #include <string> 22 23 namespace llvm { 24 25 class MachineFunctionPass; 26 class PassConfigImpl; 27 class PassInfo; 28 class ScheduleDAGInstrs; 29 class TargetLowering; 30 class TargetLoweringBase; 31 class TargetRegisterClass; 32 class raw_ostream; 33 struct MachineSchedContext; 34 35 // The old pass manager infrastructure is hidden in a legacy namespace now. 36 namespace legacy { 37 class PassManagerBase; 38 } 39 using legacy::PassManagerBase; 40 41 /// Discriminated union of Pass ID types. 42 /// 43 /// The PassConfig API prefers dealing with IDs because they are safer and more 44 /// efficient. IDs decouple configuration from instantiation. This way, when a 45 /// pass is overriden, it isn't unnecessarily instantiated. It is also unsafe to 46 /// refer to a Pass pointer after adding it to a pass manager, which deletes 47 /// redundant pass instances. 48 /// 49 /// However, it is convient to directly instantiate target passes with 50 /// non-default ctors. These often don't have a registered PassInfo. Rather than 51 /// force all target passes to implement the pass registry boilerplate, allow 52 /// the PassConfig API to handle either type. 53 /// 54 /// AnalysisID is sadly char*, so PointerIntPair won't work. 55 class IdentifyingPassPtr { 56 union { 57 AnalysisID ID; 58 Pass *P; 59 }; 60 bool IsInstance; 61 public: IdentifyingPassPtr()62 IdentifyingPassPtr() : P(nullptr), IsInstance(false) {} IdentifyingPassPtr(AnalysisID IDPtr)63 IdentifyingPassPtr(AnalysisID IDPtr) : ID(IDPtr), IsInstance(false) {} IdentifyingPassPtr(Pass * InstancePtr)64 IdentifyingPassPtr(Pass *InstancePtr) : P(InstancePtr), IsInstance(true) {} 65 isValid()66 bool isValid() const { return P; } isInstance()67 bool isInstance() const { return IsInstance; } 68 getID()69 AnalysisID getID() const { 70 assert(!IsInstance && "Not a Pass ID"); 71 return ID; 72 } getInstance()73 Pass *getInstance() const { 74 assert(IsInstance && "Not a Pass Instance"); 75 return P; 76 } 77 }; 78 79 template <> struct isPodLike<IdentifyingPassPtr> { 80 static const bool value = true; 81 }; 82 83 /// Target-Independent Code Generator Pass Configuration Options. 84 /// 85 /// This is an ImmutablePass solely for the purpose of exposing CodeGen options 86 /// to the internals of other CodeGen passes. 87 class TargetPassConfig : public ImmutablePass { 88 public: 89 /// Pseudo Pass IDs. These are defined within TargetPassConfig because they 90 /// are unregistered pass IDs. They are only useful for use with 91 /// TargetPassConfig APIs to identify multiple occurrences of the same pass. 92 /// 93 94 /// EarlyTailDuplicate - A clone of the TailDuplicate pass that runs early 95 /// during codegen, on SSA form. 96 static char EarlyTailDuplicateID; 97 98 /// PostRAMachineLICM - A clone of the LICM pass that runs during late machine 99 /// optimization after regalloc. 100 static char PostRAMachineLICMID; 101 102 private: 103 PassManagerBase *PM; 104 AnalysisID StartBefore, StartAfter; 105 AnalysisID StopAfter; 106 bool Started; 107 bool Stopped; 108 bool AddingMachinePasses; 109 110 protected: 111 TargetMachine *TM; 112 PassConfigImpl *Impl; // Internal data structures 113 bool Initialized; // Flagged after all passes are configured. 114 115 // Target Pass Options 116 // Targets provide a default setting, user flags override. 117 // 118 bool DisableVerify; 119 120 /// Default setting for -enable-tail-merge on this target. 121 bool EnableTailMerge; 122 123 public: 124 TargetPassConfig(TargetMachine *tm, PassManagerBase &pm); 125 // Dummy constructor. 126 TargetPassConfig(); 127 128 ~TargetPassConfig() override; 129 130 static char ID; 131 132 /// Get the right type of TargetMachine for this target. 133 template<typename TMC> TMC &getTM() const { 134 return *static_cast<TMC*>(TM); 135 } 136 137 // 138 void setInitialized() { Initialized = true; } 139 140 CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); } 141 142 /// Set the StartAfter, StartBefore and StopAfter passes to allow running only 143 /// a portion of the normal code-gen pass sequence. 144 /// 145 /// If the StartAfter and StartBefore pass ID is zero, then compilation will 146 /// begin at the normal point; otherwise, clear the Started flag to indicate 147 /// that passes should not be added until the starting pass is seen. If the 148 /// Stop pass ID is zero, then compilation will continue to the end. 149 /// 150 /// This function expects that at least one of the StartAfter or the 151 /// StartBefore pass IDs is null. 152 void setStartStopPasses(AnalysisID StartBefore, AnalysisID StartAfter, 153 AnalysisID StopAfter) { 154 if (StartAfter) 155 assert(!StartBefore && "Start after and start before passes are given"); 156 this->StartBefore = StartBefore; 157 this->StartAfter = StartAfter; 158 this->StopAfter = StopAfter; 159 Started = (StartAfter == nullptr) && (StartBefore == nullptr); 160 } 161 162 void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); } 163 164 bool getEnableTailMerge() const { return EnableTailMerge; } 165 void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); } 166 167 /// Allow the target to override a specific pass without overriding the pass 168 /// pipeline. When passes are added to the standard pipeline at the 169 /// point where StandardID is expected, add TargetID in its place. 170 void substitutePass(AnalysisID StandardID, IdentifyingPassPtr TargetID); 171 172 /// Insert InsertedPassID pass after TargetPassID pass. 173 void insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID, 174 bool VerifyAfter = true, bool PrintAfter = true); 175 176 /// Allow the target to enable a specific standard pass by default. 177 void enablePass(AnalysisID PassID) { substitutePass(PassID, PassID); } 178 179 /// Allow the target to disable a specific standard pass by default. 180 void disablePass(AnalysisID PassID) { 181 substitutePass(PassID, IdentifyingPassPtr()); 182 } 183 184 /// Return the pass substituted for StandardID by the target. 185 /// If no substitution exists, return StandardID. 186 IdentifyingPassPtr getPassSubstitution(AnalysisID StandardID) const; 187 188 /// Return true if the optimized regalloc pipeline is enabled. 189 bool getOptimizeRegAlloc() const; 190 191 /// Return true if shrink wrapping is enabled. 192 bool getEnableShrinkWrap() const; 193 194 /// Return true if the default global register allocator is in use and 195 /// has not be overriden on the command line with '-regalloc=...' 196 bool usingDefaultRegAlloc() const; 197 198 /// Add common target configurable passes that perform LLVM IR to IR 199 /// transforms following machine independent optimization. 200 virtual void addIRPasses(); 201 202 /// Add passes to lower exception handling for the code generator. 203 void addPassesToHandleExceptions(); 204 205 /// Add pass to prepare the LLVM IR for code generation. This should be done 206 /// before exception handling preparation passes. 207 virtual void addCodeGenPrepare(); 208 209 /// Add common passes that perform LLVM IR to IR transforms in preparation for 210 /// instruction selection. 211 virtual void addISelPrepare(); 212 213 /// addInstSelector - This method should install an instruction selector pass, 214 /// which converts from LLVM code to machine instructions. 215 virtual bool addInstSelector() { 216 return true; 217 } 218 219 /// Add the complete, standard set of LLVM CodeGen passes. 220 /// Fully developed targets will not generally override this. 221 virtual void addMachinePasses(); 222 223 /// Create an instance of ScheduleDAGInstrs to be run within the standard 224 /// MachineScheduler pass for this function and target at the current 225 /// optimization level. 226 /// 227 /// This can also be used to plug a new MachineSchedStrategy into an instance 228 /// of the standard ScheduleDAGMI: 229 /// return new ScheduleDAGMI(C, make_unique<MyStrategy>(C), /*RemoveKillFlags=*/false) 230 /// 231 /// Return NULL to select the default (generic) machine scheduler. 232 virtual ScheduleDAGInstrs * 233 createMachineScheduler(MachineSchedContext *C) const { 234 return nullptr; 235 } 236 237 /// Similar to createMachineScheduler but used when postRA machine scheduling 238 /// is enabled. 239 virtual ScheduleDAGInstrs * 240 createPostMachineScheduler(MachineSchedContext *C) const { 241 return nullptr; 242 } 243 244 protected: 245 // Helper to verify the analysis is really immutable. 246 void setOpt(bool &Opt, bool Val); 247 248 /// Methods with trivial inline returns are convenient points in the common 249 /// codegen pass pipeline where targets may insert passes. Methods with 250 /// out-of-line standard implementations are major CodeGen stages called by 251 /// addMachinePasses. Some targets may override major stages when inserting 252 /// passes is insufficient, but maintaining overriden stages is more work. 253 /// 254 255 /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM 256 /// passes (which are run just before instruction selector). 257 virtual bool addPreISel() { 258 return true; 259 } 260 261 /// addMachineSSAOptimization - Add standard passes that optimize machine 262 /// instructions in SSA form. 263 virtual void addMachineSSAOptimization(); 264 265 /// Add passes that optimize instruction level parallelism for out-of-order 266 /// targets. These passes are run while the machine code is still in SSA 267 /// form, so they can use MachineTraceMetrics to control their heuristics. 268 /// 269 /// All passes added here should preserve the MachineDominatorTree, 270 /// MachineLoopInfo, and MachineTraceMetrics analyses. 271 virtual bool addILPOpts() { 272 return false; 273 } 274 275 /// This method may be implemented by targets that want to run passes 276 /// immediately before register allocation. 277 virtual void addPreRegAlloc() { } 278 279 /// createTargetRegisterAllocator - Create the register allocator pass for 280 /// this target at the current optimization level. 281 virtual FunctionPass *createTargetRegisterAllocator(bool Optimized); 282 283 /// addFastRegAlloc - Add the minimum set of target-independent passes that 284 /// are required for fast register allocation. 285 virtual void addFastRegAlloc(FunctionPass *RegAllocPass); 286 287 /// addOptimizedRegAlloc - Add passes related to register allocation. 288 /// LLVMTargetMachine provides standard regalloc passes for most targets. 289 virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass); 290 291 /// addPreRewrite - Add passes to the optimized register allocation pipeline 292 /// after register allocation is complete, but before virtual registers are 293 /// rewritten to physical registers. 294 /// 295 /// These passes must preserve VirtRegMap and LiveIntervals, and when running 296 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix. 297 /// When these passes run, VirtRegMap contains legal physreg assignments for 298 /// all virtual registers. 299 virtual bool addPreRewrite() { 300 return false; 301 } 302 303 /// This method may be implemented by targets that want to run passes after 304 /// register allocation pass pipeline but before prolog-epilog insertion. 305 virtual void addPostRegAlloc() { } 306 307 /// Add passes that optimize machine instructions after register allocation. 308 virtual void addMachineLateOptimization(); 309 310 /// This method may be implemented by targets that want to run passes after 311 /// prolog-epilog insertion and before the second instruction scheduling pass. 312 virtual void addPreSched2() { } 313 314 /// addGCPasses - Add late codegen passes that analyze code for garbage 315 /// collection. This should return true if GC info should be printed after 316 /// these passes. 317 virtual bool addGCPasses(); 318 319 /// Add standard basic block placement passes. 320 virtual void addBlockPlacement(); 321 322 /// This pass may be implemented by targets that want to run passes 323 /// immediately before machine code is emitted. 324 virtual void addPreEmitPass() { } 325 326 /// Utilities for targets to add passes to the pass manager. 327 /// 328 329 /// Add a CodeGen pass at this point in the pipeline after checking overrides. 330 /// Return the pass that was added, or zero if no pass was added. 331 /// @p printAfter if true and adding a machine function pass add an extra 332 /// machine printer pass afterwards 333 /// @p verifyAfter if true and adding a machine function pass add an extra 334 /// machine verification pass afterwards. 335 AnalysisID addPass(AnalysisID PassID, bool verifyAfter = true, 336 bool printAfter = true); 337 338 /// Add a pass to the PassManager if that pass is supposed to be run, as 339 /// determined by the StartAfter and StopAfter options. Takes ownership of the 340 /// pass. 341 /// @p printAfter if true and adding a machine function pass add an extra 342 /// machine printer pass afterwards 343 /// @p verifyAfter if true and adding a machine function pass add an extra 344 /// machine verification pass afterwards. 345 void addPass(Pass *P, bool verifyAfter = true, bool printAfter = true); 346 347 /// addMachinePasses helper to create the target-selected or overriden 348 /// regalloc pass. 349 FunctionPass *createRegAllocPass(bool Optimized); 350 351 /// printAndVerify - Add a pass to dump then verify the machine function, if 352 /// those steps are enabled. 353 /// 354 void printAndVerify(const std::string &Banner); 355 356 /// Add a pass to print the machine function if printing is enabled. 357 void addPrintPass(const std::string &Banner); 358 359 /// Add a pass to perform basic verification of the machine function if 360 /// verification is enabled. 361 void addVerifyPass(const std::string &Banner); 362 }; 363 } // namespace llvm 364 365 /// List of target independent CodeGen pass IDs. 366 namespace llvm { 367 FunctionPass *createAtomicExpandPass(const TargetMachine *TM); 368 369 /// createUnreachableBlockEliminationPass - The LLVM code generator does not 370 /// work well with unreachable basic blocks (what live ranges make sense for a 371 /// block that cannot be reached?). As such, a code generator should either 372 /// not instruction select unreachable blocks, or run this pass as its 373 /// last LLVM modifying pass to clean up blocks that are not reachable from 374 /// the entry block. 375 FunctionPass *createUnreachableBlockEliminationPass(); 376 377 /// MachineFunctionPrinter pass - This pass prints out the machine function to 378 /// the given stream as a debugging tool. 379 MachineFunctionPass * 380 createMachineFunctionPrinterPass(raw_ostream &OS, 381 const std::string &Banner =""); 382 383 /// MIRPrinting pass - this pass prints out the LLVM IR into the given stream 384 /// using the MIR serialization format. 385 MachineFunctionPass *createPrintMIRPass(raw_ostream &OS); 386 387 /// createCodeGenPreparePass - Transform the code to expose more pattern 388 /// matching during instruction selection. 389 FunctionPass *createCodeGenPreparePass(const TargetMachine *TM = nullptr); 390 391 /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg 392 /// load-linked/store-conditional loops. 393 extern char &AtomicExpandID; 394 395 /// MachineLoopInfo - This pass is a loop analysis pass. 396 extern char &MachineLoopInfoID; 397 398 /// MachineDominators - This pass is a machine dominators analysis pass. 399 extern char &MachineDominatorsID; 400 401 /// MachineDominanaceFrontier - This pass is a machine dominators analysis pass. 402 extern char &MachineDominanceFrontierID; 403 404 /// EdgeBundles analysis - Bundle machine CFG edges. 405 extern char &EdgeBundlesID; 406 407 /// LiveVariables pass - This pass computes the set of blocks in which each 408 /// variable is life and sets machine operand kill flags. 409 extern char &LiveVariablesID; 410 411 /// PHIElimination - This pass eliminates machine instruction PHI nodes 412 /// by inserting copy instructions. This destroys SSA information, but is the 413 /// desired input for some register allocators. This pass is "required" by 414 /// these register allocator like this: AU.addRequiredID(PHIEliminationID); 415 extern char &PHIEliminationID; 416 417 /// LiveIntervals - This analysis keeps track of the live ranges of virtual 418 /// and physical registers. 419 extern char &LiveIntervalsID; 420 421 /// LiveStacks pass. An analysis keeping track of the liveness of stack slots. 422 extern char &LiveStacksID; 423 424 /// TwoAddressInstruction - This pass reduces two-address instructions to 425 /// use two operands. This destroys SSA information but it is desired by 426 /// register allocators. 427 extern char &TwoAddressInstructionPassID; 428 429 /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs. 430 extern char &ProcessImplicitDefsID; 431 432 /// RegisterCoalescer - This pass merges live ranges to eliminate copies. 433 extern char &RegisterCoalescerID; 434 435 /// MachineScheduler - This pass schedules machine instructions. 436 extern char &MachineSchedulerID; 437 438 /// PostMachineScheduler - This pass schedules machine instructions postRA. 439 extern char &PostMachineSchedulerID; 440 441 /// SpillPlacement analysis. Suggest optimal placement of spill code between 442 /// basic blocks. 443 extern char &SpillPlacementID; 444 445 /// ShrinkWrap pass. Look for the best place to insert save and restore 446 // instruction and update the MachineFunctionInfo with that information. 447 extern char &ShrinkWrapID; 448 449 /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as 450 /// assigned in VirtRegMap. 451 extern char &VirtRegRewriterID; 452 453 /// UnreachableMachineBlockElimination - This pass removes unreachable 454 /// machine basic blocks. 455 extern char &UnreachableMachineBlockElimID; 456 457 /// DeadMachineInstructionElim - This pass removes dead machine instructions. 458 extern char &DeadMachineInstructionElimID; 459 460 /// FastRegisterAllocation Pass - This pass register allocates as fast as 461 /// possible. It is best suited for debug code where live ranges are short. 462 /// 463 FunctionPass *createFastRegisterAllocator(); 464 465 /// BasicRegisterAllocation Pass - This pass implements a degenerate global 466 /// register allocator using the basic regalloc framework. 467 /// 468 FunctionPass *createBasicRegisterAllocator(); 469 470 /// Greedy register allocation pass - This pass implements a global register 471 /// allocator for optimized builds. 472 /// 473 FunctionPass *createGreedyRegisterAllocator(); 474 475 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean 476 /// Quadratic Prograaming (PBQP) based register allocator. 477 /// 478 FunctionPass *createDefaultPBQPRegisterAllocator(); 479 480 /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code, 481 /// and eliminates abstract frame references. 482 extern char &PrologEpilogCodeInserterID; 483 484 /// ExpandPostRAPseudos - This pass expands pseudo instructions after 485 /// register allocation. 486 extern char &ExpandPostRAPseudosID; 487 488 /// createPostRAScheduler - This pass performs post register allocation 489 /// scheduling. 490 extern char &PostRASchedulerID; 491 492 /// BranchFolding - This pass performs machine code CFG based 493 /// optimizations to delete branches to branches, eliminate branches to 494 /// successor blocks (creating fall throughs), and eliminating branches over 495 /// branches. 496 extern char &BranchFolderPassID; 497 498 /// MachineFunctionPrinterPass - This pass prints out MachineInstr's. 499 extern char &MachineFunctionPrinterPassID; 500 501 /// MIRPrintingPass - this pass prints out the LLVM IR using the MIR 502 /// serialization format. 503 extern char &MIRPrintingPassID; 504 505 /// TailDuplicate - Duplicate blocks with unconditional branches 506 /// into tails of their predecessors. 507 extern char &TailDuplicateID; 508 509 /// MachineTraceMetrics - This pass computes critical path and CPU resource 510 /// usage in an ensemble of traces. 511 extern char &MachineTraceMetricsID; 512 513 /// EarlyIfConverter - This pass performs if-conversion on SSA form by 514 /// inserting cmov instructions. 515 extern char &EarlyIfConverterID; 516 517 /// This pass performs instruction combining using trace metrics to estimate 518 /// critical-path and resource depth. 519 extern char &MachineCombinerID; 520 521 /// StackSlotColoring - This pass performs stack coloring and merging. 522 /// It merges disjoint allocas to reduce the stack size. 523 extern char &StackColoringID; 524 525 /// IfConverter - This pass performs machine code if conversion. 526 extern char &IfConverterID; 527 528 FunctionPass *createIfConverter(std::function<bool(const Function &)> Ftor); 529 530 /// MachineBlockPlacement - This pass places basic blocks based on branch 531 /// probabilities. 532 extern char &MachineBlockPlacementID; 533 534 /// MachineBlockPlacementStats - This pass collects statistics about the 535 /// basic block placement using branch probabilities and block frequency 536 /// information. 537 extern char &MachineBlockPlacementStatsID; 538 539 /// GCLowering Pass - Used by gc.root to perform its default lowering 540 /// operations. 541 FunctionPass *createGCLoweringPass(); 542 543 /// ShadowStackGCLowering - Implements the custom lowering mechanism 544 /// used by the shadow stack GC. Only runs on functions which opt in to 545 /// the shadow stack collector. 546 FunctionPass *createShadowStackGCLoweringPass(); 547 548 /// GCMachineCodeAnalysis - Target-independent pass to mark safe points 549 /// in machine code. Must be added very late during code generation, just 550 /// prior to output, and importantly after all CFG transformations (such as 551 /// branch folding). 552 extern char &GCMachineCodeAnalysisID; 553 554 /// Creates a pass to print GC metadata. 555 /// 556 FunctionPass *createGCInfoPrinter(raw_ostream &OS); 557 558 /// MachineCSE - This pass performs global CSE on machine instructions. 559 extern char &MachineCSEID; 560 561 /// ImplicitNullChecks - This pass folds null pointer checks into nearby 562 /// memory operations. 563 extern char &ImplicitNullChecksID; 564 565 /// MachineLICM - This pass performs LICM on machine instructions. 566 extern char &MachineLICMID; 567 568 /// MachineSinking - This pass performs sinking on machine instructions. 569 extern char &MachineSinkingID; 570 571 /// MachineCopyPropagation - This pass performs copy propagation on 572 /// machine instructions. 573 extern char &MachineCopyPropagationID; 574 575 /// PeepholeOptimizer - This pass performs peephole optimizations - 576 /// like extension and comparison eliminations. 577 extern char &PeepholeOptimizerID; 578 579 /// OptimizePHIs - This pass optimizes machine instruction PHIs 580 /// to take advantage of opportunities created during DAG legalization. 581 extern char &OptimizePHIsID; 582 583 /// StackSlotColoring - This pass performs stack slot coloring. 584 extern char &StackSlotColoringID; 585 586 /// \brief This pass lays out funclets contiguously. 587 extern char &FuncletLayoutID; 588 589 /// createStackProtectorPass - This pass adds stack protectors to functions. 590 /// 591 FunctionPass *createStackProtectorPass(const TargetMachine *TM); 592 593 /// createMachineVerifierPass - This pass verifies cenerated machine code 594 /// instructions for correctness. 595 /// 596 FunctionPass *createMachineVerifierPass(const std::string& Banner); 597 598 /// createDwarfEHPass - This pass mulches exception handling code into a form 599 /// adapted to code generation. Required if using dwarf exception handling. 600 FunctionPass *createDwarfEHPass(const TargetMachine *TM); 601 602 /// createWinEHPass - Prepares personality functions used by MSVC on Windows, 603 /// in addition to the Itanium LSDA based personalities. 604 FunctionPass *createWinEHPass(const TargetMachine *TM); 605 606 /// createSjLjEHPreparePass - This pass adapts exception handling code to use 607 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. 608 /// 609 FunctionPass *createSjLjEHPreparePass(); 610 611 /// LocalStackSlotAllocation - This pass assigns local frame indices to stack 612 /// slots relative to one another and allocates base registers to access them 613 /// when it is estimated by the target to be out of range of normal frame 614 /// pointer or stack pointer index addressing. 615 extern char &LocalStackSlotAllocationID; 616 617 /// ExpandISelPseudos - This pass expands pseudo-instructions. 618 extern char &ExpandISelPseudosID; 619 620 /// createExecutionDependencyFixPass - This pass fixes execution time 621 /// problems with dependent instructions, such as switching execution 622 /// domains to match. 623 /// 624 /// The pass will examine instructions using and defining registers in RC. 625 /// 626 FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC); 627 628 /// UnpackMachineBundles - This pass unpack machine instruction bundles. 629 extern char &UnpackMachineBundlesID; 630 631 FunctionPass * 632 createUnpackMachineBundles(std::function<bool(const Function &)> Ftor); 633 634 /// FinalizeMachineBundles - This pass finalize machine instruction 635 /// bundles (created earlier, e.g. during pre-RA scheduling). 636 extern char &FinalizeMachineBundlesID; 637 638 /// StackMapLiveness - This pass analyses the register live-out set of 639 /// stackmap/patchpoint intrinsics and attaches the calculated information to 640 /// the intrinsic for later emission to the StackMap. 641 extern char &StackMapLivenessID; 642 643 /// LiveDebugValues pass 644 extern char &LiveDebugValuesID; 645 646 /// createJumpInstrTables - This pass creates jump-instruction tables. 647 ModulePass *createJumpInstrTablesPass(); 648 649 /// createForwardControlFlowIntegrityPass - This pass adds control-flow 650 /// integrity. 651 ModulePass *createForwardControlFlowIntegrityPass(); 652 653 /// InterleavedAccess Pass - This pass identifies and matches interleaved 654 /// memory accesses to target specific intrinsics. 655 /// 656 FunctionPass *createInterleavedAccessPass(const TargetMachine *TM); 657 } // End llvm namespace 658 659 /// Target machine pass initializer for passes with dependencies. Use with 660 /// INITIALIZE_TM_PASS_END. 661 #define INITIALIZE_TM_PASS_BEGIN INITIALIZE_PASS_BEGIN 662 663 /// Target machine pass initializer for passes with dependencies. Use with 664 /// INITIALIZE_TM_PASS_BEGIN. 665 #define INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis) \ 666 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \ 667 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis, \ 668 PassInfo::TargetMachineCtor_t(callTargetMachineCtor< passName >)); \ 669 Registry.registerPass(*PI, true); \ 670 return PI; \ 671 } \ 672 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \ 673 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \ 674 } 675 676 /// This initializer registers TargetMachine constructor, so the pass being 677 /// initialized can use target dependent interfaces. Please do not move this 678 /// macro to be together with INITIALIZE_PASS, which is a complete target 679 /// independent initializer, and we don't want to make libScalarOpts depend 680 /// on libCodeGen. 681 #define INITIALIZE_TM_PASS(passName, arg, name, cfg, analysis) \ 682 INITIALIZE_TM_PASS_BEGIN(passName, arg, name, cfg, analysis) \ 683 INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis) 684 685 #endif 686