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 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
42 // a dummy basic block. This pass may be "required" by passes that cannot deal
43 // with critical edges. For this usage, a pass must call:
44 //
45 //   AU.addRequiredID(BreakCriticalEdgesID);
46 //
47 // This pass obviously invalidates the CFG, but can update forward dominator
48 // (set, immediate dominators, tree, and frontier) information.
49 //
50 FunctionPass *createBreakCriticalEdgesPass();
51 extern char &BreakCriticalEdgesID;
52 
53 //===----------------------------------------------------------------------===//
54 //
55 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
56 // optimizations.
57 //
58 Pass *createLCSSAPass();
59 extern char &LCSSAID;
60 
61 //===----------------------------------------------------------------------===//
62 //
63 // PromoteMemoryToRegister - This pass is used to promote memory references to
64 // be register references. A simple example of the transformation performed by
65 // this pass is:
66 //
67 //        FROM CODE                           TO CODE
68 //   %X = alloca i32, i32 1                 ret i32 42
69 //   store i32 42, i32 *%X
70 //   %Y = load i32* %X
71 //   ret i32 %Y
72 //
73 FunctionPass *createPromoteMemoryToRegisterPass(bool IsForced = false);
74 
75 //===----------------------------------------------------------------------===//
76 //
77 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
78 // the module.  This pass updates dominator information, loop information, and
79 // does not add critical edges to the CFG.
80 //
81 //   AU.addRequiredID(LoopSimplifyID);
82 //
83 Pass *createLoopSimplifyPass();
84 extern char &LoopSimplifyID;
85 
86 //===----------------------------------------------------------------------===//
87 //
88 // UnifyLoopExits - For each loop, creates a new block N such that all exiting
89 // blocks branch to N, and then N distributes control flow to all the original
90 // exit blocks.
91 //
92 FunctionPass *createUnifyLoopExitsPass();
93 
94 //===----------------------------------------------------------------------===//
95 //
96 // FixIrreducible - Convert each SCC with irreducible control-flow
97 // into a natural loop.
98 //
99 FunctionPass *createFixIrreduciblePass();
100 
101 //===----------------------------------------------------------------------===//
102 //
103 // CanonicalizeFreezeInLoops - Canonicalize freeze instructions in loops so they
104 // don't block SCEV.
105 //
106 Pass *createCanonicalizeFreezeInLoopsPass();
107 
108 //===----------------------------------------------------------------------===//
109 // LowerGlobalDtorsLegacy - Lower @llvm.global_dtors by creating wrapper
110 // functions that are registered in @llvm.global_ctors and which contain a call
111 // to `__cxa_atexit` to register their destructor functions.
112 ModulePass *createLowerGlobalDtorsLegacyPass();
113 } // namespace llvm
114 
115 #endif
116