• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
25 // LowerInvoke - This pass removes invoke instructions, converting them to call
26 // instructions.
27 //
28 FunctionPass *createLowerInvokePass();
29 extern char &LowerInvokePassID;
30 
31 //===----------------------------------------------------------------------===//
32 //
33 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
34 // chained binary branch instructions.
35 //
36 FunctionPass *createLowerSwitchPass();
37 extern char &LowerSwitchID;
38 
39 //===----------------------------------------------------------------------===//
40 //
41 // EntryExitInstrumenter pass - Instrument function entry/exit with calls to
42 // mcount(), @__cyg_profile_func_{enter,exit} and the like. There are two
43 // variants, intended to run pre- and post-inlining, respectively. Only the
44 // post-inlining variant is used with the legacy pass manager.
45 //
46 FunctionPass *createPostInlineEntryExitInstrumenterPass();
47 
48 //===----------------------------------------------------------------------===//
49 //
50 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
51 // a dummy basic block. This pass may be "required" by passes that cannot deal
52 // with critical edges. For this usage, a pass must call:
53 //
54 //   AU.addRequiredID(BreakCriticalEdgesID);
55 //
56 // This pass obviously invalidates the CFG, but can update forward dominator
57 // (set, immediate dominators, tree, and frontier) information.
58 //
59 FunctionPass *createBreakCriticalEdgesPass();
60 extern char &BreakCriticalEdgesID;
61 
62 //===----------------------------------------------------------------------===//
63 //
64 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
65 // optimizations.
66 //
67 Pass *createLCSSAPass();
68 extern char &LCSSAID;
69 
70 //===----------------------------------------------------------------------===//
71 //
72 // PromoteMemoryToRegister - This pass is used to promote memory references to
73 // be register references. A simple example of the transformation performed by
74 // this pass is:
75 //
76 //        FROM CODE                           TO CODE
77 //   %X = alloca i32, i32 1                 ret i32 42
78 //   store i32 42, i32 *%X
79 //   %Y = load i32* %X
80 //   ret i32 %Y
81 //
82 FunctionPass *createPromoteMemoryToRegisterPass();
83 
84 //===----------------------------------------------------------------------===//
85 //
86 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
87 // the module.  This pass updates dominator information, loop information, and
88 // does not add critical edges to the CFG.
89 //
90 //   AU.addRequiredID(LoopSimplifyID);
91 //
92 Pass *createLoopSimplifyPass();
93 extern char &LoopSimplifyID;
94 
95 //===----------------------------------------------------------------------===//
96 //
97 // UnifyLoopExits - For each loop, creates a new block N such that all exiting
98 // blocks branch to N, and then N distributes control flow to all the original
99 // exit blocks.
100 //
101 FunctionPass *createUnifyLoopExitsPass();
102 
103 //===----------------------------------------------------------------------===//
104 //
105 // FixIrreducible - Convert each SCC with irreducible control-flow
106 // into a natural loop.
107 //
108 FunctionPass *createFixIrreduciblePass();
109 
110 //===----------------------------------------------------------------------===//
111 //
112 // CanonicalizeFreezeInLoops - Canonicalize freeze instructions in loops so they
113 // don't block SCEV.
114 //
115 Pass *createCanonicalizeFreezeInLoopsPass();
116 
117 //===----------------------------------------------------------------------===//
118 // LowerGlobalDtorsLegacy - Lower @llvm.global_dtors by creating wrapper
119 // functions that are registered in @llvm.global_ctors and which contain a call
120 // to `__cxa_atexit` to register their destructor functions.
121 ModulePass *createLowerGlobalDtorsLegacyPass();
122 } // namespace llvm
123 
124 #endif
125