optimizer.hpp 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. // Copyright (c) 2016 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_
  15. #define INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_
  16. #include <memory>
  17. #include <ostream>
  18. #include <string>
  19. #include <unordered_map>
  20. #include <unordered_set>
  21. #include <utility>
  22. #include <vector>
  23. #include "libspirv.hpp"
  24. namespace spvtools {
  25. namespace opt {
  26. class Pass;
  27. struct DescriptorSetAndBinding;
  28. } // namespace opt
  29. // C++ interface for SPIR-V optimization functionalities. It wraps the context
  30. // (including target environment and the corresponding SPIR-V grammar) and
  31. // provides methods for registering optimization passes and optimizing.
  32. //
  33. // Instances of this class provides basic thread-safety guarantee.
  34. class Optimizer {
  35. public:
  36. // The token for an optimization pass. It is returned via one of the
  37. // Create*Pass() standalone functions at the end of this header file and
  38. // consumed by the RegisterPass() method. Tokens are one-time objects that
  39. // only support move; copying is not allowed.
  40. struct PassToken {
  41. struct Impl; // Opaque struct for holding internal data.
  42. PassToken(std::unique_ptr<Impl>);
  43. // Tokens for built-in passes should be created using Create*Pass functions
  44. // below; for out-of-tree passes, use this constructor instead.
  45. // Note that this API isn't guaranteed to be stable and may change without
  46. // preserving source or binary compatibility in the future.
  47. PassToken(std::unique_ptr<opt::Pass>&& pass);
  48. // Tokens can only be moved. Copying is disabled.
  49. PassToken(const PassToken&) = delete;
  50. PassToken(PassToken&&);
  51. PassToken& operator=(const PassToken&) = delete;
  52. PassToken& operator=(PassToken&&);
  53. ~PassToken();
  54. std::unique_ptr<Impl> impl_; // Unique pointer to internal data.
  55. };
  56. // Constructs an instance with the given target |env|, which is used to decode
  57. // the binaries to be optimized later.
  58. //
  59. // The instance will have an empty message consumer, which ignores all
  60. // messages from the library. Use SetMessageConsumer() to supply a consumer
  61. // if messages are of concern.
  62. explicit Optimizer(spv_target_env env);
  63. // Disables copy/move constructor/assignment operations.
  64. Optimizer(const Optimizer&) = delete;
  65. Optimizer(Optimizer&&) = delete;
  66. Optimizer& operator=(const Optimizer&) = delete;
  67. Optimizer& operator=(Optimizer&&) = delete;
  68. // Destructs this instance.
  69. ~Optimizer();
  70. // Sets the message consumer to the given |consumer|. The |consumer| will be
  71. // invoked once for each message communicated from the library.
  72. void SetMessageConsumer(MessageConsumer consumer);
  73. // Returns a reference to the registered message consumer.
  74. const MessageConsumer& consumer() const;
  75. // Registers the given |pass| to this optimizer. Passes will be run in the
  76. // exact order of registration. The token passed in will be consumed by this
  77. // method.
  78. Optimizer& RegisterPass(PassToken&& pass);
  79. // Registers passes that attempt to improve performance of generated code.
  80. // This sequence of passes is subject to constant review and will change
  81. // from time to time.
  82. Optimizer& RegisterPerformancePasses();
  83. // Registers passes that attempt to improve the size of generated code.
  84. // This sequence of passes is subject to constant review and will change
  85. // from time to time.
  86. Optimizer& RegisterSizePasses();
  87. // Registers passes that attempt to legalize the generated code.
  88. //
  89. // Note: this recipe is specially designed for legalizing SPIR-V. It should be
  90. // used by compilers after translating HLSL source code literally. It should
  91. // *not* be used by general workloads for performance or size improvement.
  92. //
  93. // This sequence of passes is subject to constant review and will change
  94. // from time to time.
  95. Optimizer& RegisterLegalizationPasses();
  96. // Register passes specified in the list of |flags|. Each flag must be a
  97. // string of a form accepted by Optimizer::FlagHasValidForm().
  98. //
  99. // If the list of flags contains an invalid entry, it returns false and an
  100. // error message is emitted to the MessageConsumer object (use
  101. // Optimizer::SetMessageConsumer to define a message consumer, if needed).
  102. //
  103. // If all the passes are registered successfully, it returns true.
  104. bool RegisterPassesFromFlags(const std::vector<std::string>& flags);
  105. // Registers the optimization pass associated with |flag|. This only accepts
  106. // |flag| values of the form "--pass_name[=pass_args]". If no such pass
  107. // exists, it returns false. Otherwise, the pass is registered and it returns
  108. // true.
  109. //
  110. // The following flags have special meaning:
  111. //
  112. // -O: Registers all performance optimization passes
  113. // (Optimizer::RegisterPerformancePasses)
  114. //
  115. // -Os: Registers all size optimization passes
  116. // (Optimizer::RegisterSizePasses).
  117. //
  118. // --legalize-hlsl: Registers all passes that legalize SPIR-V generated by an
  119. // HLSL front-end.
  120. bool RegisterPassFromFlag(const std::string& flag);
  121. // Validates that |flag| has a valid format. Strings accepted:
  122. //
  123. // --pass_name[=pass_args]
  124. // -O
  125. // -Os
  126. //
  127. // If |flag| takes one of the forms above, it returns true. Otherwise, it
  128. // returns false.
  129. bool FlagHasValidForm(const std::string& flag) const;
  130. // Allows changing, after creation time, the target environment to be
  131. // optimized for and validated. Should be called before calling Run().
  132. void SetTargetEnv(const spv_target_env env);
  133. // Optimizes the given SPIR-V module |original_binary| and writes the
  134. // optimized binary into |optimized_binary|. The optimized binary uses
  135. // the same SPIR-V version as the original binary.
  136. //
  137. // Returns true on successful optimization, whether or not the module is
  138. // modified. Returns false if |original_binary| fails to validate or if errors
  139. // occur when processing |original_binary| using any of the registered passes.
  140. // In that case, no further passes are executed and the contents in
  141. // |optimized_binary| may be invalid.
  142. //
  143. // By default, the binary is validated before any transforms are performed,
  144. // and optionally after each transform. Validation uses SPIR-V spec rules
  145. // for the SPIR-V version named in the binary's header (at word offset 1).
  146. // Additionally, if the target environment is a client API (such as
  147. // Vulkan 1.1), then validate for that client API version, to the extent
  148. // that it is verifiable from data in the binary itself.
  149. //
  150. // It's allowed to alias |original_binary| to the start of |optimized_binary|.
  151. bool Run(const uint32_t* original_binary, size_t original_binary_size,
  152. std::vector<uint32_t>* optimized_binary) const;
  153. // DEPRECATED: Same as above, except passes |options| to the validator when
  154. // trying to validate the binary. If |skip_validation| is true, then the
  155. // caller is guaranteeing that |original_binary| is valid, and the validator
  156. // will not be run. The |max_id_bound| is the limit on the max id in the
  157. // module.
  158. bool Run(const uint32_t* original_binary, const size_t original_binary_size,
  159. std::vector<uint32_t>* optimized_binary,
  160. const ValidatorOptions& options, bool skip_validation) const;
  161. // Same as above, except it takes an options object. See the documentation
  162. // for |OptimizerOptions| to see which options can be set.
  163. //
  164. // By default, the binary is validated before any transforms are performed,
  165. // and optionally after each transform. Validation uses SPIR-V spec rules
  166. // for the SPIR-V version named in the binary's header (at word offset 1).
  167. // Additionally, if the target environment is a client API (such as
  168. // Vulkan 1.1), then validate for that client API version, to the extent
  169. // that it is verifiable from data in the binary itself, or from the
  170. // validator options set on the optimizer options.
  171. bool Run(const uint32_t* original_binary, const size_t original_binary_size,
  172. std::vector<uint32_t>* optimized_binary,
  173. const spv_optimizer_options opt_options) const;
  174. // Returns a vector of strings with all the pass names added to this
  175. // optimizer's pass manager. These strings are valid until the associated
  176. // pass manager is destroyed.
  177. std::vector<const char*> GetPassNames() const;
  178. // Sets the option to print the disassembly before each pass and after the
  179. // last pass. If |out| is null, then no output is generated. Otherwise,
  180. // output is sent to the |out| output stream.
  181. Optimizer& SetPrintAll(std::ostream* out);
  182. // Sets the option to print the resource utilization of each pass. If |out|
  183. // is null, then no output is generated. Otherwise, output is sent to the
  184. // |out| output stream.
  185. Optimizer& SetTimeReport(std::ostream* out);
  186. // Sets the option to validate the module after each pass.
  187. Optimizer& SetValidateAfterAll(bool validate);
  188. private:
  189. struct Impl; // Opaque struct for holding internal data.
  190. std::unique_ptr<Impl> impl_; // Unique pointer to internal data.
  191. };
  192. // Creates a null pass.
  193. // A null pass does nothing to the SPIR-V module to be optimized.
  194. Optimizer::PassToken CreateNullPass();
  195. // Creates a strip-debug-info pass.
  196. // A strip-debug-info pass removes all debug instructions (as documented in
  197. // Section 3.42.2 of the SPIR-V spec) of the SPIR-V module to be optimized.
  198. Optimizer::PassToken CreateStripDebugInfoPass();
  199. // [Deprecated] This will create a strip-nonsemantic-info pass. See below.
  200. Optimizer::PassToken CreateStripReflectInfoPass();
  201. // Creates a strip-nonsemantic-info pass.
  202. // A strip-nonsemantic-info pass removes all reflections and explicitly
  203. // non-semantic instructions.
  204. Optimizer::PassToken CreateStripNonSemanticInfoPass();
  205. // Creates an eliminate-dead-functions pass.
  206. // An eliminate-dead-functions pass will remove all functions that are not in
  207. // the call trees rooted at entry points and exported functions. These
  208. // functions are not needed because they will never be called.
  209. Optimizer::PassToken CreateEliminateDeadFunctionsPass();
  210. // Creates an eliminate-dead-members pass.
  211. // An eliminate-dead-members pass will remove all unused members of structures.
  212. // This will not affect the data layout of the remaining members.
  213. Optimizer::PassToken CreateEliminateDeadMembersPass();
  214. // Creates a set-spec-constant-default-value pass from a mapping from spec-ids
  215. // to the default values in the form of string.
  216. // A set-spec-constant-default-value pass sets the default values for the
  217. // spec constants that have SpecId decorations (i.e., those defined by
  218. // OpSpecConstant{|True|False} instructions).
  219. Optimizer::PassToken CreateSetSpecConstantDefaultValuePass(
  220. const std::unordered_map<uint32_t, std::string>& id_value_map);
  221. // Creates a set-spec-constant-default-value pass from a mapping from spec-ids
  222. // to the default values in the form of bit pattern.
  223. // A set-spec-constant-default-value pass sets the default values for the
  224. // spec constants that have SpecId decorations (i.e., those defined by
  225. // OpSpecConstant{|True|False} instructions).
  226. Optimizer::PassToken CreateSetSpecConstantDefaultValuePass(
  227. const std::unordered_map<uint32_t, std::vector<uint32_t>>& id_value_map);
  228. // Creates a flatten-decoration pass.
  229. // A flatten-decoration pass replaces grouped decorations with equivalent
  230. // ungrouped decorations. That is, it replaces each OpDecorationGroup
  231. // instruction and associated OpGroupDecorate and OpGroupMemberDecorate
  232. // instructions with equivalent OpDecorate and OpMemberDecorate instructions.
  233. // The pass does not attempt to preserve debug information for instructions
  234. // it removes.
  235. Optimizer::PassToken CreateFlattenDecorationPass();
  236. // Creates a freeze-spec-constant-value pass.
  237. // A freeze-spec-constant pass specializes the value of spec constants to
  238. // their default values. This pass only processes the spec constants that have
  239. // SpecId decorations (defined by OpSpecConstant, OpSpecConstantTrue, or
  240. // OpSpecConstantFalse instructions) and replaces them with their normal
  241. // counterparts (OpConstant, OpConstantTrue, or OpConstantFalse). The
  242. // corresponding SpecId annotation instructions will also be removed. This
  243. // pass does not fold the newly added normal constants and does not process
  244. // other spec constants defined by OpSpecConstantComposite or
  245. // OpSpecConstantOp.
  246. Optimizer::PassToken CreateFreezeSpecConstantValuePass();
  247. // Creates a fold-spec-constant-op-and-composite pass.
  248. // A fold-spec-constant-op-and-composite pass folds spec constants defined by
  249. // OpSpecConstantOp or OpSpecConstantComposite instruction, to normal Constants
  250. // defined by OpConstantTrue, OpConstantFalse, OpConstant, OpConstantNull, or
  251. // OpConstantComposite instructions. Note that spec constants defined with
  252. // OpSpecConstant, OpSpecConstantTrue, or OpSpecConstantFalse instructions are
  253. // not handled, as these instructions indicate their value are not determined
  254. // and can be changed in future. A spec constant is foldable if all of its
  255. // value(s) can be determined from the module. E.g., an integer spec constant
  256. // defined with OpSpecConstantOp instruction can be folded if its value won't
  257. // change later. This pass will replace the original OpSpecConstantOp
  258. // instruction with an OpConstant instruction. When folding composite spec
  259. // constants, new instructions may be inserted to define the components of the
  260. // composite constant first, then the original spec constants will be replaced
  261. // by OpConstantComposite instructions.
  262. //
  263. // There are some operations not supported yet:
  264. // OpSConvert, OpFConvert, OpQuantizeToF16 and
  265. // all the operations under Kernel capability.
  266. // TODO(qining): Add support for the operations listed above.
  267. Optimizer::PassToken CreateFoldSpecConstantOpAndCompositePass();
  268. // Creates a unify-constant pass.
  269. // A unify-constant pass de-duplicates the constants. Constants with the exact
  270. // same value and identical form will be unified and only one constant will
  271. // be kept for each unique pair of type and value.
  272. // There are several cases not handled by this pass:
  273. // 1) Constants defined by OpConstantNull instructions (null constants) and
  274. // constants defined by OpConstantFalse, OpConstant or OpConstantComposite
  275. // with value 0 (zero-valued normal constants) are not considered equivalent.
  276. // So null constants won't be used to replace zero-valued normal constants,
  277. // vice versa.
  278. // 2) Whenever there are decorations to the constant's result id id, the
  279. // constant won't be handled, which means, it won't be used to replace any
  280. // other constants, neither can other constants replace it.
  281. // 3) NaN in float point format with different bit patterns are not unified.
  282. Optimizer::PassToken CreateUnifyConstantPass();
  283. // Creates a eliminate-dead-constant pass.
  284. // A eliminate-dead-constant pass removes dead constants, including normal
  285. // constants defined by OpConstant, OpConstantComposite, OpConstantTrue, or
  286. // OpConstantFalse and spec constants defined by OpSpecConstant,
  287. // OpSpecConstantComposite, OpSpecConstantTrue, OpSpecConstantFalse or
  288. // OpSpecConstantOp.
  289. Optimizer::PassToken CreateEliminateDeadConstantPass();
  290. // Creates a strength-reduction pass.
  291. // A strength-reduction pass will look for opportunities to replace an
  292. // instruction with an equivalent and less expensive one. For example,
  293. // multiplying by a power of 2 can be replaced by a bit shift.
  294. Optimizer::PassToken CreateStrengthReductionPass();
  295. // Creates a block merge pass.
  296. // This pass searches for blocks with a single Branch to a block with no
  297. // other predecessors and merges the blocks into a single block. Continue
  298. // blocks and Merge blocks are not candidates for the second block.
  299. //
  300. // The pass is most useful after Dead Branch Elimination, which can leave
  301. // such sequences of blocks. Merging them makes subsequent passes more
  302. // effective, such as single block local store-load elimination.
  303. //
  304. // While this pass reduces the number of occurrences of this sequence, at
  305. // this time it does not guarantee all such sequences are eliminated.
  306. //
  307. // Presence of phi instructions can inhibit this optimization. Handling
  308. // these is left for future improvements.
  309. Optimizer::PassToken CreateBlockMergePass();
  310. // Creates an exhaustive inline pass.
  311. // An exhaustive inline pass attempts to exhaustively inline all function
  312. // calls in all functions in an entry point call tree. The intent is to enable,
  313. // albeit through brute force, analysis and optimization across function
  314. // calls by subsequent optimization passes. As the inlining is exhaustive,
  315. // there is no attempt to optimize for size or runtime performance. Functions
  316. // that are not in the call tree of an entry point are not changed.
  317. Optimizer::PassToken CreateInlineExhaustivePass();
  318. // Creates an opaque inline pass.
  319. // An opaque inline pass inlines all function calls in all functions in all
  320. // entry point call trees where the called function contains an opaque type
  321. // in either its parameter types or return type. An opaque type is currently
  322. // defined as Image, Sampler or SampledImage. The intent is to enable, albeit
  323. // through brute force, analysis and optimization across these function calls
  324. // by subsequent passes in order to remove the storing of opaque types which is
  325. // not legal in Vulkan. Functions that are not in the call tree of an entry
  326. // point are not changed.
  327. Optimizer::PassToken CreateInlineOpaquePass();
  328. // Creates a single-block local variable load/store elimination pass.
  329. // For every entry point function, do single block memory optimization of
  330. // function variables referenced only with non-access-chain loads and stores.
  331. // For each targeted variable load, if previous store to that variable in the
  332. // block, replace the load's result id with the value id of the store.
  333. // If previous load within the block, replace the current load's result id
  334. // with the previous load's result id. In either case, delete the current
  335. // load. Finally, check if any remaining stores are useless, and delete store
  336. // and variable if possible.
  337. //
  338. // The presence of access chain references and function calls can inhibit
  339. // the above optimization.
  340. //
  341. // Only modules with relaxed logical addressing (see opt/instruction.h) are
  342. // currently processed.
  343. //
  344. // This pass is most effective if preceded by Inlining and
  345. // LocalAccessChainConvert. This pass will reduce the work needed to be done
  346. // by LocalSingleStoreElim and LocalMultiStoreElim.
  347. //
  348. // Only functions in the call tree of an entry point are processed.
  349. Optimizer::PassToken CreateLocalSingleBlockLoadStoreElimPass();
  350. // Create dead branch elimination pass.
  351. // For each entry point function, this pass will look for SelectionMerge
  352. // BranchConditionals with constant condition and convert to a Branch to
  353. // the indicated label. It will delete resulting dead blocks.
  354. //
  355. // For all phi functions in merge block, replace all uses with the id
  356. // corresponding to the living predecessor.
  357. //
  358. // Note that some branches and blocks may be left to avoid creating invalid
  359. // control flow. Improving this is left to future work.
  360. //
  361. // This pass is most effective when preceded by passes which eliminate
  362. // local loads and stores, effectively propagating constant values where
  363. // possible.
  364. Optimizer::PassToken CreateDeadBranchElimPass();
  365. // Creates an SSA local variable load/store elimination pass.
  366. // For every entry point function, eliminate all loads and stores of function
  367. // scope variables only referenced with non-access-chain loads and stores.
  368. // Eliminate the variables as well.
  369. //
  370. // The presence of access chain references and function calls can inhibit
  371. // the above optimization.
  372. //
  373. // Only shader modules with relaxed logical addressing (see opt/instruction.h)
  374. // are currently processed. Currently modules with any extensions enabled are
  375. // not processed. This is left for future work.
  376. //
  377. // This pass is most effective if preceded by Inlining and
  378. // LocalAccessChainConvert. LocalSingleStoreElim and LocalSingleBlockElim
  379. // will reduce the work that this pass has to do.
  380. Optimizer::PassToken CreateLocalMultiStoreElimPass();
  381. // Creates a local access chain conversion pass.
  382. // A local access chain conversion pass identifies all function scope
  383. // variables which are accessed only with loads, stores and access chains
  384. // with constant indices. It then converts all loads and stores of such
  385. // variables into equivalent sequences of loads, stores, extracts and inserts.
  386. //
  387. // This pass only processes entry point functions. It currently only converts
  388. // non-nested, non-ptr access chains. It does not process modules with
  389. // non-32-bit integer types present. Optional memory access options on loads
  390. // and stores are ignored as we are only processing function scope variables.
  391. //
  392. // This pass unifies access to these variables to a single mode and simplifies
  393. // subsequent analysis and elimination of these variables along with their
  394. // loads and stores allowing values to propagate to their points of use where
  395. // possible.
  396. Optimizer::PassToken CreateLocalAccessChainConvertPass();
  397. // Creates a local single store elimination pass.
  398. // For each entry point function, this pass eliminates loads and stores for
  399. // function scope variable that are stored to only once, where possible. Only
  400. // whole variable loads and stores are eliminated; access-chain references are
  401. // not optimized. Replace all loads of such variables with the value that is
  402. // stored and eliminate any resulting dead code.
  403. //
  404. // Currently, the presence of access chains and function calls can inhibit this
  405. // pass, however the Inlining and LocalAccessChainConvert passes can make it
  406. // more effective. In additional, many non-load/store memory operations are
  407. // not supported and will prohibit optimization of a function. Support of
  408. // these operations are future work.
  409. //
  410. // Only shader modules with relaxed logical addressing (see opt/instruction.h)
  411. // are currently processed.
  412. //
  413. // This pass will reduce the work needed to be done by LocalSingleBlockElim
  414. // and LocalMultiStoreElim and can improve the effectiveness of other passes
  415. // such as DeadBranchElimination which depend on values for their analysis.
  416. Optimizer::PassToken CreateLocalSingleStoreElimPass();
  417. // Creates an insert/extract elimination pass.
  418. // This pass processes each entry point function in the module, searching for
  419. // extracts on a sequence of inserts. It further searches the sequence for an
  420. // insert with indices identical to the extract. If such an insert can be
  421. // found before hitting a conflicting insert, the extract's result id is
  422. // replaced with the id of the values from the insert.
  423. //
  424. // Besides removing extracts this pass enables subsequent dead code elimination
  425. // passes to delete the inserts. This pass performs best after access chains are
  426. // converted to inserts and extracts and local loads and stores are eliminated.
  427. Optimizer::PassToken CreateInsertExtractElimPass();
  428. // Creates a dead insert elimination pass.
  429. // This pass processes each entry point function in the module, searching for
  430. // unreferenced inserts into composite types. These are most often unused
  431. // stores to vector components. They are unused because they are never
  432. // referenced, or because there is another insert to the same component between
  433. // the insert and the reference. After removing the inserts, dead code
  434. // elimination is attempted on the inserted values.
  435. //
  436. // This pass performs best after access chains are converted to inserts and
  437. // extracts and local loads and stores are eliminated. While executing this
  438. // pass can be advantageous on its own, it is also advantageous to execute
  439. // this pass after CreateInsertExtractPass() as it will remove any unused
  440. // inserts created by that pass.
  441. Optimizer::PassToken CreateDeadInsertElimPass();
  442. // Create aggressive dead code elimination pass
  443. // This pass eliminates unused code from the module. In addition,
  444. // it detects and eliminates code which may have spurious uses but which do
  445. // not contribute to the output of the function. The most common cause of
  446. // such code sequences is summations in loops whose result is no longer used
  447. // due to dead code elimination. This optimization has additional compile
  448. // time cost over standard dead code elimination.
  449. //
  450. // This pass only processes entry point functions. It also only processes
  451. // shaders with relaxed logical addressing (see opt/instruction.h). It
  452. // currently will not process functions with function calls. Unreachable
  453. // functions are deleted.
  454. //
  455. // This pass will be made more effective by first running passes that remove
  456. // dead control flow and inlines function calls.
  457. //
  458. // This pass can be especially useful after running Local Access Chain
  459. // Conversion, which tends to cause cycles of dead code to be left after
  460. // Store/Load elimination passes are completed. These cycles cannot be
  461. // eliminated with standard dead code elimination.
  462. //
  463. // If |preserve_interface| is true, all non-io variables in the entry point
  464. // interface are considered live and are not eliminated. This mode is needed
  465. // by GPU-Assisted validation instrumentation, where a change in the interface
  466. // is not allowed.
  467. //
  468. // If |remove_outputs| is true, allow outputs to be removed from the interface.
  469. // This is only safe if the caller knows that there is no corresponding input
  470. // variable in the following shader. It is false by default.
  471. Optimizer::PassToken CreateAggressiveDCEPass();
  472. Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface);
  473. Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface,
  474. bool remove_outputs);
  475. // Creates a remove-unused-interface-variables pass.
  476. // Removes variables referenced on the |OpEntryPoint| instruction that are not
  477. // referenced in the entry point function or any function in its call tree. Note
  478. // that this could cause the shader interface to no longer match other shader
  479. // stages.
  480. Optimizer::PassToken CreateRemoveUnusedInterfaceVariablesPass();
  481. // Creates an empty pass.
  482. // This is deprecated and will be removed.
  483. // TODO(jaebaek): remove this pass after handling glslang's broken unit tests.
  484. // https://github.com/KhronosGroup/glslang/pull/2440
  485. Optimizer::PassToken CreatePropagateLineInfoPass();
  486. // Creates an empty pass.
  487. // This is deprecated and will be removed.
  488. // TODO(jaebaek): remove this pass after handling glslang's broken unit tests.
  489. // https://github.com/KhronosGroup/glslang/pull/2440
  490. Optimizer::PassToken CreateRedundantLineInfoElimPass();
  491. // Creates a compact ids pass.
  492. // The pass remaps result ids to a compact and gapless range starting from %1.
  493. Optimizer::PassToken CreateCompactIdsPass();
  494. // Creates a remove duplicate pass.
  495. // This pass removes various duplicates:
  496. // * duplicate capabilities;
  497. // * duplicate extended instruction imports;
  498. // * duplicate types;
  499. // * duplicate decorations.
  500. Optimizer::PassToken CreateRemoveDuplicatesPass();
  501. // Creates a CFG cleanup pass.
  502. // This pass removes cruft from the control flow graph of functions that are
  503. // reachable from entry points and exported functions. It currently includes the
  504. // following functionality:
  505. //
  506. // - Removal of unreachable basic blocks.
  507. Optimizer::PassToken CreateCFGCleanupPass();
  508. // Create dead variable elimination pass.
  509. // This pass will delete module scope variables, along with their decorations,
  510. // that are not referenced.
  511. Optimizer::PassToken CreateDeadVariableEliminationPass();
  512. // create merge return pass.
  513. // changes functions that have multiple return statements so they have a single
  514. // return statement.
  515. //
  516. // for structured control flow it is assumed that the only unreachable blocks in
  517. // the function are trivial merge and continue blocks.
  518. //
  519. // a trivial merge block contains the label and an opunreachable instructions,
  520. // nothing else. a trivial continue block contain a label and an opbranch to
  521. // the header, nothing else.
  522. //
  523. // these conditions are guaranteed to be met after running dead-branch
  524. // elimination.
  525. Optimizer::PassToken CreateMergeReturnPass();
  526. // Create value numbering pass.
  527. // This pass will look for instructions in the same basic block that compute the
  528. // same value, and remove the redundant ones.
  529. Optimizer::PassToken CreateLocalRedundancyEliminationPass();
  530. // Create LICM pass.
  531. // This pass will look for invariant instructions inside loops and hoist them to
  532. // the loops preheader.
  533. Optimizer::PassToken CreateLoopInvariantCodeMotionPass();
  534. // Creates a loop fission pass.
  535. // This pass will split all top level loops whose register pressure exceedes the
  536. // given |threshold|.
  537. Optimizer::PassToken CreateLoopFissionPass(size_t threshold);
  538. // Creates a loop fusion pass.
  539. // This pass will look for adjacent loops that are compatible and legal to be
  540. // fused. The fuse all such loops as long as the register usage for the fused
  541. // loop stays under the threshold defined by |max_registers_per_loop|.
  542. Optimizer::PassToken CreateLoopFusionPass(size_t max_registers_per_loop);
  543. // Creates a loop peeling pass.
  544. // This pass will look for conditions inside a loop that are true or false only
  545. // for the N first or last iteration. For loop with such condition, those N
  546. // iterations of the loop will be executed outside of the main loop.
  547. // To limit code size explosion, the loop peeling can only happen if the code
  548. // size growth for each loop is under |code_growth_threshold|.
  549. Optimizer::PassToken CreateLoopPeelingPass();
  550. // Creates a loop unswitch pass.
  551. // This pass will look for loop independent branch conditions and move the
  552. // condition out of the loop and version the loop based on the taken branch.
  553. // Works best after LICM and local multi store elimination pass.
  554. Optimizer::PassToken CreateLoopUnswitchPass();
  555. // Create global value numbering pass.
  556. // This pass will look for instructions where the same value is computed on all
  557. // paths leading to the instruction. Those instructions are deleted.
  558. Optimizer::PassToken CreateRedundancyEliminationPass();
  559. // Create scalar replacement pass.
  560. // This pass replaces composite function scope variables with variables for each
  561. // element if those elements are accessed individually. The parameter is a
  562. // limit on the number of members in the composite variable that the pass will
  563. // consider replacing.
  564. Optimizer::PassToken CreateScalarReplacementPass(uint32_t size_limit = 100);
  565. // Create a private to local pass.
  566. // This pass looks for variables declared in the private storage class that are
  567. // used in only one function. Those variables are moved to the function storage
  568. // class in the function that they are used.
  569. Optimizer::PassToken CreatePrivateToLocalPass();
  570. // Creates a conditional constant propagation (CCP) pass.
  571. // This pass implements the SSA-CCP algorithm in
  572. //
  573. // Constant propagation with conditional branches,
  574. // Wegman and Zadeck, ACM TOPLAS 13(2):181-210.
  575. //
  576. // Constant values in expressions and conditional jumps are folded and
  577. // simplified. This may reduce code size by removing never executed jump targets
  578. // and computations with constant operands.
  579. Optimizer::PassToken CreateCCPPass();
  580. // Creates a workaround driver bugs pass. This pass attempts to work around
  581. // a known driver bug (issue #1209) by identifying the bad code sequences and
  582. // rewriting them.
  583. //
  584. // Current workaround: Avoid OpUnreachable instructions in loops.
  585. Optimizer::PassToken CreateWorkaround1209Pass();
  586. // Creates a pass that converts if-then-else like assignments into OpSelect.
  587. Optimizer::PassToken CreateIfConversionPass();
  588. // Creates a pass that will replace instructions that are not valid for the
  589. // current shader stage by constants. Has no effect on non-shader modules.
  590. Optimizer::PassToken CreateReplaceInvalidOpcodePass();
  591. // Creates a pass that simplifies instructions using the instruction folder.
  592. Optimizer::PassToken CreateSimplificationPass();
  593. // Create loop unroller pass.
  594. // Creates a pass to unroll loops which have the "Unroll" loop control
  595. // mask set. The loops must meet a specific criteria in order to be unrolled
  596. // safely this criteria is checked before doing the unroll by the
  597. // LoopUtils::CanPerformUnroll method. Any loop that does not meet the criteria
  598. // won't be unrolled. See CanPerformUnroll LoopUtils.h for more information.
  599. Optimizer::PassToken CreateLoopUnrollPass(bool fully_unroll, int factor = 0);
  600. // Create the SSA rewrite pass.
  601. // This pass converts load/store operations on function local variables into
  602. // operations on SSA IDs. This allows SSA optimizers to act on these variables.
  603. // Only variables that are local to the function and of supported types are
  604. // processed (see IsSSATargetVar for details).
  605. Optimizer::PassToken CreateSSARewritePass();
  606. // Create pass to convert relaxed precision instructions to half precision.
  607. // This pass converts as many relaxed float32 arithmetic operations to half as
  608. // possible. It converts any float32 operands to half if needed. It converts
  609. // any resulting half precision values back to float32 as needed. No variables
  610. // are changed. No image operations are changed.
  611. //
  612. // Best if run after function scope store/load and composite operation
  613. // eliminations are run. Also best if followed by instruction simplification,
  614. // redundancy elimination and DCE.
  615. Optimizer::PassToken CreateConvertRelaxedToHalfPass();
  616. // Create relax float ops pass.
  617. // This pass decorates all float32 result instructions with RelaxedPrecision
  618. // if not already so decorated.
  619. Optimizer::PassToken CreateRelaxFloatOpsPass();
  620. // Create copy propagate arrays pass.
  621. // This pass looks to copy propagate memory references for arrays. It looks
  622. // for specific code patterns to recognize array copies.
  623. Optimizer::PassToken CreateCopyPropagateArraysPass();
  624. // Create a vector dce pass.
  625. // This pass looks for components of vectors that are unused, and removes them
  626. // from the vector. Note this would still leave around lots of dead code that
  627. // a pass of ADCE will be able to remove.
  628. Optimizer::PassToken CreateVectorDCEPass();
  629. // Create a pass to reduce the size of loads.
  630. // This pass looks for loads of structures where only a few of its members are
  631. // used. It replaces the loads feeding an OpExtract with an OpAccessChain and
  632. // a load of the specific elements. The parameter is a threshold to determine
  633. // whether we have to replace the load or not. If the ratio of the used
  634. // components of the load is less than the threshold, we replace the load.
  635. Optimizer::PassToken CreateReduceLoadSizePass(
  636. double load_replacement_threshold = 0.9);
  637. // Create a pass to combine chained access chains.
  638. // This pass looks for access chains fed by other access chains and combines
  639. // them into a single instruction where possible.
  640. Optimizer::PassToken CreateCombineAccessChainsPass();
  641. // Create a pass to instrument bindless descriptor checking
  642. // This pass instruments all bindless references to check that descriptor
  643. // array indices are inbounds, and if the descriptor indexing extension is
  644. // enabled, that the descriptor has been initialized. If the reference is
  645. // invalid, a record is written to the debug output buffer (if space allows)
  646. // and a null value is returned. This pass is designed to support bindless
  647. // validation in the Vulkan validation layers.
  648. //
  649. // TODO(greg-lunarg): Add support for buffer references. Currently only does
  650. // checking for image references.
  651. //
  652. // Dead code elimination should be run after this pass as the original,
  653. // potentially invalid code is not removed and could cause undefined behavior,
  654. // including crashes. It may also be beneficial to run Simplification
  655. // (ie Constant Propagation), DeadBranchElim and BlockMerge after this pass to
  656. // optimize instrument code involving the testing of compile-time constants.
  657. // It is also generally recommended that this pass (and all
  658. // instrumentation passes) be run after any legalization and optimization
  659. // passes. This will give better analysis for the instrumentation and avoid
  660. // potentially de-optimizing the instrument code, for example, inlining
  661. // the debug record output function throughout the module.
  662. //
  663. // The instrumentation will read and write buffers in debug
  664. // descriptor set |desc_set|. It will write |shader_id| in each output record
  665. // to identify the shader module which generated the record.
  666. // |desc_length_enable| controls instrumentation of runtime descriptor array
  667. // references, |desc_init_enable| controls instrumentation of descriptor
  668. // initialization checking, and |buff_oob_enable| controls instrumentation
  669. // of storage and uniform buffer bounds checking, all of which require input
  670. // buffer support. |texbuff_oob_enable| controls instrumentation of texel
  671. // buffers, which does not require input buffer support.
  672. Optimizer::PassToken CreateInstBindlessCheckPass(
  673. uint32_t desc_set, uint32_t shader_id, bool desc_length_enable = false,
  674. bool desc_init_enable = false, bool buff_oob_enable = false,
  675. bool texbuff_oob_enable = false);
  676. // Create a pass to instrument physical buffer address checking
  677. // This pass instruments all physical buffer address references to check that
  678. // all referenced bytes fall in a valid buffer. If the reference is
  679. // invalid, a record is written to the debug output buffer (if space allows)
  680. // and a null value is returned. This pass is designed to support buffer
  681. // address validation in the Vulkan validation layers.
  682. //
  683. // Dead code elimination should be run after this pass as the original,
  684. // potentially invalid code is not removed and could cause undefined behavior,
  685. // including crashes. Instruction simplification would likely also be
  686. // beneficial. It is also generally recommended that this pass (and all
  687. // instrumentation passes) be run after any legalization and optimization
  688. // passes. This will give better analysis for the instrumentation and avoid
  689. // potentially de-optimizing the instrument code, for example, inlining
  690. // the debug record output function throughout the module.
  691. //
  692. // The instrumentation will read and write buffers in debug
  693. // descriptor set |desc_set|. It will write |shader_id| in each output record
  694. // to identify the shader module which generated the record.
  695. Optimizer::PassToken CreateInstBuffAddrCheckPass(uint32_t desc_set,
  696. uint32_t shader_id);
  697. // Create a pass to instrument OpDebugPrintf instructions.
  698. // This pass replaces all OpDebugPrintf instructions with instructions to write
  699. // a record containing the string id and the all specified values into a special
  700. // printf output buffer (if space allows). This pass is designed to support
  701. // the printf validation in the Vulkan validation layers.
  702. //
  703. // The instrumentation will write buffers in debug descriptor set |desc_set|.
  704. // It will write |shader_id| in each output record to identify the shader
  705. // module which generated the record.
  706. Optimizer::PassToken CreateInstDebugPrintfPass(uint32_t desc_set,
  707. uint32_t shader_id);
  708. // Create a pass to upgrade to the VulkanKHR memory model.
  709. // This pass upgrades the Logical GLSL450 memory model to Logical VulkanKHR.
  710. // Additionally, it modifies memory, image, atomic and barrier operations to
  711. // conform to that model's requirements.
  712. Optimizer::PassToken CreateUpgradeMemoryModelPass();
  713. // Create a pass to do code sinking. Code sinking is a transformation
  714. // where an instruction is moved into a more deeply nested construct.
  715. Optimizer::PassToken CreateCodeSinkingPass();
  716. // Create a pass to fix incorrect storage classes. In order to make code
  717. // generation simpler, DXC may generate code where the storage classes do not
  718. // match up correctly. This pass will fix the errors that it can.
  719. Optimizer::PassToken CreateFixStorageClassPass();
  720. // Creates a graphics robust access pass.
  721. //
  722. // This pass injects code to clamp indexed accesses to buffers and internal
  723. // arrays, providing guarantees satisfying Vulkan's robustBufferAccess rules.
  724. //
  725. // TODO(dneto): Clamps coordinates and sample index for pointer calculations
  726. // into storage images (OpImageTexelPointer). For an cube array image, it
  727. // assumes the maximum layer count times 6 is at most 0xffffffff.
  728. //
  729. // NOTE: This pass will fail with a message if:
  730. // - The module is not a Shader module.
  731. // - The module declares VariablePointers, VariablePointersStorageBuffer, or
  732. // RuntimeDescriptorArrayEXT capabilities.
  733. // - The module uses an addressing model other than Logical
  734. // - Access chain indices are wider than 64 bits.
  735. // - Access chain index for a struct is not an OpConstant integer or is out
  736. // of range. (The module is already invalid if that is the case.)
  737. // - TODO(dneto): The OpImageTexelPointer coordinate component is not 32-bits
  738. // wide.
  739. //
  740. // NOTE: Access chain indices are always treated as signed integers. So
  741. // if an array has a fixed size of more than 2^31 elements, then elements
  742. // from 2^31 and above are never accessible with a 32-bit index,
  743. // signed or unsigned. For this case, this pass will clamp the index
  744. // between 0 and at 2^31-1, inclusive.
  745. // Similarly, if an array has more then 2^15 element and is accessed with
  746. // a 16-bit index, then elements from 2^15 and above are not accessible.
  747. // In this case, the pass will clamp the index between 0 and 2^15-1
  748. // inclusive.
  749. Optimizer::PassToken CreateGraphicsRobustAccessPass();
  750. // Create a pass to spread Volatile semantics to variables with SMIDNV,
  751. // WarpIDNV, SubgroupSize, SubgroupLocalInvocationId, SubgroupEqMask,
  752. // SubgroupGeMask, SubgroupGtMask, SubgroupLeMask, or SubgroupLtMask BuiltIn
  753. // decorations or OpLoad for them when the shader model is the ray generation,
  754. // closest hit, miss, intersection, or callable. This pass can be used for
  755. // VUID-StandaloneSpirv-VulkanMemoryModel-04678 and
  756. // VUID-StandaloneSpirv-VulkanMemoryModel-04679 (See "Standalone SPIR-V
  757. // Validation" section of Vulkan spec "Appendix A: Vulkan Environment for
  758. // SPIR-V"). When the SPIR-V version is 1.6 or above, the pass also spreads
  759. // the Volatile semantics to a variable with HelperInvocation BuiltIn decoration
  760. // in the fragement shader.
  761. Optimizer::PassToken CreateSpreadVolatileSemanticsPass();
  762. // Create a pass to replace a descriptor access using variable index.
  763. // This pass replaces every access using a variable index to array variable
  764. // |desc| that has a DescriptorSet and Binding decorations with a constant
  765. // element of the array. In order to replace the access using a variable index
  766. // with the constant element, it uses a switch statement.
  767. Optimizer::PassToken CreateReplaceDescArrayAccessUsingVarIndexPass();
  768. // Create descriptor scalar replacement pass.
  769. // This pass replaces every array variable |desc| that has a DescriptorSet and
  770. // Binding decorations with a new variable for each element of the array.
  771. // Suppose |desc| was bound at binding |b|. Then the variable corresponding to
  772. // |desc[i]| will have binding |b+i|. The descriptor set will be the same. It
  773. // is assumed that no other variable already has a binding that will used by one
  774. // of the new variables. If not, the pass will generate invalid Spir-V. All
  775. // accesses to |desc| must be OpAccessChain instructions with a literal index
  776. // for the first index.
  777. Optimizer::PassToken CreateDescriptorScalarReplacementPass();
  778. // Create a pass to replace each OpKill instruction with a function call to a
  779. // function that has a single OpKill. Also replace each OpTerminateInvocation
  780. // instruction with a function call to a function that has a single
  781. // OpTerminateInvocation. This allows more code to be inlined.
  782. Optimizer::PassToken CreateWrapOpKillPass();
  783. // Replaces the extensions VK_AMD_shader_ballot,VK_AMD_gcn_shader, and
  784. // VK_AMD_shader_trinary_minmax with equivalent code using core instructions and
  785. // capabilities.
  786. Optimizer::PassToken CreateAmdExtToKhrPass();
  787. // Replaces the internal version of GLSLstd450 InterpolateAt* extended
  788. // instructions with the externally valid version. The internal version allows
  789. // an OpLoad of the interpolant for the first argument. This pass removes the
  790. // OpLoad and replaces it with its pointer. glslang and possibly other
  791. // frontends will create the internal version for HLSL. This pass will be part
  792. // of HLSL legalization and should be called after interpolants have been
  793. // propagated into their final positions.
  794. Optimizer::PassToken CreateInterpolateFixupPass();
  795. // Removes unused components from composite input variables. Current
  796. // implementation just removes trailing unused components from input arrays
  797. // and structs. The pass performs best after maximizing dead code removal.
  798. // A subsequent dead code elimination pass would be beneficial in removing
  799. // newly unused component types.
  800. //
  801. // WARNING: This pass can only be safely applied standalone to vertex shaders
  802. // as it can otherwise cause interface incompatibilities with the preceding
  803. // shader in the pipeline. If applied to non-vertex shaders, the user should
  804. // follow by applying EliminateDeadOutputStores and
  805. // EliminateDeadOutputComponents to the preceding shader.
  806. Optimizer::PassToken CreateEliminateDeadInputComponentsPass();
  807. // Removes unused components from composite output variables. Current
  808. // implementation just removes trailing unused components from output arrays
  809. // and structs. The pass performs best after eliminating dead output stores.
  810. // A subsequent dead code elimination pass would be beneficial in removing
  811. // newly unused component types. Currently only supports vertex and fragment
  812. // shaders.
  813. //
  814. // WARNING: This pass cannot be safely applied standalone as it can cause
  815. // interface incompatibility with the following shader in the pipeline. The
  816. // user should first apply EliminateDeadInputComponents to the following
  817. // shader, then apply EliminateDeadOutputStores to this shader.
  818. Optimizer::PassToken CreateEliminateDeadOutputComponentsPass();
  819. // Removes unused components from composite input variables. This safe
  820. // version will not cause interface incompatibilities since it only changes
  821. // vertex shaders. The current implementation just removes trailing unused
  822. // components from input structs and input arrays. The pass performs best
  823. // after maximizing dead code removal. A subsequent dead code elimination
  824. // pass would be beneficial in removing newly unused component types.
  825. Optimizer::PassToken CreateEliminateDeadInputComponentsSafePass();
  826. // Analyzes shader and populates |live_locs| and |live_builtins|. Best results
  827. // will be obtained if shader has all dead code eliminated first. |live_locs|
  828. // and |live_builtins| are subsequently used when calling
  829. // CreateEliminateDeadOutputStoresPass on the preceding shader. Currently only
  830. // supports tesc, tese, geom, and frag shaders.
  831. Optimizer::PassToken CreateAnalyzeLiveInputPass(
  832. std::unordered_set<uint32_t>* live_locs,
  833. std::unordered_set<uint32_t>* live_builtins);
  834. // Removes stores to output locations not listed in |live_locs| or
  835. // |live_builtins|. Best results are obtained if constant propagation is
  836. // performed first. A subsequent call to ADCE will eliminate any dead code
  837. // created by the removal of the stores. A subsequent call to
  838. // CreateEliminateDeadOutputComponentsPass will eliminate any dead output
  839. // components created by the elimination of the stores. Currently only supports
  840. // vert, tesc, tese, and geom shaders.
  841. Optimizer::PassToken CreateEliminateDeadOutputStoresPass(
  842. std::unordered_set<uint32_t>* live_locs,
  843. std::unordered_set<uint32_t>* live_builtins);
  844. // Creates a convert-to-sampled-image pass to convert images and/or
  845. // samplers with given pairs of descriptor set and binding to sampled image.
  846. // If a pair of an image and a sampler have the same pair of descriptor set and
  847. // binding that is one of the given pairs, they will be converted to a sampled
  848. // image. In addition, if only an image has the descriptor set and binding that
  849. // is one of the given pairs, it will be converted to a sampled image as well.
  850. Optimizer::PassToken CreateConvertToSampledImagePass(
  851. const std::vector<opt::DescriptorSetAndBinding>&
  852. descriptor_set_binding_pairs);
  853. // Create an interface-variable-scalar-replacement pass that replaces array or
  854. // matrix interface variables with a series of scalar or vector interface
  855. // variables. For example, it replaces `float3 foo[2]` with `float3 foo0, foo1`.
  856. Optimizer::PassToken CreateInterfaceVariableScalarReplacementPass();
  857. // Creates a remove-dont-inline pass to remove the |DontInline| function control
  858. // from every function in the module. This is useful if you want the inliner to
  859. // inline these functions some reason.
  860. Optimizer::PassToken CreateRemoveDontInlinePass();
  861. // Create a fix-func-call-param pass to fix non memory argument for the function
  862. // call, as spirv-validation requires function parameters to be an memory
  863. // object, currently the pass would remove accesschain pointer argument passed
  864. // to the function
  865. Optimizer::PassToken CreateFixFuncCallArgumentsPass();
  866. } // namespace spvtools
  867. #endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_