Commit Graph

2421 Commits

Author SHA1 Message Date
greg-lunarg
e7afeb060e Use dummy switch instead of dummy loop in MergeReturn pass. (#3151)
Fixes #3127
2020-01-24 12:20:14 -05:00
alan-baker
6729c4a7ce
Fix structured exit validation (#3141)
Fixes #3139

* If the header of the construct is also a merge block, jump to the
associated header instead of the immediate dominator
  * prevents spurious failures from unrelated constructs
* new tests
2020-01-23 18:04:21 -05:00
David Neto
bb236c326d
Add spvParseVulkanEnv (#3142)
This new API lets clients request a minimal spv_target_env value
that supports a given Vulkan and SPIR-V version, by a generic
numbering scheme (as already defined by Vulkan and SPIR-V specs).

This breaks a formal source dependency from Glslang to SPIRV-Tools.
When a new API is rolled out, such as Vulkan 1.2, Glslang currently
needs to reference a specific SPIRV-Tools enum by name.
2020-01-23 17:20:32 -05: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
Shahbaz Youssefi
b97057e7f7 Use spirv-headers' BUILD.gn (#3148)
* Roll external/spirv-headers/ af64a9e82..dc77030ac (4 commits)

$ git log af64a9e82..dc77030ac --date=short --no-merges --format='%ad %ae %s'
2020-01-20 dneto Fix the license to match LICENSE
2020-01-20 syoussefi Add BUILD.gn
2019-11-20 Tobias.Hector Off-by-one errors
2019-11-20 Tobias.Hector Reserve a new block of 64 opcodes

Created with:
  roll-dep external/spirv-headers

* Use BUILD.gn from spirv-headers
2020-01-23 13:40:12 -05:00
Shahbaz Youssefi
6a1a1b3269 Roll external/spirv-headers/ af64a9e82..dc77030ac (4 commits) (#3147)
$ git log af64a9e82..dc77030ac --date=short --no-merges --format='%ad %ae %s'
2020-01-20 dneto Fix the license to match LICENSE
2020-01-20 syoussefi Add BUILD.gn
2019-11-20 Tobias.Hector Off-by-one errors
2019-11-20 Tobias.Hector Reserve a new block of 64 opcodes

Created with:
  roll-dep external/spirv-headers
2020-01-23 12:07:30 -05:00
Alastair Donaldson
ab7ac60f14
spirv-fuzz: Refactoring and type-related fixes (#3144)
This change refactors some code for walking access chain indexes to
make it mirror the structure of other code (to improve readability in
the first instance and potentially enable a future refactoring to
extract common code), and fixes a problem related to module donation
and function types.
2020-01-21 05:59:57 -08:00
Alan Baker
323a81fc5e Validate Vulkan 1.2 capabilities 2020-01-14 20:06:19 -05:00
David Neto
d46a1b0487 Add basic support for Vulkan 1.2: SPV_ENV_VULKAN_1_2 2020-01-14 20:06:19 -05:00
Jaebaek Seo
f8d7df760c
Fix OpLine bug of merge-blocks pass (#3130)
As explained in #3118, spirv-opt merge-blocks pass causes a
spirv-val error when an OpBranch has an OpLine in front of it.

OpLoopMerge
OpBranch ; Will be killed by merge-blocks pass
OpLabel  ; Will be killed by merge-blocks pass
OpLine   ; will be placed between OpLoopMerge and OpBranch - error!
OpBranch

To fix this issue, this commit moves line info of OpBranch to
OpLoopMerge.

Fixes #3118
2020-01-14 14:35:21 -05:00
Alastair Donaldson
8013d477ae
spirv-fuzz: add dead blocks (#3135)
This adds a new kind of fact to the fact manager that knows whether a
block is dead - i.e. guaranteed to be statically unreachable - and a
new transformation for adding a selection construct to a CFG that
conditionally branches to a fresh, dead block, such that the branch
will never be dynamically taken. Transformations that may create new
blocks ('split block' and 'outline function') are updated to propagate
dead block facts to newly-created blocks where appropriate. A fuzzer
pass randomly adds dead blocks to the module.

Future transformations will be able to exploit the fact that such
blocks are known to be dead.
2020-01-13 22:04:01 +00:00
aqnuep
18b3b94567 Remove names and decorations of imported symbols (#3081)
* Remove names and decorations of imported symbols

* Added test case
2020-01-10 09:54:35 -05:00
David Neto
fb2e819819
Fix GN build for OpenCL.DebugInfo.100 update (#3134)
The utils/generate_grammar_tables.py vendor-operand-kind-prefix
can now take a value of "...nil..." to signify the empty string.
That's needed because GN doesn't quote empty string arguments
correctly down into its action commands.

Fixes #3120
2020-01-08 17:27:38 -05:00
Ben Clayton
c86dc0bcdb Fix bad parameter names in error message (#3129) 2020-01-08 09:54:45 -05:00
alan-baker
899735f455
Revert PR #3093 (#3131)
* Change is now under active discussion in Khronos
2020-01-07 13:55:46 -05:00
alan-baker
a466b99dbb
Disallow forward references in arrays (#3093)
Fixes https://crbug.com/1031049

* Disallow forward references in arrays
* Add a test
2020-01-07 09:38:17 -05:00
Alastair Donaldson
31acc78821
spirv-fuzz: Add fuzzer pass to perform module donation (#3117)
This change adds a fuzzer pass that allows code from other SPIR-V
modules to be donated into the module under transformation.  It also
changes the command-line options of the tools so that, in fuzzing
mode, a file must be specified that contains the names of available
donor modules.
2020-01-07 08:39:55 +00:00
David Neto
c8bf14393c
GetOperandConstants operand can be const (#3126) 2020-01-06 11:14:04 -05:00
David Neto
8aa423930d
Avoid pessimizing std::move (#3124)
Should fix a warning
2019-12-27 12:05:58 -05:00
Kai Burjack
fad92f1e7e Fix typo in validation message (#3122) 2019-12-27 10:47:16 -05:00
greg-lunarg
578c5ac133 Change default version for CreatInstBindlessCheckPass to 2 (#3119) 2019-12-27 10:46:43 -05:00
greg-lunarg
9215c1b7df Fix convert-relax-to-half invalid code (#3099) (#3106) 2019-12-20 21:08:12 -05:00
David Neto
64f36ea529
Support OpenCL.DebugInfo.100 extended instruction set (#3080)
* Clone opencl.debuginfo.100 grammar from debuginfo grammar

Update version number to 200 revision 2

* Apply content from OpenCL.DebugInfo.100 extension text

* Rename grammar file

* Support OpenCL.DebugInfo.100 extended instructions

Add support for prefixing operand type names, to disambiguate
them between different instruction sets.

* Add tests for OpenCL.DebugInfo.100

* Support lookup of OpenCL.DebugInfo.100 extinst

* Add tests for enum values

* Recognize 2017-2019 as copyright date range

* Android.mk: support OpenCL.DebugInfo.100 extended instruction set

Also, stop generating core instruction tables for non-unified1 versions
of the grammar.

* Imported entity operand type is concrete

* Bazel: Suppoort OpenCL.DebugInfo.100

* BUILD.gn: Support OpenCL.DebugInfo.100
2019-12-19 17:16:26 -05:00
Alastair Donaldson
e01bc6d4e8
spirv-fuzz: Always add new globals to entry point interfaces (#3113)
In the context of SPIR-V 1.4 or higher, global variables cannot be
used by an instruction unless they are listed in the interface of all
entry points that might invoke the instruction.  This change
conservatively adds new global variables to the interfaces of all
entry points (if the SPIR-V version is 1.4 or higher).

Issue #3111 notes that a more rigorous approach to entry point
interfaces could be taken in spirv-fuzz, which would allow being less
conservative here.
2019-12-19 21:16:09 +00:00
Alastair Donaldson
dcb7169bbd
spirv-fuzz: Transformation to add a new function to a module (#3114)
This adds a large transformation that can add a new function to a
SPIR-V module.  This paves the way for donation of code from one
module to another.
2019-12-19 21:15:09 +00:00
Alastair Donaldson
2e41d5ece7
spirv-fuzz: Avoid passing access chains as parameters (#3112)
This change prevents the spirv-fuzz function outliner from outlining a
region that uses the result of an OpAccessChain not defined inside the
region.  Such accesses were turning into parameters to the outlined
function, and the result of an OpAccessChain cannot be passed as a
function parameter according to the SPIR-V specification.
2019-12-19 17:34:36 +00:00
David Neto
e70b009b0f
Add support for SPV_KHR_non_semantic_info (#3110)
Add support for SPV_KHR_non_semantic_info

This entails a couple of changes:

- Allowing unknown OpExtInstImport that begin with the prefix `NonSemantic.`
- Allowing OpExtInst that reference any of those sets to contain unknown
  ext inst instruction numbers, and assume the format is always a series of IDs
  as guaranteed by the extension.
- Allowing those OpExtInst to appear in the types/variables/constants section.
- Not stripping OpString in the --strip-debug pass, since it may be referenced
  by these non-semantic OpExtInsts.
- Stripping them instead in the --strip-reflect pass.

* Add adjacency validation of non-semantic OpExtInst

- We validate and test that OpExtInst cannot appear before or between
  OpPhi instructions, or before/between OpFunctionParameter
  instructions.

* Change non-semantic extinst type to single value

* Add helper function spvExtInstIsNonSemantic() which will check if the extinst
  set is non-semantic or not, either the unknown generic value or any future
  recognised non-semantic set.

* Add test of a complex non-semantic extinst

* Use DefUseManager in StripDebugInfoPass to strip some OpStrings

* Any OpString used by a non-semantic instruction cannot be stripped, all others
  can so we search for uses to see if each string can be removed.
* We only do this if the non-semantic debug info extension is enabled, otherwise
  all strings can be trivially removed.

* Silence -Winconsistent-missing-override in protobufs
2019-12-18 18:10:29 -05:00
Alastair Donaldson
38d7fbaad0
spirv-fuzz: Transformations to add types, constants and variables (#3101)
This change adds several transformations that allow types, constants,
undefined values and global variables to be added to a module.
2019-12-16 23:54:13 +00:00
greg-lunarg
fccbc00aca Make Instrumentation format version 2 the default (Step 1) (#3096)
* Make Instrumentation format version 2 the default (Step 1)

Add new interfaces without version number argument. Remove version 1
logic and tests. Version interfaces will be removed in step 2 after
layers have transitioned to new interface.

* Add error messages to InstrumentPass().
2019-12-16 14:18:47 -05:00
Alastair Donaldson
96354f5047
spirv-fuzz: Fuzzer pass to merge blocks (#3097)
This change adds a transformation and associated fuzzer pass for
merging adjacent blocks in a module, re-using block merging code from
the optimizer.
2019-12-12 15:27:40 +00:00
Steven Perron
5c019b5923 Start SPIRV-Tools v2020.1 2019-12-11 14:53:48 -05:00
Steven Perron
c413b982c3 Finalize SPIRV-Tools v2019.5 2019-12-11 14:52:28 -05:00
Steven Perron
2afbe90512 Update CHANGES 2019-12-11 13:04:18 -05:00
Steven Perron
00ca4e5bdf
Don't crash when folding construct of empty struct (#3092)
* Don't crash when folding construct of empty struct

An OpCompositeConstruct of an empty struct will be folded to a constant
under normal circumstances.  However, if the id limit has been reached
and the constant cannot be generated, then other folding rules will be
tried.

These rules do not handle the case of an empty struct.  We add allow it
to be handled.

Fixes http://crbug/1030194

* Changes based on the review.
2019-12-10 14:58:30 -05:00
Alastair Donaldson
0a2b38d082
spirv-fuzz: function outlining fuzzer pass (#3078)
A new transformation and associated fuzzer pass in spirv-fuzz that
selects single-entry single-exit control flow graph regions and for
each selected region outlines the region into a new function and
replaces the original region with a call to this function.
2019-12-10 14:47:42 +00:00
Alastair Donaldson
983b5b4fcc
spirv-fuzz: Use validator to check break/continue dominance conditions (#3089)
The passes that add dead breaks and continues suffer from the
challenge that a new control flow graph edge can change dominance
information, leading to the potenital for definitions to no longer
dominate their uses.  The attempt at guarding against this was known
to be incomplete.  This change calls on the SPIR-V validator to do the
necessary checking: in deciding whether adding such an edge would be
legitimate, we clone the module, add the edge, and use the validator
to check whether the transformed clone is valid.

This strategy is heavy-weight, and should be used sparingly, but seems
like a good option when the validity of transformations is intricate,
to avoid reimplementing swathes of validation logic in the fuzzer.

Fixes #2919.
2019-12-06 16:38:17 +00:00
David Neto
e82a428605
WebGPU: Array size at most max signed int + 1 (#3077)
This makes it easier to clamp indices for robust-buffer-access
behaviour.

See https://github.com/gpuweb/spirv-execution-env/issues/47
2019-12-03 11:55:28 -05:00
Sarah
0a5d99d02c Permit the debug instructions in WebGPU SPIR-V - remove from the optimizer (#3083)
continuing #3063
fixing #3052
2019-12-03 11:21:26 -05:00
David Neto
af7410597e graphics robust access: use signed clamp (#3073)
Access chain indices are always interpreted as signed integers.
So use signed clamp instead of unsigned clamp.  We must also
clamp to the max signed int for the index type.

Fixes #3072
2019-12-03 11:18:56 -05:00
Steven Perron
3ed4586044
Folding: perform add and sub on mismatched integer types (#3084)
Fixes #3040
2019-12-02 17:51:20 -05:00
Alastair Donaldson
47f3eb4264
spirv-fuzz: Fix invalid tests (#3079)
This change fixes some tests that turned out to be invalid; recent
improvements to the validator in #3068 exposed them as such.
2019-11-29 15:48:13 +00:00
alan-baker
b334829a91 Validate nested constructs (#3068)
* Validate that if a construct contains a header and it's merge is
reachable, the construct also contains the merge
* updated block merging to not merge into the continue
* update inlining to mark the original block of a single block loop as
the continue
* updated some tests
* remove dead code
* rename kBlockTypeHeader to kBlockTypeSelection for clarity
2019-11-27 16:45:57 -05:00
Alastair Donaldson
52e9cc9301
spirv-fuzz: Improve debugging facilities (#3074)
Adds an option to run the validator on the SPIR-V binary after each
fuzzer pass has been applied, to help identify when the fuzzer has
made the module invalid.  Also adds a helper method to allow dumping
of the sequence of transformations that have been applied to a JSON
file.
2019-11-27 18:05:56 +00:00
Steven Perron
54385458ca
Handle unreachable block when computing register pressure (#3070)
Fixes #3053
2019-11-27 09:45:17 -05:00
greg-lunarg
868ca3954c Improve RegisterSizePasses (#3059) 2019-11-27 09:41:50 -05:00
Ben Clayton
f31f26f739 utils/vscode: Add install.bat (#3071)
Installs the language server on windows.
Also add info to / correct `README.md`.
2019-11-26 16:23:57 -05:00
David Turner
03957e8a9f build: cmake: Add support for Fuchsia. (#3062)
This small patch adds support for the Fuchsia operating system
to the CMakeLists.txt file and source/print.cpp, the only source
file that contains platform-specific code.

This should not change the build for other platforms. To use it,
one needs a Fuchsia-specific CMake toolchain file, as in:

  mkdir build-fuchsia && cd build-fuchsia
  cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/fuchsia-toolchain.cmake
  make -j8
2019-11-26 16:22:59 -05:00
David Neto
a62012cede
Add test with explicit example of stripping reflection info (#3064)
* Add test with explicit example of stripping reflection info

* Improve the comment on StripReflectEnd2EndExample
2019-11-26 16:20:45 -05:00
Sarah
8312c523ee Permit the debug instructions in WebGPU SPIR-V (#3063)
Add tests
2019-11-26 14:04:57 -05:00
Matt Turner
85f3e93d13 Respect CMAKE_INSTALL_LIBDIR in installed CMake files (#3054)
Fixes #3017
2019-11-22 11:02:25 -05:00