1 //===- llvm/Transforms/Utils.h - Utility Transformations --------*- C++ -*-===//
2 //
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
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 // createUniqueInternalLinkageNamesPass - Make internal linkage symbol names
30 // unique.
31 //
32 ModulePass *createUniqueInternalLinkageNamesPass();
33 
34 //===----------------------------------------------------------------------===//
35 //
36 // LowerInvoke - This pass removes invoke instructions, converting them to call
37 // instructions.
38 //
39 FunctionPass *createLowerInvokePass();
40 extern char &LowerInvokePassID;
41 
42 //===----------------------------------------------------------------------===//
43 //
44 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
45 //
46 FunctionPass *createInstructionNamerPass();
47 extern char &InstructionNamerID;
48 
49 //===----------------------------------------------------------------------===//
50 //
51 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
52 // chained binary branch instructions.
53 //
54 FunctionPass *createLowerSwitchPass();
55 extern char &LowerSwitchID;
56 
57 //===----------------------------------------------------------------------===//
58 //
59 // EntryExitInstrumenter pass - Instrument function entry/exit with calls to
60 // mcount(), @__cyg_profile_func_{enter,exit} and the like. There are two
61 // variants, intended to run pre- and post-inlining, respectively.
62 //
63 FunctionPass *createEntryExitInstrumenterPass();
64 FunctionPass *createPostInlineEntryExitInstrumenterPass();
65 
66 //===----------------------------------------------------------------------===//
67 //
68 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
69 // a dummy basic block. This pass may be "required" by passes that cannot deal
70 // with critical edges. For this usage, a pass must call:
71 //
72 //   AU.addRequiredID(BreakCriticalEdgesID);
73 //
74 // This pass obviously invalidates the CFG, but can update forward dominator
75 // (set, immediate dominators, tree, and frontier) information.
76 //
77 FunctionPass *createBreakCriticalEdgesPass();
78 extern char &BreakCriticalEdgesID;
79 
80 //===----------------------------------------------------------------------===//
81 //
82 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
83 // optimizations.
84 //
85 Pass *createLCSSAPass();
86 extern char &LCSSAID;
87 
88 //===----------------------------------------------------------------------===//
89 //
90 // AddDiscriminators - Add DWARF path discriminators to the IR.
91 FunctionPass *createAddDiscriminatorsPass();
92 
93 //===----------------------------------------------------------------------===//
94 //
95 // PromoteMemoryToRegister - This pass is used to promote memory references to
96 // be register references. A simple example of the transformation performed by
97 // this pass is:
98 //
99 //        FROM CODE                           TO CODE
100 //   %X = alloca i32, i32 1                 ret i32 42
101 //   store i32 42, i32 *%X
102 //   %Y = load i32* %X
103 //   ret i32 %Y
104 //
105 FunctionPass *createPromoteMemoryToRegisterPass();
106 
107 //===----------------------------------------------------------------------===//
108 //
109 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
110 // the module.  This pass updates dominator information, loop information, and
111 // does not add critical edges to the CFG.
112 //
113 //   AU.addRequiredID(LoopSimplifyID);
114 //
115 Pass *createLoopSimplifyPass();
116 extern char &LoopSimplifyID;
117 
118 /// This function returns a new pass that downgrades the debug info in the
119 /// module to line tables only.
120 ModulePass *createStripNonLineTableDebugLegacyPass();
121 
122 //===----------------------------------------------------------------------===//
123 //
124 // ControlHeightReudction - Merges conditional blocks of code and reduces the
125 // number of conditional branches in the hot paths based on profiles.
126 //
127 FunctionPass *createControlHeightReductionLegacyPass();
128 
129 //===----------------------------------------------------------------------===//
130 //
131 // InjectTLIMappingsLegacy - populates the VFABI attribute with the
132 // scalar-to-vector mappings from the TargetLibraryInfo.
133 //
134 FunctionPass *createInjectTLIMappingsLegacyPass();
135 
136 //===----------------------------------------------------------------------===//
137 //
138 // UnifyLoopExits - For each loop, creates a new block N such that all exiting
139 // blocks branch to N, and then N distributes control flow to all the original
140 // exit blocks.
141 //
142 FunctionPass *createUnifyLoopExitsPass();
143 
144 //===----------------------------------------------------------------------===//
145 //
146 // FixIrreducible - Convert each SCC with irreducible control-flow
147 // into a natural loop.
148 //
149 FunctionPass *createFixIrreduciblePass();
150 
151 //===----------------------------------------------------------------------===//
152 //
153 // AssumeSimplify - remove redundant assumes and merge assumes in the same
154 // BasicBlock when possible.
155 //
156 FunctionPass *createAssumeSimplifyPass();
157 
158 //===----------------------------------------------------------------------===//
159 //
160 // CanonicalizeFreezeInLoops - Canonicalize freeze instructions in loops so they
161 // don't block SCEV.
162 //
163 Pass *createCanonicalizeFreezeInLoopsPass();
164 } // namespace llvm
165 
166 #endif
167