IPO.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This header file defines prototypes for accessor functions that expose passes
  15. // in the IPO transformations library.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_IPO_H
  19. #define LLVM_TRANSFORMS_IPO_H
  20. #include "llvm/ADT/SmallVector.h"
  21. #include <functional>
  22. #include <vector>
  23. namespace llvm {
  24. struct InlineParams;
  25. class ModulePass;
  26. class Pass;
  27. class BasicBlock;
  28. class GlobalValue;
  29. class raw_ostream;
  30. //===----------------------------------------------------------------------===//
  31. //
  32. // This pass adds !annotation metadata to entries in the
  33. // @llvm.global.annotations global constant.
  34. //
  35. ModulePass *createAnnotation2MetadataLegacyPass();
  36. //===----------------------------------------------------------------------===//
  37. //
  38. // These functions removes symbols from functions and modules. If OnlyDebugInfo
  39. // is true, only debugging information is removed from the module.
  40. //
  41. ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
  42. //===----------------------------------------------------------------------===//
  43. //
  44. // These functions strips symbols from functions and modules.
  45. // Only debugging information is not stripped.
  46. //
  47. ModulePass *createStripNonDebugSymbolsPass();
  48. //===----------------------------------------------------------------------===//
  49. //
  50. // This pass removes llvm.dbg.declare intrinsics.
  51. ModulePass *createStripDebugDeclarePass();
  52. //===----------------------------------------------------------------------===//
  53. //
  54. // This pass removes unused symbols' debug info.
  55. ModulePass *createStripDeadDebugInfoPass();
  56. //===----------------------------------------------------------------------===//
  57. /// createConstantMergePass - This function returns a new pass that merges
  58. /// duplicate global constants together into a single constant that is shared.
  59. /// This is useful because some passes (ie TraceValues) insert a lot of string
  60. /// constants into the program, regardless of whether or not they duplicate an
  61. /// existing string.
  62. ///
  63. ModulePass *createConstantMergePass();
  64. //===----------------------------------------------------------------------===//
  65. /// createGlobalOptimizerPass - This function returns a new pass that optimizes
  66. /// non-address taken internal globals.
  67. ///
  68. ModulePass *createGlobalOptimizerPass();
  69. //===----------------------------------------------------------------------===//
  70. /// createGlobalDCEPass - This transform is designed to eliminate unreachable
  71. /// internal globals (functions or global variables)
  72. ///
  73. ModulePass *createGlobalDCEPass();
  74. //===----------------------------------------------------------------------===//
  75. /// This transform is designed to eliminate available external globals
  76. /// (functions or global variables)
  77. ///
  78. ModulePass *createEliminateAvailableExternallyPass();
  79. //===----------------------------------------------------------------------===//
  80. /// createGVExtractionPass - If deleteFn is true, this pass deletes
  81. /// the specified global values. Otherwise, it deletes as much of the module as
  82. /// possible, except for the global values specified. If keepConstInit is true,
  83. /// the initializers of global constants are not deleted even if they are
  84. /// unused.
  85. ///
  86. ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
  87. deleteFn = false, bool keepConstInit = false);
  88. //===----------------------------------------------------------------------===//
  89. /// createFunctionInliningPass - Return a new pass object that uses a heuristic
  90. /// to inline direct function calls to small functions.
  91. ///
  92. /// The Threshold can be passed directly, or asked to be computed from the
  93. /// given optimization and size optimization arguments.
  94. ///
  95. /// The -inline-threshold command line option takes precedence over the
  96. /// threshold given here.
  97. Pass *createFunctionInliningPass();
  98. Pass *createFunctionInliningPass(int Threshold);
  99. Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
  100. bool DisableInlineHotCallSite);
  101. Pass *createFunctionInliningPass(InlineParams &Params);
  102. //===----------------------------------------------------------------------===//
  103. /// createInternalizePass - This pass loops over all of the functions in the
  104. /// input module, internalizing all globals (functions and variables) it can.
  105. ////
  106. /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
  107. /// gives to the client the ability to prevent internalizing specific symbols.
  108. ///
  109. /// The symbol in DSOList are internalized if it is safe to drop them from
  110. /// the symbol table.
  111. ///
  112. /// Note that commandline options that are used with the above function are not
  113. /// used now!
  114. ModulePass *
  115. createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
  116. /// createInternalizePass - Same as above, but with an empty exportList.
  117. ModulePass *createInternalizePass();
  118. //===----------------------------------------------------------------------===//
  119. /// createDeadArgEliminationPass - This pass removes arguments from functions
  120. /// which are not used by the body of the function.
  121. ///
  122. ModulePass *createDeadArgEliminationPass();
  123. /// DeadArgHacking pass - Same as DAE, but delete arguments of external
  124. /// functions as well. This is definitely not safe, and should only be used by
  125. /// bugpoint.
  126. ModulePass *createDeadArgHackingPass();
  127. //===----------------------------------------------------------------------===//
  128. /// createIPSCCPPass - This pass propagates constants from call sites into the
  129. /// bodies of functions, and keeps track of whether basic blocks are executable
  130. /// in the process.
  131. ///
  132. ModulePass *createIPSCCPPass();
  133. //===----------------------------------------------------------------------===//
  134. //
  135. /// createLoopExtractorPass - This pass extracts all natural loops from the
  136. /// program into a function if it can.
  137. ///
  138. Pass *createLoopExtractorPass();
  139. /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
  140. /// program into a function if it can. This is used by bugpoint.
  141. ///
  142. Pass *createSingleLoopExtractorPass();
  143. /// createStripDeadPrototypesPass - This pass removes any function declarations
  144. /// (prototypes) that are not used.
  145. ModulePass *createStripDeadPrototypesPass();
  146. //===----------------------------------------------------------------------===//
  147. /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
  148. /// graph in RPO to deduce and propagate function attributes. Currently it
  149. /// only handles synthesizing norecurse attributes.
  150. ///
  151. Pass *createReversePostOrderFunctionAttrsPass();
  152. //===----------------------------------------------------------------------===//
  153. /// createMergeFunctionsPass - This pass discovers identical functions and
  154. /// collapses them.
  155. ///
  156. ModulePass *createMergeFunctionsPass();
  157. //===----------------------------------------------------------------------===//
  158. /// createHotColdSplittingPass - This pass outlines cold blocks into a separate
  159. /// function(s).
  160. ModulePass *createHotColdSplittingPass();
  161. //===----------------------------------------------------------------------===//
  162. /// createIROutlinerPass - This pass finds similar code regions and factors
  163. /// those regions out into functions.
  164. ModulePass *createIROutlinerPass();
  165. //===----------------------------------------------------------------------===//
  166. /// createPartialInliningPass - This pass inlines parts of functions.
  167. ///
  168. ModulePass *createPartialInliningPass();
  169. //===----------------------------------------------------------------------===//
  170. /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
  171. /// manager.
  172. ModulePass *createBarrierNoopPass();
  173. /// createCalledValuePropagationPass - Attach metadata to indirct call sites
  174. /// indicating the set of functions they may target at run-time.
  175. ModulePass *createCalledValuePropagationPass();
  176. /// What to do with the summary when running passes that operate on it.
  177. enum class PassSummaryAction {
  178. None, ///< Do nothing.
  179. Import, ///< Import information from summary.
  180. Export, ///< Export information to summary.
  181. };
  182. /// This pass export CFI checks for use by external modules.
  183. ModulePass *createCrossDSOCFIPass();
  184. /// This pass splits globals into pieces for the benefit of whole-program
  185. /// devirtualization and control-flow integrity.
  186. ModulePass *createGlobalSplitPass();
  187. } // End llvm namespace
  188. #endif
  189. #ifdef __GNUC__
  190. #pragma GCC diagnostic pop
  191. #endif