Commit Graph

3176 Commits

Author SHA1 Message Date
Steven Perron
c3adcb034f
Adce refactor (NFC) (#4547)
* Have ADCE use cfg struct analysis (NFC)

ADCE has a lot of code and variables to keep track of
information that is easily obtains using the Struct
cfg analysis.  Most of this change is to refactor the
code to have small functions to get the information
from the struct cfg analysis.

A few other changes small refactoring changes are
done.

* Factor out work list initialization in ADCE (NFC)

We move the code that will initially populate the work list into its own
function.  We also simplify the code by making use of the struct cfg
analysis.  That way we can reduce the number of tables used to track
information as we traverse the CFG.
2021-09-24 13:21:45 -04:00
Greg Fischer
19dc86c48c
Handle NonSemantic.Shader Debug[No]Line (#4530)
Debug[No]Line are tracked and optimized using the same mechanism that tracks
and optimizes Op[No]Line.

Also:
    - Fix missing DebugScope at top of block.
    - Allow scalar replacement of access chain in DebugDeclare
2021-09-24 10:56:08 -04:00
Greg Fischer
f125452cf8
Fix inst_buff_addr_check to handle struct loads (#4489) 2021-09-23 12:59:38 -04:00
Jamie Madill
134d763f45
GN: Fix build for debuginfo codegen. (#4536)
Fixes #4535
2021-09-23 10:18:06 -04:00
alan-baker
1d48824bae
Update SPIRV-Headers (#4543)
* Remove tests that expected fast math mode operands to require a
  capability
2021-09-22 15:52:19 -04:00
alan-baker
a6c5056db2
Fix checks for offset in nested structs (#4531)
Fixes #4533
Fixes https://crbug.com/38771

* Fixes offset checks to look through arrays for nested structures
2021-09-21 11:15:16 -04:00
Alastair Donaldson
0f4508752f
Fix UBSan error in spirv-dis fuzzer (#4517)
Pending a more general solution for constructing a target environment
based on the bytes of a test input, this change avoids a UBSan error
caused by the existing approach.

Fixes https://crbug.com/38087
2021-09-21 15:07:30 +00:00
Steven Perron
59f51bb4f8
Fix extract with out-of-bounds index (#4529)
* Fix extract with out-of-bounds index

When folding a OpCompositeExtract that is fed by an
OpCompositeConstruct, we handle and out of bounds
index, but only in the case where the result of the
OpCompostiteConstruct is a struct.  This change
refactors that folding rule and then improves it to
handle an out-of-bounds access when the result of the
OpCompositeConstruct is a vector.
2021-09-20 13:02:47 -04:00
Greg Fischer
1454c95d1b
spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493)
Includes:
- Shift to use of spirv-header extinst.nonsemantic.shader grammar.json
- Remove extinst.nonsemantic.vulkan.debuginfo.100.grammar.json
- Enable all optimizations for Shader.DebugInfo

Also fixes scalar replacement to only insert DebugValue after all
OpVariables. This is not necessary for OpenCL.DebugInfo, but it is
for Shader.DebugInfo.

Likewise, fixes Private-to-Local to insert DebugDeclare after all
OpVariables.

Also fixes inlining to handle FunctionDefinition which can show up
after first block if early return processing happens.

Co-authored-by: baldurk <baldurk@baldurk.org>
2021-09-15 14:38:53 -04:00
Greg Fischer
4ac8e5e541
Add preserve_interface mode to aggressive_dead_code_elim (#4520)
This mode is needed by GPU-assisted validation instrumentation which
cannot change the shader entry point interface.
2021-09-15 14:38:34 -04:00
Alastair Donaldson
9e65f054d1
spirv-fuzz: Account for differing signedness in WrapVectorSynonym (#4414)
Makes the fuzzer pass and transformation that wraps vector synonyms
aware of the fact that integer operations can have arguments that
differ in signedness, and that the result type of such an operation
can have different sign from the argument types.

Fixes #4413.
2021-09-14 21:09:39 +00:00
Alastair Donaldson
36ff135341
spirv-opt: Avoid integer overflow during constant folding (#4511)
In SPIR-V, integers use 2s complement representation, so that signed
integer overflow and underflow is well defined. However, the constant
folder was causing overflow / underflow at the C++ level. This change
avoids such overflows by performing constant folding for IAdd, ISub and
IMul in the context of unsigned values, which works because signedness
is irrelevant according to the SPIR-V semantics for these instructions.

Fixes #4510.
2021-09-14 21:09:05 +00:00
Steven Perron
cb6c66917a
Roll external/googletest/ b7d472f12..955c7f837 (111 commits) (#4521)
b7d472f122...955c7f837e

$ git log b7d472f12..955c7f837 --date=short --no-merges --format='%ad %ae %s'
2021-08-20 absl-team Googletest export
2021-08-20 absl-team Googletest export
2021-08-19 invalid_ms_user Simplify example code with c++11
2021-08-12 absl-team Googletest export
2021-08-10 dmauro Googletest export
2021-08-09 dmauro Googletest export
2021-08-06 absl-team Internal change
2021-08-06 victordk13 Format test properties in xml printer
2021-08-05 iamberkeyavas typo fix gmock_cook_book
2021-08-03 absl-team Googletest export
2021-08-03 absl-team Googletest export
2021-08-02 absl-team Googletest export
2021-07-29 absl-team Googletest export
2021-07-29 otnaiud Typo, double "the"
2021-07-28 absl-team Internal change
2021-07-24 slowy.arfy fix: typo codespelling comment
2021-07-22 absl-team Googletest export
2021-07-21 absl-team Googletest export
2021-07-19 dmauro Googletest export
2021-07-14 761129+derekmauro Fix location of GOOGLETEST_CM0011 marker
2021-07-08 absl-team Googletest export
2021-07-08 absl-team Googletest export
2021-07-07 absl-team Googletest export
2021-07-02 absl-team Googletest export
2021-07-02 absl-team Googletest export
2021-07-07 manuel Link -lregex on QNX
2021-07-01 jeremy.nimmer Use GTEST_DONT_DEFINE_TEST_F to guard TEST_F
2021-06-29 absl-team Googletest export
2021-06-28 absl-team Googletest export
2021-06-28 absl-team Googletest export
2021-06-25 manuel Don't link pthread on QNX
2021-06-23 alex Fix EXPECT_DEATH() and ASSERT_DEATH() triggering -Wcovered-switch-default
2021-06-18 dmauro Googletest export
2021-06-03 pochkaenkov feat: make a matcher ElementsAreArray applicable for std ranges
2021-06-13 hyuk.myeong fix typos
2021-06-11 absl-team Googletest export
2021-06-10 absl-team Googletest export
2021-06-09 absl-team Googletest export
2021-06-09 dmauro Googletest export
2021-06-09 absl-team Googletest export
2021-06-09 absl-team Googletest export
2021-06-08 absl-team Googletest export
2021-06-04 absl-team Googletest export
2021-06-03 dmauro Googletest export
2021-05-28 florin.crisan #3420 Declare MarkAsIgnored as a DLL export
2021-05-28 florin.crisan #3420 Properly declare all overloads of testing::internal::PrintTo as DLL exports
2021-06-01 absl-team Googletest export
2021-06-01 absl-team Googletest export
2021-05-26 absl-team Googletest export
2021-05-25 absl-team Googletest export
(...)
2021-05-06 durandal Googletest export
2021-05-06 absl-team Googletest export
2021-05-03 absl-team Googletest export
2021-05-04 JC3 isalnum -> IsAlNum for correct handling of signed chars
2021-04-28 absl-team Googletest export
2021-04-27 absl-team Googletest export
2021-04-27 absl-team Googletest export
2021-04-27 absl-team Googletest export
2021-04-26 absl-team Googletest export
2021-04-26 absl-team Googletest export
2021-04-20 absl-team Googletest export
2021-04-19 absl-team Googletest export
2021-04-20 github Use URL instead of git-repo
2021-04-16 dmauro Googletest export
2021-04-14 absl-team Googletest export
2021-04-15 sebkraemer Apply missing suggestions from code review for GTEST_SKIP
2021-04-15 sebkraemer Apply suggestions from code review for GTEST_SKIP documentation
2020-12-15 sebkraemer Add subsection for GTEST_SKIP documentation
2021-04-15 jbampton chore: fix spelling
2021-04-14 github Mention to explicitely set the option to it's default.
2021-04-14 dmauro Googletest export
2021-04-14 github Changes like Requested.
2021-04-13 absl-team Googletest export
2021-04-09 absl-team Googletest export
2021-04-09 absl-team Googletest export
2021-04-09 absl-team Googletest export
2021-04-07 absl-team Googletest export
2021-04-07 absl-team Googletest export
2021-04-07 absl-team Googletest export
2021-04-06 absl-team Googletest export
2021-04-06 absl-team Googletest export
2021-04-05 absl-team Googletest export
2021-04-02 absl-team Googletest export
2021-03-25 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-23 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-20 absl-team Googletest export
2021-03-17 77407429+a-sully Update nicestrictnaggy gmock cook_book links
2021-03-14 zekewarren Use @platforms instead of @bazel_tools for windows constraint
2021-03-13 github Use Fetchcontent instead of ExternalProject
2020-12-30 mattias.ellert Port to GNU/Hurd
2020-12-24 georgthegreat Use proper feature test macro to test if library supports char8_t
2020-12-05 gautham.bangalore Fix typo
2020-12-04 zed.three CMake: Add namespaced ALIAS library

Created with:
  roll-dep external/googletest

Roll external/re2/ f8e389f3a..4244cd1cb (10 commits)

f8e389f3ac...4244cd1cb4

$ git log f8e389f3a..4244cd1cb --date=short --no-merges --format='%ad %ae %s'
2021-05-21 junyer Fix a bug in `Regexp::ToString()`.
2021-05-19 junyer Pass a path to `cmake` in order to avoid a warning.
2021-05-18 junyer Let CMake pass `-pthread` for us.
2021-05-18 junyer Remove unneeded policy setting.
2021-05-12 junyer (|a)* shouldn't match more text than (|a)+ does!
2021-05-10 junyer Update the R wrapper URL.
2021-05-03 junyer Add GCC 11 to the build matrix.
2021-04-29 junyer Nullify hooks::context when using RE2::Set.
2021-04-19 junyer Add Clang 12 to the build matrix.
2021-03-26 junyer Set "compatibility version" and "current version".

Created with:
  roll-dep external/re2

Roll external/spirv-headers/ e71feddb3..0d3c45cdb (6 commits)

e71feddb3f...0d3c45cdbb

$ git log e71feddb3..0d3c45cdb --date=short --no-merges --format='%ad %ae %s'
2021-08-27 greg Add nonsemantic.shader.debuginfo to Bazel
2021-07-28 marijn spirv.core.grammar: Remove duplicate OpArbitraryFloatPowNINTEL declaration
2021-05-20 kloczek Rename spirv-headers.pc to SPIRV-Headers.pc
2021-05-19 kloczek removed excesive space in configure_file() line
2021-05-19 kloczek Fixed substituted string with paths and version
2021-05-18 kloczek Add spirv-headers pkgconfig file

Created with:
  roll-dep external/spirv-headers
2021-09-14 12:20:20 -04:00
alan-baker
846b032b53
Fix infinite loop in validation (#4523)
* Fix infinite loop in validation

Fixes https://crbug.com/38548

* Fixes an issue in structured exit checking where an invalid merge
  could result in an infinite traversal

* formatting
2021-09-13 13:19:04 -04:00
Alastair Donaldson
bf463fe37c
Fix UBSan kokoro config (#4522)
A test has been removed which depends on casting to spv_target_env from a value
outside the range of that enum. This is an undefined behaviour, thus the
test is invalid.
2021-09-13 16:55:51 +01:00
alan-baker
5efeaad309
Fix bad order of checks in atomic validation (#4524)
Fixes https://crbug.com/38625

* Check the type is an integer before checking it's bit width
2021-09-13 11:16:37 -04:00
Steven Perron
8865b20295
Handle out-of-bounds accesses in VDCE (#4518)
It is possible that other optimization will propagate
a value into an OpCompositeExtract or OpVectorShuffle
instruction that is larger than the vector size.
Vector DCE has to be able to handle it.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/4513.
2021-09-13 09:57:44 -04:00
alan-baker
4f4f76037c
Change validator boolean tests to avoid asserts (#4503)
Fixes https://crbug.com/38102

* Check for valid instructions in many boolean tests instead of
  asserting in ValidationState_t
2021-09-12 19:14:33 -04:00
alan-baker
912460e46a
Fix infinite loop in GetBlockDepth (#4519)
Fixes #4515

* Sets block depth to 0 if it encountered multiple times and leaves
  finding the real error for other code
2021-09-11 03:27:14 +00:00
David Neto
013b1f3d6d
Fix validation message for cooperative matrix column type (#4502)
* Fix validation message for cooperative matrix column type

Fixes: #4497

* Add tests for cooperative matrix type validation
2021-09-10 11:28:00 -04:00
Alastair Donaldson
2a938fcfa3
Add UBSan kokoro configuration (#4512)
Adds a kokoro configuration for UBSan, to allow this sanitizer to be
used during continuous integration.
2021-09-10 12:53:09 +00:00
alan-baker
c16224c684
Add some missing switch validation (#4507)
Fixes #4506

* Add validation of selector and default operands
2021-09-08 10:09:01 +01:00
Alastair Donaldson
92868b8f3f
spirv-val: Fix ubsan error (#4505)
Fixes an issue where an arbitrary word was cast to SpvOp, leading to
undefined behaviour if the value of the word fell outside the range of
SpvOp values.

Fixes #4504.
2021-09-07 15:37:40 -04:00
gnl21
4db6b8dcc2
Remove environment features that are never used (#4491)
The validation state contained feature bits for scalar block layout and
workgroup memory scalar block layout which were never used (the
command-line option is used in every case).
2021-09-07 13:08:15 -04:00
David Neto
7e860e3831
fix parsing of bad binary exponents in hex floats (#4501)
- The binary exponent must have some decimal digits
- A + or - after the binary exponent digits should not be interpreted as
  part of the binary exponent.

Fixes: #4500
2021-09-03 12:27:12 -04:00
Alastair Donaldson
789de0dc4b
Adjust build for fuzzer targets to support OSS-Fuzz (#4498)
With OSS-Fuzz, the build system should not directly set options such as
-fsanitize=fuzzer. Instead, these are set by OSS-Fuzz, and
linker options are provided via the LIB_FUZZER_OPTIONS environment
variable. This change allows the fuzzers to be build stand-alone,
outside of OSS-Fuzz, in the way that was already supported, as well as
inside OSS-Fuzz, when the LIB_FUZZER_OPTIONS environment variable is
set.
2021-09-02 22:55:30 +00:00
Jaebaek Seo
0c09258e07
Set threshold for reduce-load-size pass (#4499)
Allow uses to set the threshold for spirv-opt reduce-load-size pass
2021-09-02 10:45:51 -04:00
Steven Perron
bd3a271ce3
Handle exported functions in ADCE (#4495)
ADCE does not handle exported functions.  This was an explicit decision
because we did not believe that the linkage attribute could be used in
shaders, but it can now.  This change has been made.

While fixing this error, I noticed that the OpName for labels is
sometimes removed because the label instructions are not marked
explicitly marked as live.  This has able been fixed.
2021-08-31 12:39:46 -04:00
Lei Zhang
702e6af380
Only add -DSPIRV_CHECK_CONTEXT for Debug builds (#4496) 2021-08-30 09:39:40 -04:00
Jakub Kuderski
b8fce5f9e6
spirv-lint: Add lint based on divergence analysis (#4488)
This PR is a rebased version of #4479 by James Dong.
---

The primary purpose of this PR is to add the code from my prototype as a PR, for licensing reasons.
The commit history is messy, and the code is not especially clean.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/3196.
2021-08-27 14:43:23 -04:00
gnl21
ee30773650
Add a feature for allowing LocalSizeId (#4492)
Allow LocalSizeId as a way of sizing compute workgroups where the
environment allows it. A command-line switch is also added to force
acceptance even where the environment would not otherwise allow it.
2021-08-26 14:33:19 -04:00
Jaebaek Seo
2a5cc342fb Start SPIRV-Tools v2021.4 2021-08-25 10:09:53 -04:00
Jaebaek Seo
1fbed83c8a Finalize SPIRV-Tools v2021.3 2021-08-25 10:08:20 -04:00
Jaebaek Seo
3d4246b4aa Update CHANGES 2021-08-24 16:44:49 -04:00
Greg Fischer
a1d5d67aeb
spirv-val: Validate vulkan debug info similarly to opencl debug info (#4466)
Co-authored-by: baldurk <baldurk@baldurk.org>
2021-08-23 17:38:26 -04:00
dong-ja
937227c761
Add divergence analysis to linter (#4465)
Currently, handles promotion of divergence due to reconvergence rules, but doesn't handle "late merges" caused by a later-than-necessary declared merge block.

Co-authored-by: Jakub Kuderski <kubak@google.com>
2021-08-23 17:03:28 -04:00
sfricke-samsung
d699296b4d
spirv-val: Fix WorkgroupSize VUID 04425 (#4482) 2021-08-19 16:06:01 -04:00
dong-ja
1ad8b71359
spirv-lint: add basic CLI argument handling (#4478)
Mostly copied from spirv-opt. Simply reads in a single input file.
2021-08-18 16:17:03 -04:00
alan-baker
a9ce5e07c6
Fix matrix stride validation (#4468)
Fixes #4454

* Use MatrixStride from member decorations instead of from matrix
  decorations
2021-08-18 13:03:45 -04:00
alan-baker
e172833bd1
Don't double count variables for location validation (#4474)
Fixes #4403

* Pre-1.4 modules could have duplicate interface entries
  * Don't double count variables for locations
2021-08-18 13:01:37 -04:00
Jamie Madill
926ff6d1ba
GN: Suppress unreachable code warnings. (#4476)
These are popping up in a Chromium test integration.

Fixes #4475
2021-08-18 08:53:21 -04:00
Jaebaek Seo
57e1d8ebe3
Add spirv-opt convert-to-sampled-image pass (#4340)
convert-to-sampled-image pass converts images and/or samplers with
given pairs of descriptor set and binding to sampled image.

If a pair of an image and a sampler have the same pair of descriptor
set and binding that is one of the given pairs, they will be
converted to a sampled image. In addition, if only an image has the
descriptor set and binding that is one of the given pairs, it will
be converted to a sampled image as well.

For example, when we have

  %a = OpLoad %type_2d_image %texture
  %b = OpLoad %type_sampler %sampler
  %combined = OpSampledImage %type_sampled_image %a %b
  %value = OpImageSampleExplicitLod %v4float %combined ...

1. If %texture and %sampler have the same descriptor set and binding

  %combine_texture_and_sampler = OpVaraible %ptr_type_sampled_image_Uniform
  ...
  %combined = OpLoad %type_sampled_image %combine_texture_and_sampler
  %value = OpImageSampleExplicitLod %v4float %combined ...

2. If %texture and %sampler have different pairs of descriptor set and binding

  %a = OpLoad %type_sampled_image %texture
  %extracted_image = OpImage %type_2d_image %a
  %b = OpLoad %type_sampler %sampler
  %combined = OpSampledImage %type_sampled_image %extracted_image %b
  %value = OpImageSampleExplicitLod %v4float %combined ...
2021-08-18 08:30:48 -04:00
alan-baker
b2e36b67ec
Disallow loading a runtime-sized array (#4473)
* Disallow loading a runtime-sized array

Fixes #4472

* Disallow loading a runtime-sized array or a composite containing one
* Refactor type traversal into a separate function used by both runtime
  array checks and sized int/float checks
* Update invalid tests
2021-08-16 18:23:10 -04:00
Nicolas Capens
2c829c4155
Fix early-out for Clamp constant folding (#4461)
Only the first two operands were tested for constness, missing the third
one. Since the FoldFPBinaryOp() at the end of FoldClamp1() returns null
when not both of its operands are constant, this doesn't change any
behavior, but it avoids some needless work.

Also the comment for FoldClamp2() was fixed.
2021-08-16 14:11:38 -04:00
Nicolas Capens
869a550d26
Don't fold unsigned divides of an constant and a negation (#4457)
Negating an unsigned constant results in its two's complement which is
still interpreted as unsigned. For example -2u becomes 4294967294u.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/4456
2021-08-16 09:56:05 -04:00
5265644D61736F6E
881001070a
fix SIGSEGV when reading from a non-existant file (#4453)
When a tool (tested with spirv-dis and spirv-as) runs on a file that
does not exist, it notifies the user and tries to close the stream that
was never successfully opened.
2021-08-16 09:44:22 -04:00
alan-baker
00b106e769
Limit location validation (#4467)
Fixes #4464

* Add a limit to only check up to 4096 locations to prevent excessive
  memory consumption
  * still fully validates all reasonable inputs
2021-08-13 13:00:00 -04:00
alan-baker
54524ffa6a
Update SPIRV-Headers (#4463)
* Add SpvBuiltInCurrentRayTimeNV to unvalidated builtins
2021-08-12 10:34:29 -04:00
Greg Fischer
de69f32e89
spirv-opt: Add handling of vulkan debug info to DebugInfoManager (#4423)
Co-authored-by: baldurk <baldurk@baldurk.org>
2021-08-10 09:31:17 -04:00
dong-ja
c4c6f2ba5c
spirv-opt: Add dataflow analysis framework (#4402)
This PR adds a generic dataflow analysis framework to SPIRV-opt, with the intent of being used in SPIRV-lint. This may also be useful for SPIRV-opt, as existing ad-hoc analyses can be rewritten to use a common framework, but this is not the target of this PR.
2021-08-09 16:43:36 -04:00