Commit Graph

2720 Commits

Author SHA1 Message Date
André Perez
ee7f0c882f
spirv-opt: Implement opt::Function::HasEarlyReturn function (#3711) 2020-08-18 09:31:24 -04:00
André Perez
e28436f2b8
spirv-fuzz: Check termination instructions when donating modules (#3710)
The FuzzerPassDonateModules was not checking if the function to donate had
a block with OpKill or OpUnreachable as its termination instruction.

Fixes #3709.
2020-08-17 23:30:07 +01:00
Jack Andersen
1023dd7a04
Fix -Wrange-loop-analysis warning (#3712) 2020-08-17 12:59:36 -04:00
André Perez
82f4bf128a
spirv-fuzz: Check header dominance when adding dead block (#3694)
`TransformationAddDeadBlock` did not check whether the existing block
(that will become a selection header) dominates its successor block (that
will become its merge block).

This change adds the check.

Fixes #3690.
2020-08-17 17:47:13 +01:00
Jaebaek Seo
b8de4f57e9
Allow DebugTypeTemplate for Type operand (#3702)
Some OpenCL.DebugInfo.100 instructions such as DebugGlobalVariable
and DebugLocalVariable have the Type operand. This commit allows them to
use DebugTypeTemplate for the Type operand.
2020-08-16 23:42:59 -04:00
Antoni Karpiński
c20995ef80
spirv-fuzz: Improve code coverage of tests (#3686)
Improves the code coverage of tests for the following transformations:

1. TransformationAddRelaxedDecoration
2. TransformationReplaceCopyMemoryWithLoadStore
3. TransformationReplaceCopyObjectWithStoreLoad
4. TransformationReplaceLoadStoreWithCopyMemory
5. TransformationReplaceAddSubMulWithCarryingExtended
2020-08-14 12:47:21 +01:00
Stefano Milizia
eade36db22
spirv-fuzz: Fuzzer pass to randomly apply loop preheaders (#3668)
This PR introduces FuzzerPassAddLoopPreheaders, which:
- Finds existing loop headers
- If they have no simple preheader (where simple means that the
  preheader itself is not a loop header), randomly decides whether
  to add one.

Fixes #3621.
2020-08-14 12:44:28 +01:00
Vasyl Teliman
72ea7bec4a
spirv-fuzz: Support identical predecessors in TransformationPropagateInstructionUp (#3689)
Support identical predecessors in TransformationPropagateInstructionUp.

A basic block may have multiple identical predecessors as follows:

%1 = OpLabel
OpSelectionMerge %2 None
OpBranchConditional %true %2 %2
%2 = OpLabel
...

This case wasn't supported before.
2020-08-14 12:29:36 +01:00
alan-baker
b4c4da3e76
Improve non-semantic instruction handling in the optimizer (#3693)
* No longer blindly add global non-semantic info instructions to global
  types and values
  * functions now have a list of non-semantic instructions that succeed
    them in the global scope
  * global non-semantic instructions go in global types and values if
    they appear before any function, otherwise they are attached to the
    immediate function predecessor in the module
* changed ADCE to use the function removal utility
* Modified EliminateFunction to have special handling for non-semantic
  instructions in the global scope
  * non-semantic instructions are moved to an earlier function (or full
    global set) if the function they are attached to is eliminated
  * Added IRContext::KillNonSemanticInfo to remove the tree of
    non-semantic instructions that use an instruction
  * this is used in function elimination
* There is still significant work in the optimizer to handle
  non-semantic instructions fully in the optimizer
2020-08-13 14:54:14 -04:00
Vasyl Teliman
948577c5df
Fix the bug (#3680) 2020-08-13 09:09:57 -04:00
André Perez
df859f77da
spirv-fuzz: Check integer and float width capabilities (#3670)
`TransformationAddTypeFloat` and `TransformationAddTypeInt` did not check whether the required capabilities were present when adding 16-bit, 64-bit, and 8-bit types.

This change adds these checks in the `IsApplicable` method of each transformation.

Fixes #3669.
2020-08-12 22:05:36 +01:00
André Perez
2641d33516
spirv-fuzz: consider additional access chain instructions (#3672)
`TransformationReplaceIdWithSynonym` is careful to avoid replacing id uses that index into a struct with synonyms because the indices must only be `OpConstant` instructions. However, the check only considered `OpAccessChain` instructions, even though the same restriction applies to `OpInBoundsAccessChain`, `OpPtrAccessChain`, etc. 

This change extends the check to include all access chain instructions.

Fixes #3671.
2020-08-12 21:58:53 +01:00
André Perez
5e5929455f
spirv-fuzz: Ignore specialization constants (#3664)
`FuzzerPassInterchangeSignednessOfIntegerOperands` and `FuzzerPassInterchangeZeroLikeConstants` both included specialization constants when trying to find integer constants with known values. However, this is incorrect behavior because we do not know the value of specialization constants. Furthermore, ConstantManager does not support them, and this led to crashes where we assumed we could look up specialization constants via the ConstantManager.

This change fixes both passes to ignore specialization constants.

Fixes #3663.
2020-08-12 18:59:47 +01:00
Vasyl Teliman
1435e427da
Fix the bug (#3683) 2020-08-12 13:00:41 -04:00
Vasyl Teliman
be099cde1f
spirv-fuzz: Fix width in FuzzerPassAddEquationInstructions (#3685)
Fixes FuzzerPassAddEquationInstructions to check whether certain int/float type widths are supported to avoid creating unsupported types.

Fixes #3669.
2020-08-12 16:39:23 +01:00
Jaebaek Seo
f0ca96d12c
Preserve debug info in dead-insert-elim pass (#3652)
When we determine the liveness of an insert, we have to ignore the debug
instruction (it must not have any impact on the decision).
2020-08-12 10:19:37 -04:00
Jaebaek Seo
0d629b903a
Validate more OpenCL.DebugInfo.100 instructions (#3684)
- DebugTypeTemplate
- DebugTypeTemplateParameter
- DebugGlobalVariable
- DebugInlinedAt
- DebugValue
2020-08-12 09:37:32 -04:00
alan-baker
13a65b1aee
Only validation locations for appropriate execution models (#3656)
Fixes #3653

* Only validate locations for fragment, vertex, geometry and
  tessellation shaders
2020-08-11 18:51:49 -04:00
André Perez
fd3cabd8b5
spirv-fuzz: Fix in operand type assertion (#3666)
spvtools::fuzz::MakeIdUseDescriptorFromUse asserts if the id use type is
SPV_OPERAND_TYPE_ID. The problem is that not all id types are covered by
this condition. The bug was found because the first operand of an OpControlBarrier
instruction has SPV_OPERAND_TYPE_SCOPE_ID as type. Therefore, to cover
all cases the spvIsInIdType function is used.

Fixes #3665.
2020-08-11 18:37:01 +01:00
André Perez
f505538677
spirv-opt: Add spvOpcodeIsAccessChain (#3682) 2020-08-11 11:21:36 -04:00
Vasyl Teliman
b7056e7e03
spirv-fuzz: FuzzerPassPropagateInstructionsUp (#3478)
Given an instruction (that may use an OpPhi result from the same block as an input operand), try to clone the instruction into each predecessor block, replacing the input operand with the corresponding OpPhi input operand in each case, if necessary.

Fixes #3458.
2020-08-11 10:24:32 +01:00
Steven Perron
8e1380996d
Handle no index access chain in local access chain convert (#3678)
* Handle no index access chain in local access chain convert

Fixes #3643
2020-08-10 22:03:02 -04:00
Ryan Harrison
bdeeae78a9
Roll 2 dependencies (#3677)
Roll external/googletest/ a781fe29b..3af06fe16 (12 commits)

a781fe29bc...3af06fe166

$ git log a781fe29b..3af06fe16 --date=short --no-merges --format='%ad %ae %s'
2020-08-05 absl-team Googletest export
2020-08-03 absl-team Googletest export
2020-08-03 absl-team Googletest export
2020-08-05 zumix.cpp fix endif comment
2020-08-02 zumix.cpp fix tests
2020-07-29 franciscogthiesen Removing tiny-dnn from "Who is using.."
2020-07-28 absl-team Googletest export
2020-07-29 zumix.cpp fix GTEST_REMOVE_LEGACY_TEST_CASEAPI_ typo
2020-07-28 absl-team Googletest export
2020-07-26 ofats Googletest export
2020-07-19 jasjuang fix clang tidy modernize-use-equals-default warnings
2020-07-02 siliconearth Fix test failing when simple regex is used

Created with:
  roll-dep external/googletest

Roll external/spirv-headers/ 5538bf438..3fdabd0da (1 commit)

5538bf4386...3fdabd0da2

$ git log 5538bf438..3fdabd0da --date=short --no-merges --format='%ad %ae %s'
2020-08-03 44190824+mmerecki Reserve SPIR-V token range for upcoming Intel extensions. (#165)

Created with:
  roll-dep external/spirv-headers
2020-08-10 16:44:39 -04:00
Steven Perron
2990a21926
Avoid using /MP4 for clang on windows. (#3662) 2020-08-10 10:59:24 -04:00
Antoni Karpiński
7b2dd11dda
spirv-fuzz: TransformationReplaceAddSubMulWithCarryingExtended (#3598)
Replaces OpIAdd with OpIAddCarry, OpISub with OpISubBorrow, OpIMul with
OpUMulExtended or OpSMulExtended and stores the result into a fresh_id
representing a structure. Extracts the first element of the result into
the original result_id. This value is the same as the result of the
original instruction.

Fixes #3577
2020-08-06 17:30:34 +01:00
André Perez
6d7f34fbfe
spirv-fuzz: Add TransformationMakeVectorOperationDynamic (#3597)
Fixes #3588.
2020-08-06 15:50:18 +01:00
André Perez
d29eac95aa
spirv-fuzz: iterate over blocks in replace linear algebra pass (#3654)
This PR changes the way FuzzerPassReplaceLinearAlgebraInstructions iterates over the module instructions. It avoids iterating over non-relevant instructions (globals, types, etc.).
2020-08-06 13:00:17 +01:00
Stefano Milizia
efc85ff661
spirv-fuzz: make outliner pass use additional transformations (#3604)
This PR changes FuzzerPassOutlineFunctions so that it uses some
transformation that make the TransformationOutlineFunction
transformation applicable in more cases. See the discussion in
#3095 for more details.

Fixes #3095.
2020-08-06 12:29:26 +01:00
Jaebaek Seo
5fd92a7e0c
OpenCL.DebugInfo.100 DebugTypeArray with variable size (#3549)
The updated OpenCL.DebugInfo.100 spec says that we can use
variable for "Component Count" operand of DebugTypeArray i.e.,
DebugLocalVariable or DebugGlobalVariable. This commit updates spirv-val
based on the spec update.
2020-08-05 17:08:37 -04:00
André Perez
3f33a9aa55
spirv-opt: Improve the code of the Instruction class (#3610) 2020-08-05 15:28:05 -04:00
Vasyl Teliman
0419751b0c
spirv-fuzz: Handle OpPhis in livesafe functions (#3642)
Fixes #3641.
2020-08-05 19:21:37 +01:00
Vasyl Teliman
a10e760596
spirv-fuzz: Handle OpPhi during constant obfuscation (#3640)
Fixes #3639.
2020-08-05 19:17:27 +01:00
Vasyl Teliman
28f32ca53e
spirv-fuzz: Fix FuzzerPassCopyObjects (#3638)
Fixes #3637.
2020-08-05 11:54:11 +01:00
Vasyl Teliman
8bc27a1cfb
spirv-fuzz: Remove OpFunctionCall operands in correct order (#3630)
Fixes #3629.
2020-08-04 19:10:21 +01:00
Vasyl Teliman
d9c73ebd9e
spirv-fuzz: Handle capabilities during module donation (#3651)
Fixes #3648.
2020-08-04 17:11:29 +01:00
Vasyl Teliman
9f22236024
spirv-fuzz: Refactor boilerplate in TransformationAddParameter (#3625)
Part of #3534. I forgot to implement this functionality in the original PR.
2020-08-04 15:04:17 +01:00
Vasyl Teliman
92a71657fc
spirv-fuzz: TransformationMoveInstructionDown (#3477)
Swaps an instruction with the next instruction in the block.

Fixes #3457.
2020-08-03 16:45:24 +01:00
Jaebaek Seo
b78f4b1518
Remove DebugDeclare only for target variables in ssa-rewrite (#3511)
For each local variable, ssa-rewrite should remove its DebugDeclare
if and only if it is replaced by any number of DebugValues for store
and phi instructions.

For example, when we have two variables `a` whose DebugDeclare
will be replaced to DebugValues by ssa-rewrite pass and `b` whose
DebugDeclare will not be replaced, we have to remove only DebugDeclare
for `a`, not `b`.
2020-07-31 10:00:30 -04:00
Vasyl Teliman
91cea06ab4
Fix typo in ASAN CI build (#3623) 2020-07-31 13:53:41 +01:00
Stefano Milizia
2aaa8653da
spirv-fuzz: Transformation to add loop preheader (#3599)
This PR introduces TransformationAddLoopPreheader, which, given
a loop header and enough fresh ids, adds a loop preheader, updating
all the references so that this new block is the only out-of-loop
predecessor of the header, which branches unconditionally to the
header.

See the discussion in #3095.
2020-07-30 20:18:19 +01:00
Stefano Milizia
96bcc82743
spirv-fuzz: Pass to replace int operands with ints of opposite signedness (#3612)
This PR introduces a new fuzzer pass, which:

- finds all integer vectors or constants
- finds or creates the corresponding constants with opposite
  signedness
- records such constants as synonyms of the first ones
- replaces the usages of the original constants with the new ones
  if allowed

Fixes #2677.
2020-07-30 19:48:29 +01:00
Jaebaek Seo
ebaefda666
Debug info preservation in loop-unroll pass (#3548)
When we copy the loop body to unroll it, we have to copy its
instructions but DebugDeclare or DebugValue used for the declaration
i.e., DebugValue with Deref must not be copied and only the first block
can contain those instructions.
2020-07-30 12:18:06 -04:00
alan-baker
50300450af
Validator support for non-semantic clspv reflection (#3618)
* Generate ext inst table for reflection
* Change build to use grammar files from SPIRV-Headers instead of
  SPIRV-Tools
* Add enum for clspv reflection extended instruction set
  * count it as non-semantic
* validate clspv reflection extended instruction set
* Remove local extended inst sets
* update headers deps
* Update nbuilds to use grammars from SPIRV-Headers instead of
  local duplicates
2020-07-30 12:08:53 -04:00
Vasyl Teliman
ab4fe12a46
spirv-fuzz: Fix memory bugs (#3622) 2020-07-30 16:51:29 +01:00
André Perez
c6e6597c4f
spirv-fuzz: Implement the OpOuterProduct linear algebra case (#3617)
Fixes #3354.
2020-07-29 23:46:56 +01:00
Vasyl Teliman
054f034ea9
spirv-fuzz: Compute corollary facts from OpBitcast (#3538)
Splits #3523 in two parts. This part implements functionality to
compute corollary facts from OpBitcast equation facts.
2020-07-29 22:06:31 +01:00
dan sinclair
a1ea15c902
Update some language usage. (#3611)
This CL updates various bits of language in line with the guidelines
provided by Android
(https://source.android.com/setup/contribute/respectful-code)
2020-07-29 13:50:58 -04:00
Vasyl Teliman
863b8e3d3d
spirv-fuzz: Relax type constraints in DataSynonym facts (#3602)
Fixes #3595.
2020-07-29 17:48:01 +01:00
Vasyl Teliman
7e75fea9ec
spirv-fuzz: Remove non-deterministic behaviour (#3608)
Fixes #3607.
2020-07-29 17:47:12 +01:00
Alastair Donaldson
f9b088fe0d
Avoid use of 'sanity' and 'sanity check' in the code base (#3585)
In line with:

  https://source.android.com/setup/contribute/respectful-code

this change uses the terms 'coherence' and 'coherence check' where
'sanity' and 'sanity check' were previously used.
2020-07-28 23:55:02 -04:00