Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- llvm/Transforms/Utils.h - Utility Transformations --------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This header file defines prototypes for accessor functions that expose passes |
| 10 | // in the Utils transformations library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TRANSFORMS_UTILS_H |
| 15 | #define LLVM_TRANSFORMS_UTILS_H |
| 16 | |
| 17 | namespace llvm { |
| 18 | |
| 19 | class ModulePass; |
| 20 | class FunctionPass; |
| 21 | class Pass; |
| 22 | |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | // createMetaRenamerPass - Rename everything with metasyntatic names. |
| 25 | // |
| 26 | ModulePass *createMetaRenamerPass(); |
| 27 | |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | // |
| 30 | // LowerInvoke - This pass removes invoke instructions, converting them to call |
| 31 | // instructions. |
| 32 | // |
| 33 | FunctionPass *createLowerInvokePass(); |
| 34 | extern char &LowerInvokePassID; |
| 35 | |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | // |
| 38 | // InstructionNamer - Give any unnamed non-void instructions "tmp" names. |
| 39 | // |
| 40 | FunctionPass *createInstructionNamerPass(); |
| 41 | extern char &InstructionNamerID; |
| 42 | |
| 43 | //===----------------------------------------------------------------------===// |
| 44 | // |
| 45 | // LowerSwitch - This pass converts SwitchInst instructions into a sequence of |
| 46 | // chained binary branch instructions. |
| 47 | // |
| 48 | FunctionPass *createLowerSwitchPass(); |
| 49 | extern char &LowerSwitchID; |
| 50 | |
| 51 | //===----------------------------------------------------------------------===// |
| 52 | // |
| 53 | // EntryExitInstrumenter pass - Instrument function entry/exit with calls to |
| 54 | // mcount(), @__cyg_profile_func_{enter,exit} and the like. There are two |
| 55 | // variants, intended to run pre- and post-inlining, respectively. |
| 56 | // |
| 57 | FunctionPass *createEntryExitInstrumenterPass(); |
| 58 | FunctionPass *createPostInlineEntryExitInstrumenterPass(); |
| 59 | |
| 60 | //===----------------------------------------------------------------------===// |
| 61 | // |
| 62 | // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting |
| 63 | // a dummy basic block. This pass may be "required" by passes that cannot deal |
| 64 | // with critical edges. For this usage, a pass must call: |
| 65 | // |
| 66 | // AU.addRequiredID(BreakCriticalEdgesID); |
| 67 | // |
| 68 | // This pass obviously invalidates the CFG, but can update forward dominator |
| 69 | // (set, immediate dominators, tree, and frontier) information. |
| 70 | // |
| 71 | FunctionPass *createBreakCriticalEdgesPass(); |
| 72 | extern char &BreakCriticalEdgesID; |
| 73 | |
| 74 | //===----------------------------------------------------------------------===// |
| 75 | // |
| 76 | // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop |
| 77 | // optimizations. |
| 78 | // |
| 79 | Pass *createLCSSAPass(); |
| 80 | extern char &LCSSAID; |
| 81 | |
| 82 | //===----------------------------------------------------------------------===// |
| 83 | // |
| 84 | // AddDiscriminators - Add DWARF path discriminators to the IR. |
| 85 | FunctionPass *createAddDiscriminatorsPass(); |
| 86 | |
| 87 | //===----------------------------------------------------------------------===// |
| 88 | // |
| 89 | // PromoteMemoryToRegister - This pass is used to promote memory references to |
| 90 | // be register references. A simple example of the transformation performed by |
| 91 | // this pass is: |
| 92 | // |
| 93 | // FROM CODE TO CODE |
| 94 | // %X = alloca i32, i32 1 ret i32 42 |
| 95 | // store i32 42, i32 *%X |
| 96 | // %Y = load i32* %X |
| 97 | // ret i32 %Y |
| 98 | // |
| 99 | FunctionPass *createPromoteMemoryToRegisterPass(); |
| 100 | |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | // |
| 103 | // LoopSimplify - Insert Pre-header blocks into the CFG for every function in |
| 104 | // the module. This pass updates dominator information, loop information, and |
| 105 | // does not add critical edges to the CFG. |
| 106 | // |
| 107 | // AU.addRequiredID(LoopSimplifyID); |
| 108 | // |
| 109 | Pass *createLoopSimplifyPass(); |
| 110 | extern char &LoopSimplifyID; |
| 111 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 112 | /// This function returns a new pass that downgrades the debug info in the |
| 113 | /// module to line tables only. |
| 114 | ModulePass *createStripNonLineTableDebugInfoPass(); |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 115 | |
| 116 | //===----------------------------------------------------------------------===// |
| 117 | // |
| 118 | // ControlHeightReudction - Merges conditional blocks of code and reduces the |
| 119 | // number of conditional branches in the hot paths based on profiles. |
| 120 | // |
| 121 | FunctionPass *createControlHeightReductionLegacyPass(); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | #endif |