IPO.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This header file defines prototypes for accessor functions that expose passes
  11. // in the IPO transformations library.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_TRANSFORMS_IPO_H
  15. #define LLVM_TRANSFORMS_IPO_H
  16. #include "llvm/ADT/ArrayRef.h"
  17. namespace llvm {
  18. class ModulePass;
  19. class Pass;
  20. class Function;
  21. class BasicBlock;
  22. class GlobalValue;
  23. //===----------------------------------------------------------------------===//
  24. //
  25. // These functions removes symbols from functions and modules. If OnlyDebugInfo
  26. // is true, only debugging information is removed from the module.
  27. //
  28. ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
  29. //===----------------------------------------------------------------------===//
  30. //
  31. // These functions strips symbols from functions and modules.
  32. // Only debugging information is not stripped.
  33. //
  34. ModulePass *createStripNonDebugSymbolsPass();
  35. //===----------------------------------------------------------------------===//
  36. //
  37. // These pass removes llvm.dbg.declare intrinsics.
  38. ModulePass *createStripDebugDeclarePass();
  39. //===----------------------------------------------------------------------===//
  40. //
  41. // These pass removes unused symbols' debug info.
  42. ModulePass *createStripDeadDebugInfoPass();
  43. //===----------------------------------------------------------------------===//
  44. /// createConstantMergePass - This function returns a new pass that merges
  45. /// duplicate global constants together into a single constant that is shared.
  46. /// This is useful because some passes (ie TraceValues) insert a lot of string
  47. /// constants into the program, regardless of whether or not they duplicate an
  48. /// existing string.
  49. ///
  50. ModulePass *createConstantMergePass();
  51. //===----------------------------------------------------------------------===//
  52. /// createGlobalOptimizerPass - This function returns a new pass that optimizes
  53. /// non-address taken internal globals.
  54. ///
  55. ModulePass *createGlobalOptimizerPass();
  56. //===----------------------------------------------------------------------===//
  57. /// createGlobalDCEPass - This transform is designed to eliminate unreachable
  58. /// internal globals (functions or global variables)
  59. ///
  60. ModulePass *createGlobalDCEPass();
  61. //===----------------------------------------------------------------------===//
  62. /// This transform is designed to eliminate available external globals
  63. /// (functions or global variables)
  64. ///
  65. ModulePass *createEliminateAvailableExternallyPass();
  66. //===----------------------------------------------------------------------===//
  67. /// createGVExtractionPass - If deleteFn is true, this pass deletes
  68. /// the specified global values. Otherwise, it deletes as much of the module as
  69. /// possible, except for the global values specified.
  70. ///
  71. ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
  72. deleteFn = false);
  73. //===----------------------------------------------------------------------===//
  74. /// createFunctionInliningPass - Return a new pass object that uses a heuristic
  75. /// to inline direct function calls to small functions.
  76. ///
  77. /// The Threshold can be passed directly, or asked to be computed from the
  78. /// given optimization and size optimization arguments.
  79. ///
  80. /// The -inline-threshold command line option takes precedence over the
  81. /// threshold given here.
  82. Pass *createFunctionInliningPass();
  83. Pass *createFunctionInliningPass(int Threshold);
  84. Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
  85. //===----------------------------------------------------------------------===//
  86. /// createAlwaysInlinerPass - Return a new pass object that inlines only
  87. /// functions that are marked as "always_inline".
  88. Pass *createAlwaysInlinerPass();
  89. Pass *createAlwaysInlinerPass(bool InsertLifetime);
  90. //===----------------------------------------------------------------------===//
  91. /// createPruneEHPass - Return a new pass object which transforms invoke
  92. /// instructions into calls, if the callee can _not_ unwind the stack.
  93. ///
  94. Pass *createPruneEHPass();
  95. //===----------------------------------------------------------------------===//
  96. /// createInternalizePass - This pass loops over all of the functions in the
  97. /// input module, internalizing all globals (functions and variables) it can.
  98. ////
  99. /// The symbols in \p ExportList are never internalized.
  100. ///
  101. /// The symbol in DSOList are internalized if it is safe to drop them from
  102. /// the symbol table.
  103. ///
  104. /// Note that commandline options that are used with the above function are not
  105. /// used now!
  106. ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
  107. /// createInternalizePass - Same as above, but with an empty exportList.
  108. ModulePass *createInternalizePass();
  109. //===----------------------------------------------------------------------===//
  110. /// createDeadArgEliminationPass - This pass removes arguments from functions
  111. /// which are not used by the body of the function.
  112. ///
  113. ModulePass *createDeadArgEliminationPass();
  114. /// DeadArgHacking pass - Same as DAE, but delete arguments of external
  115. /// functions as well. This is definitely not safe, and should only be used by
  116. /// bugpoint.
  117. ModulePass *createDeadArgHackingPass();
  118. //===----------------------------------------------------------------------===//
  119. /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
  120. /// be passed by value if the number of elements passed is smaller or
  121. /// equal to maxElements (maxElements == 0 means always promote).
  122. ///
  123. Pass *createArgumentPromotionPass(unsigned maxElements = 3);
  124. //===----------------------------------------------------------------------===//
  125. /// createIPConstantPropagationPass - This pass propagates constants from call
  126. /// sites into the bodies of functions.
  127. ///
  128. ModulePass *createIPConstantPropagationPass();
  129. //===----------------------------------------------------------------------===//
  130. /// createIPSCCPPass - This pass propagates constants from call sites into the
  131. /// bodies of functions, and keeps track of whether basic blocks are executable
  132. /// in the process.
  133. ///
  134. ModulePass *createIPSCCPPass();
  135. //===----------------------------------------------------------------------===//
  136. //
  137. /// createLoopExtractorPass - This pass extracts all natural loops from the
  138. /// program into a function if it can.
  139. ///
  140. Pass *createLoopExtractorPass();
  141. /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
  142. /// program into a function if it can. This is used by bugpoint.
  143. ///
  144. Pass *createSingleLoopExtractorPass();
  145. /// createBlockExtractorPass - This pass extracts all blocks (except those
  146. /// specified in the argument list) from the functions in the module.
  147. ///
  148. ModulePass *createBlockExtractorPass();
  149. /// createStripDeadPrototypesPass - This pass removes any function declarations
  150. /// (prototypes) that are not used.
  151. ModulePass *createStripDeadPrototypesPass();
  152. //===----------------------------------------------------------------------===//
  153. /// createFunctionAttrsPass - This pass discovers functions that do not access
  154. /// memory, or only read memory, and gives them the readnone/readonly attribute.
  155. /// It also discovers function arguments that are not captured by the function
  156. /// and marks them with the nocapture attribute.
  157. ///
  158. Pass *createFunctionAttrsPass();
  159. //===----------------------------------------------------------------------===//
  160. /// createMergeFunctionsPass - This pass discovers identical functions and
  161. /// collapses them.
  162. ///
  163. ModulePass *createMergeFunctionsPass();
  164. //===----------------------------------------------------------------------===//
  165. /// createPartialInliningPass - This pass inlines parts of functions.
  166. ///
  167. ModulePass *createPartialInliningPass();
  168. //===----------------------------------------------------------------------===//
  169. // createMetaRenamerPass - Rename everything with metasyntatic names.
  170. //
  171. ModulePass *createMetaRenamerPass();
  172. // //
  173. ///////////////////////////////////////////////////////////////////////////////
  174. /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
  175. /// manager.
  176. ModulePass *createBarrierNoopPass();
  177. /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
  178. /// to bitsets.
  179. ModulePass *createLowerBitSetsPass();
  180. } // End llvm namespace
  181. #endif