Граф коммитов

30 Коммитов

Автор SHA1 Сообщение Дата
Alastair Donaldson 3118276370
spirv-reduce: Remove unused struct members (#3329)
Adds a reduction pass to remove unused members from structs.
2020-05-14 15:36:38 +01:00
Alastair Donaldson 2992386ebe
spirv-reduce: Remove unused uniforms and similar (#3321)
Extends the pass for removing unused instructions so that it can
remove global declarations (such as types and variables) that are only
used by decorations with which they are intimately connected, such as
descriptor set and binding decorations.
2020-05-13 22:08:40 +01:00
Jaebaek Seo dd37d73c5e Handle conflict between debug info and existing validation rule (#3104)
* Allow OpExtInst for DebugInfo between secion 9 and 10

Fixes #3086

* Handle spirv-opt errors on DebugInfo Ext

* Add IR Loader test

* Fix ir loader bug

* Handle DebugFunction/DebugTypeMember forward reference

* Add test cases (forward reference to function)

* Support old DebugInfo extension

* Validate local debug info out of function
2020-01-23 17:04:30 -05:00
Aaron Barany 9c0ae6bb8e Improved CMake install step. (#2963)
Added exports for libraries. External libraries that themselves use
libraries require all dependencies have exports, so not having exports can
cause major problems when used within other projects.

Install paths for exports are now placed in the proper directories expected
by Windows and *nix systems. Config files are generated as well, which
should work with CMake's find_package() function once installed.
2019-10-17 11:36:55 -04:00
Paul Thomson feb1549213
reduce: add large tests and fix (#2947)
* Add larger reducer tests. 
* Fix conditional_branch_to_simple_conditional_branch_opportunity pass.
2019-10-10 17:12:42 +01:00
Paul Thomson 2f6a87f610
reduce: improve remove unref instr pass (#2945)
* Remove Impl struct in Reducer; we can re-add it later (in a cleaner fashion) if we need to. 
* Add cleanup passes in Reducer; needed so that removal of constants can be disabled during the main passes, and then enabled during cleanup passes, otherwise some main passes can perform worse due to lack of available constants. 
* Delete passes: remove op name, remove relaxed precision. And delete associated tests. 
* Add more tests for remove unreferenced instructions. 
* Always return and write the output file, even if there was a reduction failure. 
* Only exit with 0 if the reduction completed or we hit the reduction step limit.
2019-10-08 13:02:34 +01:00
rumblehhh 1dfb5fc12e Export SPIRV-Tools targets on installation (#2785)
This allows the targets to be used in other cmake projects. See the following for more details:
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
https://foonathan.net/blog/2016/07/07/cmake-dependency-handling.html
2019-09-04 12:45:26 -04:00
Alastair Donaldson 8336d1925f
Extend reducer to remove relaxed precision decorations (#2797)
Adds a reduction pass that removes OpDecorate and OpMemberDecorate
instructions that annotate instructions and members with
RelaxedPrecision.  As well as being useful in its own right, removing
such references allows other passes to remove further instructions.
2019-08-22 23:33:09 +01:00
Ryan Harrison 048dcd38ce
Implement WebGPU->Vulkan initializer conversion for 'Function' variables (#2513)
WebGPU requires certain variables to be initialized, whereas there are
known issues with using initializers in Vulkan. This PR is the first
of three implementing a pass to decompose initialized variables into
a variable declaration followed by a store. This has been broken up
into multiple PRs, because there 3 distinct cases that need to be
handled, which require separate implementations.

This first PR implements the basic infrastructure that is needed, and
handling of Function storage class variables. Private and Output will
be handled in future PRs.

This is part of resolving #2388
2019-04-16 14:31:36 -04:00
Paul Thomson 3335c61147
reduce: Add two branch reduction passes (#2507)
* Fix #2320. `conditional_branch_to_simple_conditional_branch` reduction pass changes conditional branches so both targets point to the same block id (creating a "simple" conditional branch).
* Fix #2501. `simple_conditional_branch_to_branch` reduction pass changes "simple" conditional branches to branches. 
* Fix #2503. `conditional_branch_to_simple_conditional_branch` proper handling of back-edges.
2019-04-15 19:54:36 +01:00
Paul Thomson d90aae9a5a
reduce: miscellaneous fixes (#2494)
* Fix .gitignore 
* Add missing reduction pass: RemoveBlockReductionOpportunityFinder 
* Add DumpShader functions in test_reduce for debugging 
* Add DumpShader functions in spirv-reduce for debugging 
* Fix include style 
* Don't use "using namespace"
2019-04-08 19:37:17 +01:00
Paul Thomson e2ddb9371e
reduce: add remove_selection_reduction_opportunity (#2485)
Fix #2484
2019-04-02 16:50:15 +01:00
Paul Thomson fcb8453104
reduce: fix loop to selection pass for loops with combined header/continue block (#2480)
* Fix #2478. The fix is to just not try to simplify such loops. 
* Also added `BasicBlock::MergeBlockId()` and `BasicBlock::ContinueBlockId()`. 
* Some minor changes to `structured_loop_to_selection_reduction_opportunity.cpp`. 
* Added test.
2019-03-29 11:29:24 +00:00
Paul Thomson fb0753640a
reduce: fix loop to selection dominance query (#2477)
Fix #2457
2019-03-26 16:37:08 +00:00
Paul Thomson 7d1b176c1d
Improve reducer algorithm and other changes (#2472)
Fix #2475. Fix #2476. 

* Improve reducer algorithm: shrink granularity, remove an early return, no lazy initialization, notify pass if binary is interesting, add comments.
* Add fail-on-validation-error option to fail a reduction if an invalid state is reached; useful for tests.
* Set fail-on-validation-error in tests.
* Improve some documentation comments.
* Add Reducer::AddDefaultReductionPasses so tests (and other library consumers) can add the default reduction passes.
* Add CLIMessageConsumer in test_reduce so we can see messages for tricky tests.
* Remove test RemoveUnreferencedInstructionReductionPassTest_ApplyReduction because it was indirectly testing the reduction algorithm, not the RemoveUnreferencedInstruction pass.
* Tweak tests where needed.
2019-03-26 13:22:31 +00:00
Paul Thomson 2d52cbee49
Add some val options to reduce (#2401)
Fix #2396 

* Check that initial state is valid. Add kInitialStateInvalid. 
* Fix RemoveOpnameAndRemoveUnreferenced test; turns out the original shader is invalid, but we never notice because we don't check this and the reduced shader is valid; fix original shader. Assert reduction status is kComplete.
* Always check return value from `Reducer::Run`.
* Change Reducer::Run to *not* immediately copy the input binary.
2019-03-21 14:28:06 +00:00
Paul Thomson 1f60f98964
reduce: remove unreferenced blocks pass (#2398) 2019-03-21 13:32:21 +00:00
Paul Thomson 40a7940e05 Fix merge blocks opportunity to check if still enabled (#2370)
Fix MergeBlocksReductionOpportunity so it checks whether it is still enabled

Fixes #2369. Added tests.
2019-02-11 16:26:37 -05:00
Alastair Donaldson 34c5ac614c
Fixes #2358. Added to the reducer the ability to remove a function t… (#2361)
* Fixes #2358.  Added to the reducer the ability to remove a function that is not directly called.  Factored out some code from the optimizer to help with this.
2019-02-08 16:20:29 +00:00
Alastair Donaldson 37861ac106
Merge blocks in reducer (#2353)
Fixes #2120 

Enhanced the reducer so that it can merge blocks together, leveraging the functionality extracted from the block_merge pass in the optimizer.
2019-02-01 14:56:54 +00:00
Alastair Donaldson 98c67d3850 Fixed names in ifdefs and GetName functions that had been forgotten in a previous refactoring. Also shortened names of test files as those files test both the new 'finder' classes introduced in the refactoring, as well as the 'reduction pass' class; the shorter names capture both. (#2336) 2019-01-25 11:37:03 -05:00
Alastair Donaldson 86d0d9be25 Refactored reducer so that the 'finding' functionality of a reduction pass are separated from the generic functionality for tracking progress of a pass. With this change, we now have a ReductionOpportunityFinder abstract class, with many subclasses for each type of reduction, and just one ReductionPass class, which has an associated finder. (#2321)
Sounds good.
2019-01-23 17:07:58 -05:00
Paul Thomson 71aa48f91d spirv-reduce: add OperandToUndefReductionPass (#2200)
* Add OperandToUndefReductionPass.

Fixes #2115.

Also added some tests that are similar to those in OperandToConstantReductionPassTest.

In addition, refactor FindOrCreateGlobalUndef into reduction_util.cpp. Fixes #2184.

Removed many documentation comments that were identical or very similar to the overridden function's documentation comment.
2018-12-19 13:25:56 +00:00
Alastair Donaldson 1cba9942bd Validate during reduction (#2194)
* Run validator during reduction.

* Added functionality to validate modules after each reduction step, and some tests to check this is working.  Also fixed an issue where reduction passes were not guaranteed to be executed at their minimum granularities.
2018-12-12 09:06:13 -05:00
Hugues Evrard 4aeadc0199 Add RemoveOpNameInstruction reduction pass (#2187)
Add a spirv-reduce pass which removes OpName and OpMemberName instructions.

This is useful to enable other reduction passes, e.g. RemoveUnreferencedInstruction may not be able to remove an instruction creating an id whose only usage is an OpName for this id.
2018-12-10 11:53:31 -05:00
Alastair Donaldson 6679d5df89 Replace loop with selection (#2164)
Add a pass for spirv-reduce that will turn a loop into a selection.
2018-12-07 12:44:46 -05:00
Alastair Donaldson 3b13040cf9 New spirv-reduce reduction pass: operand to dominating id. (#2099)
* Added a reduction pass to replace ids with ids of the same type that dominate them.
* Introduce helper method for querying whether an operand type is an input id.
2018-11-26 17:06:21 -05:00
Minmin Gong 095cc6722f Fix the missing pch files in spirv-reduce (#2097) 2018-11-22 18:00:08 -05:00
dan sinclair 78c951b3f6
Add newline at end of file (#2098) 2018-11-22 14:35:40 -05:00
Alastair Donaldson f3acb955c2 Initial commit for spirv-reduce. (#2056)
Creates a new tool that can be used to reduce failing testcases, similar to creduce.
2018-11-21 14:03:09 -05:00