Commit Graph

1296 Commits

Author SHA1 Message Date
Ryan Harrison
11c7a9e067
Validate that debugging instructions are not present for WebGPU (#2089)
Validate that debugging instructions are not present for WebGPU

For WebGPU execution environments, check that all of the debug
instructions have already been stripped before validation.

Fixes #2063
2018-11-20 16:12:28 -05:00
alan-baker
d41ff27f17
Add support for VK_EXT_Transform_feedback capabilities (#2088)
* Added support for Transform Feedback capabilities.
* Fix tests
2018-11-20 12:41:03 -05:00
dan sinclair
15fdcf94d7 Add missing override to ProcessLinesPass 2018-11-19 19:24:48 -05:00
alan-baker
f5b4a8eee3
Catch invalid input type to OpConvertUToPtr (#2078)
Fixes https://crbug.com/906426

* Fails validation if the input operand is a type
* Added a test
2018-11-19 15:08:38 -05:00
Ryan Harrison
8cd2a9d187
Validate component literals for OpVectorShuffle in WebGPU environment (#2077)
Validate component literals for OpVectorShuffle in WebGPU environment

Fixes #2072
2018-11-19 14:32:18 -05:00
Alan Baker
d652ed3029 Vulkan memory model: semantics validation
Ban sequentially consistent with VulkanKHR

* Added validation check that SequentiallyConsistent memory semantics
are not used if the memory model is VulkanKHR
 * Added tests
* Fixed a bug in evaluating constant 32-bit integers and updated some
handling to avoid inferring a value from a spec constant default

Remaining memory semantics validation

* Adds checks that OutputMemoryKHR, MakeAvailableKHR and MakeVisibleKHR
are only used if the VulkanMemoryModelKHR capabailty is present
* Added checks that MakeAvailableKHR requires release semantics
* Added checks that MakeVisibleKHR requires acquire semantics
* Added checks that MakeAvailableKHR and MakeVisibleKHR require a
storage class
2018-11-19 11:44:20 -05:00
Alan Baker
cd22b31557 Catch branch condition being a type
Fixes https://crbug.com/903691

* Added a test
2018-11-16 16:40:39 -05:00
David Neto
8e9be303b0 Validator: Support VK_EXT_scalar_block_layout
Adds validator option to specify scalar block layout rules.

Both VK_KHR_relax_block_layout and VK_EXT_scalar_block_layout can be
enabled at the same time.  But scalar block layout is as permissive
as relax block layout.

Also, scalar block layout does not require padding at the end of a
struct.

Add test for scalar layout testing ArrayStride 12 on array of vec3s

Cleanup: The internal getSize method does not need a round-up argument,
so remove it.
2018-11-16 15:55:30 -05:00
alan-baker
28d8d7bc67
Fix min base alignment (#2075)
Fixes #2073

* Added a test
2018-11-16 14:22:42 -05:00
Ryan Harrison
d7cd1203a4 Ensure for OpVariable that result type and storage class operand agree (#2052)
From SPIR-V spec, section 3.32.8 on OpVariable:
  Its Storage Class operand must be the same as the Storage Class
  operand of the result type.

Fixes #941
2018-11-16 11:22:11 -05:00
greg-lunarg
c37388f1ad Add passes to propagate and eliminate redundant line instructions (#2027). (#2039)
These are bookend passes designed to help preserve line information
across passes which delete, move and clone instructions. The propagation
pass attaches a debug line instruction to every instruction based on
SPIR-V line propagation rules. It should be performed before optimization.
The redundant line elimination pass eliminates all line instructions
which match the previous line instruction. This pass should be performed
at the end of optimization to reduce physical SPIR-V file size.

Fixes #2027.
2018-11-15 14:06:17 -05:00
fjhenigman
ab76e332de
Validate uniform variable type in Vulkan (#1949) (#2055)
From the Vulkan 1.1 spec 14.5.2:
  Variables identified with the Uniform storage class are used to access
  transparent buffer backed resources. Such variables must be typed as
  OpTypeStruct, or an array of this type.

Fixes #1949
2018-11-15 13:42:17 -05:00
David Neto
a29a9947ac UniformConstant variables can have RuntimeArray, TypeAccelerationStructureNV 2018-11-14 21:50:09 -05:00
Greg Fischer
d4a10590b7 Fix Instruction::IsFloatingPointFoldingAllowed()
Was looking for decorations based on opcode. Should use result_id.
2018-11-14 15:25:51 -07:00
alan-baker
5c334514d6
Allow InstanceId for NV ray tracing (#2049)
* Allow InstanceId for NV ray tracing

Fixes #2046

* Allows InstanceId in the Vulkan environment if RayTracingNV
capability is specified
2018-11-14 15:03:40 -05:00
Ryan Harrison
a362e60d5a
Validate variable types for UniformConstant storage in Vulkan (#2008) (#2044)
Validate variable types for UniformConstant storage in Vulkan (#2008)

From the Vulkan 1.1 spec 14.5.2:
  Variables identified with the UniformConstant storage class are used
  only as handles to refer to opaque resources. Such variables must be
  typed as OpTypeImage, OpTypeSampler, OpTypeSampledImage, or an array
  of one of these types.

Fixes #2008
2018-11-14 15:00:03 -05:00
Steven Perron
dc9d155d62
Fix folding of volatile store. (#2048)
When looking for the Volatile mask on a store, the instruction folder
accesses an out-of-bounds element.  We fix that up.

Fixes crbug.com/903530.
2018-11-14 13:52:18 -05:00
Steven Perron
a6150a3fe7
Don't assert on void function parameters. (#2047)
The type manager in spirv-opt currently asserts if a function parameter
has type void.  It is not exactly clear from the spec that this is
disallowed, even if it probably will be disallowed.  In either case,
asserts should be used to verify assumptions that will actually make a
difference to the code.  As far as the optimizer is concerned, a void
parameter does not matter.  I don't see the point of the assert.  I'll
just remove it and let the validator decide whether to accept it or not.

No test was added because it is not clear that it is legal, and should
not force us to accept it in the future unless the spec make it clear
that it is legal.

Fixes crbug.com/903088.
2018-11-14 12:43:43 -05:00
Steven Perron
ec5574a9c6
Instruction::GetBaseAddress to handle OpPtrAccessChain (#2050)
That function currently only handled OpPtrAccessChain if it was in the
middle of the chain, but not at the start.  Fixing that up.

Fixes crbug.com/905271.
2018-11-14 12:42:25 -05:00
Neil Henning
2b1f6b373c Validate that VertexId and InstanceId are not allowed in Vulkan. (#2036)
The Vulkan specification does not permit use of the VertexId and
InstanceId BuiltIn decorations, so add a check to ensure they are not
being used when the target environment is Vulkan.
2018-11-13 09:22:48 -05:00
dan sinclair
f343a15764
Add missing overrides (#2041) 2018-11-12 15:11:32 -05:00
dan sinclair
75999d9b71
Remove asserts around environment determination. (#2040)
This CL removes several asserts around determining the SPIR-V
environment. In each case we already return a default value if
assertions are compiled out, so just return the default value.
2018-11-12 14:24:47 -05:00
greg-lunarg
1e9fc1aac1 Add base and core bindless validation instrumentation classes (#2014)
* Add base and core bindless validation instrumentation classes

* Fix formatting.

* Few more formatting fixes

* Fix build failure

* More build fixes

* Need to call non-const functions in order.

Specifically, these are functions which call TakeNextId(). These need to
be called in a specific order to guarantee that tests which do exact
compares will work across all platforms. c++ pretty much does not
guarantee order of evaluation of operands, so any such functions need to
be called separately in individual statements to guarantee order.

* More ordering.

* And more ordering.

* And more formatting.

* Attempt to fix NDK build

* Another attempt to address NDK build problem.

* One more attempt at NDK build failure

* Add instrument.hpp to BUILD.gn

* Some name improvement in instrument.hpp

* Change all types in instrument.hpp to int.

* Improve documentation in instrument.hpp

* Format fixes

* Comment clean up in instrument.hpp

* imageInst -> image_inst

* Fix GetLabel() issue.
2018-11-08 13:54:54 -05:00
greg-lunarg
6721478ef1 Don't assume one return means function can be inlined. (#2018) (#2025)
If there is only 1 return and it is in a loop, then the function cannot be inlined.

Fix condition when inlined code needs one-trip loop wrapper.  The dummy loop is needed when there is a return inside a selection construct.  Even if there is only 1 return.
2018-11-08 09:11:20 -05:00
Jeff Bolz
c06a35b902 Rename PCH macro to spvtools_pch to avoid conflicts with other projects. Also add pch to test/opt. (#2034) 2018-11-07 09:15:04 -05:00
Steven Perron
91f33503fc
Validate the id bound. (#2031)
* Validate the id bound.

Validates that the id bound for the module is not larger than the max id
bound.  Also adds an option to set the max id bound.  Allows the
optimizer option to set the max id bound to also set the id bound for
the validation run done by the optimizer.

Fixes #2030.
2018-11-06 11:30:19 -05:00
James Jones
398f37a2e0 Add explicit void parameter in libspirv.h again (#2032)
When building C code with gcc and the
-Wstrict-prototypes option, function declarations
and definitions that don't specify their argument
types generate warnings.  Functions that don't
take parameters need to specify (void) as their
parameter list, rather than leaving it empty.

Note this only applies to C, so only the functions
exported in C-compatible headers need fixing.  In
C++ functions can't be declared/defined without a
parameter list, so C++ can safely allow an empty
parameter list to imply (void).
2018-11-06 11:12:26 -05:00
Jeff Bolz
60fac96c6b Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
Steven Perron
f2cc71e5cb
Handle OpMemberDecorateStringGOOGLE in ACDE (#2029)
Add missing case to the switch statement for the annotation
instructions.

See https://github.com/KhronosGroup/glslang/issues/1561.
2018-11-02 13:42:45 -04:00
Jeff Bolz
fb996dce75 Add /Zm flag as a workaround for VS2013 build (#2023) 2018-10-31 07:59:43 -04:00
Steven Perron
6647884a13
Remove MemberDecorateStringGOOGLE during stript-refect. (#2021)
The strip-reflect pass is not removing the reflection decorations that
are decorating members.  With this commit, they will now be removed.

Fixes #2019.
2018-10-30 16:17:35 -04:00
alelenv
1c1e749f0b Add support for nv-raytracing-final (#2010)
Add support for nv-raytracing (non-experimental)
2018-10-25 14:07:46 -04:00
Steven Perron
18fe6d59e5
Fix dead branch elim infinite loop. (#2009)
When looking for a break from a selection construct, we do not realize
that a jump to the continue target of a loop containing the selection
is a break.  This causes and infinit loop, or possibly other failures.

Fixes #2004.
2018-10-24 09:10:30 -04:00
Steven Perron
0ba35798c3
Fix dead branch elim infinite loop. (#1997)
When looking for a break from a selection construct, we do not need to
look inside nested constructs.  However, if a loop header has an
unconditional branch, then we enter the loop.  Entering the loop causes
an infinite loop because we keep going through the loop.

The solution is to look for a merge block, if one exsits, even for block
terminated by an OpBranch.

Fixes #1979.
2018-10-22 13:59:20 -04:00
alan-baker
20bbfb6f4d
Layout checks should recurse through runtime arrays (#1999)
Fixes #1985

* Added test to catch bug
* Tested aginst Vulkan CTS
2018-10-22 08:50:45 -04:00
alan-baker
89b8e238eb
Better checking of the index operand (#1992)
Fixes https://crbug.com/897069

* Code previously assumed the index instruction had a type
* Added a test to reproduce
2018-10-22 08:47:56 -04:00
alan-baker
6e85d1a6fc
Fix restrictions in if conversion (#1998)
Fixes #1991

* Improved identification of potential conditional branches
* Pass changed to only work for shaders
* added a test to catch the bug
2018-10-19 15:16:46 -04:00
Jeff Bolz
dd1e837e1c Use per-configuration location for pch file (#1989) 2018-10-19 14:58:26 -04:00
Steven Perron
8edf3557ca
Revert "Add custom target to wrap around custom commands. (#1986)" (#1996)
Breaks the build when using makefiles.  The ninja build is fine.

This reverts commit 67ebe3f7ae.
2018-10-19 14:05:19 -04:00
Neil Henning
d29a1f98f3 Add validaton for SPV_KHR_8bit_storage + convert to/from floats. (#1990)
The SPV_KHR_8bit_storage extension does not permit 8-bit integers to be
cast directly to floating point types. We are seeing shaders in the
wild, being produced by toolchains like glslang, that are generating
invalid SPIR-V.

This change adds validation to check for the patterns not permitted, and
some tests that expose the failure.
2018-10-19 13:45:26 -04:00
Steven Perron
715afb0cea
Add a nullptr check to array copy propagation. (#1987)
We are missing a check for a nullptr that is causing things to fail.

Added an extra test case, and fixed up others.

This is the fix for https://github.com/Microsoft/DirectXShaderCompiler/issues/1598.
2018-10-19 12:53:40 -04:00
Steven Perron
67ebe3f7ae
Add custom target to wrap around custom commands. (#1986)
In CMake, we are not suppose to have multiple targets depend on the same
custom command.  To avoid this, we have to add a custom target around
the command.

Fixes #1941.
2018-10-19 10:17:47 -04:00
greg-lunarg
c4687889b7 Fix ADCE to treat OpUnreachable correctly during liveness analysis (#1984)
ADCE liveness algorithm should treat OpUnreachable at least like other
branch instructions. It was being treated as always live which was
preventing useless structured constructs from being eliminated.
OpUnreachable is generated by dead branch elimination which is now
being required by merge return, so this fix should accompany that
change.
2018-10-19 10:16:35 -04:00
Steven Perron
0e68bb3632
Only run merge-returnon reachable functions. (#1983)
We currently run merge-return on all functions, but
dead-branch-elimination only runs on function reachable from an entry
point or exported function.  Since dead-branch-elimination is needed for
merge-return, they have to match.

Fixes #1976.
2018-10-18 08:48:27 -04:00
alan-baker
9aa14a38f4
OpGroupDecorate may not target OpDecorationGroup (#1977)
Fixes https://crbug.com/896200

* Adds a check to validation of OpGroupDecorate that OpDecorationGroup
cannot be targeted
2018-10-17 13:45:05 -04:00
Steven Perron
b407163ef3
Checks for variable pointers (#1976)
In logical addressing mode, we are not allowed to generate variables
pointers.  There is already a check for OpSelect.  However, OpPhi 
and OpPtrAccessChain are not checked to make sure it does not 
generate an variable pointer.  I've added those checks.

Fixes #1957.
2018-10-16 14:57:55 -04:00
greg-lunarg
ab45d69154 Fix ADCE liveness to include all enclosing control structures. (#1975)
Was removing control structures which didn't have data dependency
with enclosed live loop and otherwise did not contain live code.
An example is a counting loop around a live loop.

Fixes #1967.
2018-10-16 08:00:07 -04:00
David Neto
eea449a1e8 validator: FPRoundingMode can apply to vector conversions
Fixes #1972
2018-10-15 17:22:50 -04:00
Jeff Bolz
339d23275d Enable precompiled headers for MSVC (#1969) 2018-10-15 11:12:02 -04:00
alan-baker
72bac04d73
Memory access checks for vulkan mem model (#1909)
* MakePointerVisibleKHR cannot be used with OpStore
* MakePointerAvailableKHR cannot be used with OpLoad
* MakePointerAvailableKHR and MakePointerVisibleKHR both require
NonPrivatePointerKHR
* NonPrivatePointerKHR is limited to a subset of storage classes
* many tests
2018-10-15 09:30:47 -04:00
David Neto
bdecee8c86 Validator: TaskNV can use LocalSize or LocalSizeId (#1970)
Correponds to the update to Rev2 of SPV_NV_mesh_shader

Fixes #1968
2018-10-12 08:54:52 -04:00
greg-lunarg
e545564887 Consider atomics that load when analyzing live stores in ADCE (#1956) (#1958)
Consider atomics that load when analyzing live stores in ADCE.

Previously it asserted that the base of an OpImageTexelPointer should
be an image. It is actually a pointer to an image, so IsValidBasePointer
should suffice.
2018-10-12 08:46:35 -04:00
Alan Baker
1c128aa9ef Validating for new image operands
* Validation checks for new image operands MakeTexelAvailableKHR and
MakeTexelVisibleKHR
 * added tests
* Tests that NonPrivateTexelKHR is accepted for all image operands

Updating test environments

* fixed build errors
* changed image types for *FetchSuccess tests to use a type defined in
1.3 shader body
2018-10-11 17:47:18 -04:00
Steven Perron
82663f34c9
Check for unreachable blocks in merge-return. (#1966)
Merge return assumes that the only unreachable blocks are those needed
to keep the structured cfg valid.  Even those must be essentially empty
blocks.

If this is not the case, we get unpredictable behaviour.  This commit
add a check in merge return, and emits an error if it is not the case.

Added a pass of dead branch elimination before merge return in both the
performance and size passes.  It is a precondition of merge return.

Fixes #1962.
2018-10-10 15:18:15 -04:00
alan-baker
bc09f53c96
Fix calculation of case fall through (#1965)
Fixes #1959

* Code erroneously concluded that the target's fall through was itself
* Added a test
2018-10-10 13:25:48 -04:00
Steven Perron
4e266f775a
Fold divisions by 0. (#1963)
The current implementation in the folder when seeing a division by zero
is to assert.  In the release build, the compiler will attempt to
compute the value, which causes its own problems.

The solution I will go with is to fold the division, and just give it
the value of 0.  The same goes for remainder and mod operations.

Fixes #1961.
2018-10-10 11:17:26 -04:00
alan-baker
fae1e61ab8
Fix bug in construct block calculation (#1964)
Fixes #1960

* Only allows blocks that are dominated by the header
* Fixed a bad loop fusion test
* Added a test derived from the reported bug
2018-10-10 11:14:01 -04:00
Ben Ashbaugh
d3f88b0841 allow atomics on Function pointers for OpenCL (#1955) 2018-10-09 11:33:01 -04:00
Jaebaek Seo
03cbf33a69 Validator: FPRoundingMode decoration (#1482)
This commit checks the following when Shader capability exists:
"The FPRoundingMode decoration can be applied only to a width-only
conversion instruction that is used as the Object operand of an
OpStore storing through a pointer to a 16-bit floating-point object
in the StorageBuffer, Uniform, PushConstant, Input, or Output
Storage Classes.".
2018-10-05 13:33:03 -04:00
Steven Perron
497958d899 Removing HLSLCounterBuffer decorations when not needed. (#1954)
The HlslCounterBufferGOOGLE that was introduced changed the OpDecorateId
so that is can now reference an id other than the target.  If that other
id is used only in the decoration, then the definition of the id will be
removed because decoration do not count as real uses.

However, if the target of the decoration is still live the decoration
will not be removed.  This leaves a reference to an id that is not
defined.

There are two solutions to consider.  The first is that is the decoration
is kept, then the definition of the id should be kept live.  Implementing
this change would be involved because the way ADCE handles decorations
will have to be reimplemented.

The other solution is to remove the decoration the id is otherwise dead.
This works for this specific case.  Also this is the more desirable
behaviour in this case.  The id will always be the id of a variable that
belongs to a descriptor set.  If that variable is not bound and we do
not remove it, the driver will complain.

I chose to implement the second solution.  The first will be left to when
a case for it comes up.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1885.
2018-10-05 08:23:09 -04:00
Jaebaek Seo
ebcc58b5f8 Validator: function scope variable at start of entry block #1923
All OpVariable instructions in a function must be the first
instructions in the first block.
2018-10-04 15:05:47 -04:00
Alan Baker
3b5960174f Don't scalarize spec constant sized arrays
Fixes #1952

* Prevent scalarization of arrays that are sized by a specialization
constant
2018-10-04 11:58:23 -04:00
Steven Perron
19c07731fc
Change handling of unknown extentions in validtor. (#1951)
This commit will change the message for unknown extensions from an error
to a warning.

Code was added to limit the number of warning messages so that consummer
of the messages are not overwhelmed.  This is standard practice in
compilers.

Many other issues were found at while looking into this. They have been
documented in #1950.

Fixes http://crbug.com/875547.
2018-10-03 15:59:40 -04:00
Jaebaek Seo
d73b9d8dfb [Validator] AMD_gpu_shader_half_float_fetch allow float16 (#1393)
SPV_AMD_gpu_shader_half_float_fetch extension should implicitly
allow declaring 16bit float.
2018-10-02 16:06:13 -04:00
Jaebaek Seo
37c99ab7e5 Validator: OpImageQuerySize validation (#1538)
Validation of OpImageQuerySize is missing that is a TODO. This
commit implements its validation based on the spec.
2018-10-02 15:53:52 -04:00
Alan Baker
a77bb2e54b Add validation for execution modes
* Check rules from Execution Mode tables, 2.16.2 and the Vulkan
environment spec

* Allows MeshNV execution model with the following execution modes
 * LocalSize, LocalSizeId, OutputPoints and OutputVertices
 * Done to not break their validation
2018-10-02 10:22:23 -04:00
Steven Perron
146eb3bdcf
Fix erroneous uses of the type manager in copy-prop-arrays. (#1942)
There are a few spots where copy propagate arrays is trying
to go from a Type to an id, but the type is not unique.  When generating
code this pass needs specific ids, otherwise we get type mismatches.
However, the ambigous types means we can sometimes get the wrong type
and generate invalid code.

That code has been rewritten to not rely on the type manager, and just
look at the instructions instead.

I have opened https://github.com/KhronosGroup/SPIRV-Tools/issues/1939 to
try to get a way to make this more robust.
2018-10-01 14:45:44 -04:00
Jeff Bolz
fe90a1d2dc Enable /MP4 (parallel build across 4 cores for MSVC) for SPIRV-Tools/source[/opt] (#1930) 2018-10-01 10:47:39 -04:00
Steven Perron
ddc705933d
Analyze uses for all instructions. (#1937)
* Analyze uses for all instructions.

The def-use manager needs to fill in the `inst_to_used_ids_` field for
every instruction.  This means we have to analyze the uses for every
instruction, even if they do not have any uses.

This mistake was not found earlier because there was a typo in the
equality check for def-use managers.  No new tests are needed.

While looking into this I found redundant work in block merge.  Cleaning
that up at the same time.

* Fix other transformations

Aggressive dead code elimination did not update the OpGroupDecorate
and the OpGroupMemberDecorate instructions properly when they are
updated.  That is fixed.

Dead branch elimination did not analyze the OpUnreachable instructions
that is would add.  That is taken care of.
2018-09-28 14:39:06 -04:00
Steven Perron
32381e30ef
Handle decoration groups with no decorations. (#1921)
In DecorationManager::RemoveDecorationsFrom, we do not remove the id
from a decoration group if the group has no decorations.  This causes
problems because KillNamesAndDecorates is suppose to remove all
references to the id, but in this case, there is still a reference.

This is fixed by adding a special case.

Also, there is the possibility of a double free because
RemoveDecorationsFrom will delete the instructions defining |id| when
|id| is a decoration group.  Later, KillInst would later write to memory
that has been deleted when trying to turn it into a Nop.  To fix this,
we will only remove the decorations that use |id| and not its definition
in RemoveDecorationsFrom.
2018-09-28 14:16:04 -04:00
Jaebaek Seo
f0aa6f4e3a Fixed Validator adjacency bug for OpPhi (#1922)
OpPhi instruction must appear before all non-OpPhi instructions
except for OpLine. Without this commit, Validator does not check
the case that an OpPhi is preceeded by an OpLine and the OpLine is
preceeded by a non-OpPhi instruction that is not OpLine.
2018-09-28 12:40:57 -04:00
alan-baker
ad0232dee5 Unify memory instruction validation style (#1934)
* Rename ValidateMemoryInstructions to MemoryPass
* Changed functions to take pointer to an instruction instead of
reference
2018-09-27 12:34:14 -04:00
Jaebaek Seo
4b4bd4c53a Validator: Validate OpImageTexelPointer (#487)
Checked all instructions whose object is OpTypeSampledImage or
OpTypeImage as suggested in #487. OpImageTexelPointer instruction
is missing and others look good. This commit adds only
OpImageTexelPointer.
2018-09-27 09:53:30 -04:00
Steven Perron
80564a56ec
Keep analyses live in unrolling (#1929)
Add code to keep the def-use manger and the inst-to-block mapping up-to-date. This means we do not have to rebuild them later.

To make this work, we will have to have to find places to update the
def-use manager. Updating the def-use manager is not straight forward
because we are unrolling loops, and we have circular references.

This forces one pass to register all of the definitions. A second one
to analyze the uses. Also because there will be references to the new
instructions in the old code, we want to register the definitions of the
new instructions early, so we can update the uses of the older code as
we go along.

The inst-to-block mapping is not too difficult. It can be done as instructions are created.

Fixes #1928.
2018-09-26 17:36:27 -04:00
Lei Zhang
1225324ae2
VK_KHR_shader_atomic_int64 covers OpAtomic{Load|Store} 2018-09-26 16:45:37 -04:00
Jaebaek Seo
026309ab27 Validator: OpGroupNonUniformBallotBitCount validation (#1486) 2018-09-26 15:52:39 -04:00
Steven Perron
0e5fc7d75e
Allow 0 as argument to scalar replacement. (#1917)
A limit of 0 for the scalar replacement options it used to indicate that
there is no limit.  The current implementation does not allow 0.  This
should be fixed.
2018-09-26 09:58:28 -04:00
Steven Perron
b85fb4a300
Get KillNameAndDecorates to handle group decorations. (#1919)
It seems like the current implementation of KillNameAndDecorates does
not handle group decorations correctly.  The id being removed is not
removed from the OpGroupDecorate instructions.  Even worst, any
decorations that apply to that group are removed.

The solution is to use the function in the decoration manager that will
remove the decorations and update the instructions instead of doing the
work itself.
2018-09-25 12:57:44 -04:00
Alan Baker
90a12b3d4d Decoration validation for Vulkan memory model
* Adds a check that using Coherent or Volatile decorations with the
Vulkan memory model is a validation error
 * Adds tests
2018-09-21 21:55:01 -04:00
Alan Baker
1492111332 Validate vulkan mem model capabilty
* Check that if the VulkanMemoryModelKHR capability is specified that
the memory model must be VulkanKHR
 * added tests
2018-09-21 21:50:20 -04:00
Chao Chen
6e2dab2ffd Add support for Nvidia Turing extensions 2018-09-19 20:46:14 -04:00
Steven Perron
9fbcce4ca1
Add unrolling to the legalization passes (#1903)
Adds unrolling to the legalization passes.

After enabling unrolling I found a bug when there is a self-referencing
phi node.  That has been fixed.

The test that checks for that the order of optimizations is correct also
needed to be updated.
2018-09-19 16:40:09 -04:00
Jaebaek Seo
0cd3e599ae Validator: correct out of bound check for OpMemberDecorate (#1881)
The number that indicates a member in OpMemberDecorate must be less
than the number of total members of struct.
2018-09-18 10:16:46 -04:00
Steven Perron
7f0a8877a2
Move the registration of decorations. (#1895)
We currently register decorations in the first pass through the
instructions.  This is a problem because the validator has not even
checked if the decoration instructions are valid yet.  This can lead to
unexpected behaviour from these side table.  For example, in
https://github.com/KhronosGroup/SPIRV-Tools/issues/1882, we use 5GB of
data to store 1 decoration for ids that are not even defined.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1882.
2018-09-18 08:53:09 -04:00
Steven Perron
7075c49923
Add dummy loop in merge-return. (#1896)
The current implementation of merge return can create bad, but correct,
code.  When it is not in a loop construct, it will insert a lot of
extra branch around code.  The potentially large number of branches are
bad.  At the same time, it can separate code store to variables from
its uses hiding the fact that the store dominates the load.

This hurts the later analysis because the compiler thinks that multiple
values can reach a load, when there is really only 1.  This poorer
analysis leads to missed optimizations.

The solution is to create a dummy loop around the entire body of the
function, then we can break from that loop with a single branch.  Also
only new merge nodes would be those at the end of loops meaning that
most analysies will not be hurt.

Remove dead code for cases that are no longer possible.

It seems like some drivers expect there the be an OpSelectionMerge
before conditional branches, even if they are not strictly needed.
So we add them.
2018-09-18 08:52:47 -04:00
Steven Perron
5f599e700e
Fix infinite loop in dead-branch-elimination (#1891)
* Create structed cfg analysis.

There are lots of optimization that have to traverse the CFG in a
structured order just because it wants to know which constructs a
basic block in contained in.  This adds extra complexity to these
optimizations, for causes too much refactoring of older optimizations.

To help with this problem, I have written an analysis that can give this
information.

* Identify branches breaking from loops.

Dead branch elimination does a search for a conditional branch to the
end of the current selection construct.  This search assumes that the
only way to leave the construct is through the merge node.  But that is
not true.  The code can jump to the merge node of a loop that contains
the construct.

The search needs to take this into consideration.
2018-09-17 13:00:24 -04:00
Diego Novillo
4a4632264e Add IR dumping functions to use during debugging.
When using lldb and/or gdb I frequently get odd std::string failures
when using the IR printing instructions we have now.  This adds the
methods  Instruction::Dump(), BasicBlock::Dump() and Function::Dump() to
emit the output of the pretty print to stderr.

With this I can now reliably print IR from gdb and lldb sessions.
2018-09-14 14:28:34 -04:00
Lei Zhang
63265097e5
Add support for VK_KHR_shader_atomic_int64 in validator 2018-09-14 14:07:25 -04:00
Steven Perron
6d5f1bc2e8
Allow merge blocks to merge two header blocks in some cases. (#1890)
In merge blocks, we do not allow the merging of two blocks with merge
instructions.  This is because if the two block are merged only 1 of
those instructions can exists.  However, if the successor block is the
merge block of the predecessor, then we can delete the merge instruction
in the predecessor.  In this case, we are able to merge the blocks.
2018-09-14 13:37:18 -04:00
Jaebaek Seo
2c2fee7979 Validator: check OpTypeBool inside Blocks (#1405)
OpTypeBool can only be used with non-externally visible shader
Storage Classes: Workgroup, CrossWorkgroup, Private, and Function.
2018-09-10 13:33:13 -04:00
Steven Perron
75c1bf2843
Add option for the max id bound. (#1870)
* Create a new entry point for the optimizer

Creates a new struct to hold the options for the optimizer, and creates
an entry point that take the optimizer options as a parameter.

The old entry point that takes validator options are now deprecated.
The validator options will be one of the optimizer options.

Part of the optimizer options will also be the upper bound on the id bound.

* Add a command line option to set the max value for the id bound.  The default is 0x3FFFFF.

* Modify `TakeNextIdBound` to return 0 when the limit is reached.
2018-09-10 11:49:41 -04:00
Steven Perron
f62d7978fc
Add validation check for arrays of void type. (#1880)
In the definition of an array
(https://www.khronos.org/registry/spir-v/specs/1.2/SPIRV.html#Array),
it specfically mentions that array elements have non-void type.  I've
added a check for that in this PR.

http://crbug.com/879016
2018-09-10 09:21:32 -04:00
David Neto
571251c8f8 Support SPV_KHR_vulkan_memory_model rev2
Support collapsed into one commit:
- Asm/Dis support for SPV_KHR_vulkan_memory_model
- Add Vulkan mem model image operands to switch
- Add TODO for source/validate_image.cpp
- val: Image operands NonPrivateTexelKHR, VolatileTexelKHR have no operands
  This is required for memory model tests to pass SPIR-V validation.
- Round trip tests: Test new flags on OpCopyMemory*
2018-09-06 13:30:32 -04:00
Alan Baker
cb0f1f565b Remove struct member offset monotonicity check
Fixes #1822

* Remove check that struct member offsets must be monotonic
 * All environments match Vulkan behaviour now
 * updated offending tests
2018-08-31 09:45:45 -04:00
Steven Perron
482b1744ca
Validate all type ids. (#1868)
* Validate all type ids.

The validator does not check if the type of an instruction is actually
a type unless the OpCode has a specific requirement.  For example,
OpFAdd is checked, but OpUndef is not.

The commit add a generic check that if there is a type id then the id
defines a type.

http://crbug.com/876694

* Merge other checks for type into new one.

There are a couple check that the type id is a type for specific
opcodes.  Those have been mereged into 1.

Small changes to other test cases to make them valid enough for the
purpose of the test.
2018-08-27 23:45:32 -04:00
Steven Perron
06b42949b6
Validate uses of OpTypeFunction. (#1867)
In the specification of `OpTypeFunction`, it says

> OpFunction is the only valid use of OpTypeFunction.

This commit add a check in the validator for this rule.

A test started to fail because the new check happens before the check
the test case is testing.  Updated the test case to still fail the
check it was suppose to fail originally.

http://crbug.com/874571
2018-08-27 11:41:25 -04:00
alan-baker
d94a2077d6
Remove idUsage
* Moved remaining validation out of idUsage and deleted it
* Deleted unused functions
2018-08-27 11:06:09 -04:00
Steven Perron
416b1ab4f3
Have the constant manager take ownership of constants. (#1866)
* Have the constant manager take ownership of constants.

Right now the owner of an object of type contant that is in the
|const_pool_| of the constant manager is unclear.  The constant
manager does not delete them, there is no other reasonable owner.  This
causes memory leaks.

This change fixes the memory leaks by having the constant manager
take ownership of the constant that is stores in |const_pool_|.  Other
changes include interface changes to make it explicit that the constant
manager takes ownership of the object when a constant is registered
with the constant manager.

Fixes #1865.
2018-08-27 09:53:47 -04:00
Steven Perron
47ee776a2c Revert "Have the constant manager take ownership of constants."
This reverts commit b938b74bac.
2018-08-24 15:12:49 -04:00
Steven Perron
b938b74bac Have the constant manager take ownership of constants.
Right now the owner of an object of type contant that is in the
|const_pool_| of the constant manager is unclear.  The constant
manager does not delete them, there is no other reasonable owner.  This
causes memory leaks.

This change fixes the memory leaks by having the constant manager
take ownership of the constant that is stores in |const_pool_|.  Other
changes include interface changes to make it explicit that the constant
manager takes ownership of the object when a constant is registered
with the constant manager.
2018-08-24 15:08:12 -04:00
Steven Perron
d746681fe9
Copy decorations when creating new ids. (#1843)
* Copy decorations when creating new ids.

When creating a new value based on an old value, we need to copy the
decorations to the new id.  This change does this in 3 places:

1) The variable holding the return value of the function generated by
merge return should get decorations from the function.

2) The results of the OpPhi instructions should get decorations from the
variable they are replacing in the ssa writer.

3) In local access chain convert the intermediate struct (result of
OpCompositeInsert) generated for the store replacement should get its
decorations from the variable being stored to.

Fixes #1787.
2018-08-24 11:55:39 -04:00
Alan Baker
6d27a8350f Fixing instances of iteration over unordered containers
* There were several instances found in the validator
 * validate_id.cpp
 * validate_decorations.cpp
 * validate_interfaces.cpp
2018-08-23 14:49:10 -04:00
Steven Perron
b4d3618f77
Don't "break" from selection constructs. (#1862)
If seems like at least 1 driver does not like a condition jump to the end
of a selection construct.  We are generating these in the merge return
pass.  This change stops merge return from generating this sequence.

Part of #1861.
2018-08-23 14:38:25 -04:00
Steven Perron
6c73b1fb70
Update the order when predicating blocks. (#1859)
When doing predicate blocks, we need to traverse every block in
structured order in order to keep track of which construct a block is
contained in.  The standard way of traversing code in structured order
is to create a list with all of the nodes in order.  However, when
predicating blocks, new blocks are created, and those blocks are missed.
This causes branches that go too far.

The solution is to update the order as new blocks are created.  Since
we are using an std::list, we do not have to worry about invalidation of
iterators when changing the list.
2018-08-23 12:59:31 -04:00
Alan Baker
c5b38062ec Moving constant opcode validation into a new file
* Split constant opcode validation out of idUsage and into
validate_constants.cpp
 * minor style fixes
 * reduced duplication
 * fixed an issue with array sizing
2018-08-21 17:30:26 -04:00
Steven Perron
d91d34e150
Fix VS2013 build break. (#1853) 2018-08-21 13:50:47 -04:00
Steven Perron
19264ef42c
Have PredicateBlocks jump the existing merge blocks. (#1849)
* Refactor PredicateBlocks

Refactor PredicateBlocks so that we know which constructs a return
is contained in.  Will be used later.

* Have PredicateBlocks jump the existing merge blocks.

In PredicateBlocks, we currently skip instructions with side effects,
but it still follows the same control flow (sort-of).  This causes a
problem, when we are trying to predicate code in a loop.  We skip all
of the code with side effects (IV increment), but still follow the
same control flow (jump back the start of the loop).  This creates an
infinite loop because the code will keep jumping back to the start of
the loop without changing the values that effect the exit condition.

This is a large change to merge-return.  When predicating a block that
is in a loop or merge construct, it will jump to the merge block of the
construct.  Once out of all constructs we will generate code as we did
before.
2018-08-21 12:04:08 -04:00
Alan Baker
197b4597a0 Fix EvalInt32IfConst to fail on type instructions.
Fixes https://crbug.com/875842

* EvalInt32IfConst dereferenced a null pointer if a type instruction was
sent as the id
2018-08-21 11:59:00 -04:00
Steven Perron
d693a83e36
Handle breaks from structured-ifs in DCE. (#1848)
* Handle breaks from structured-ifs in DCE.

dead code elimination assumes that are conditional branches except for
breaks and continues in loops will have an OpSelectionMerge before them.
That is not true when breaking out of a selection construct.

The fix is to look for breaks in selection constructs in the same place
we look for breaks and continues for loops.
2018-08-21 11:54:44 -04:00
Steven Perron
45c235d41f
Have dead-branch-elim handle conditional exits from selections. (#1850)
When dead-branch-elim folds a conditional branch, it also deletes the
OpSelectionMerge instruction.  If that construct contains a
conditional branch to the merge node, it will not have its own
OpSelectionMerge.  When the headers merge instruction is deleted, the
the inner conditional branch will no longer be legal.  It will be a
selection to a node that is not a merge node.

We fix this up by moving the OpSelectionMerge to a new location if it is
still needed.
2018-08-21 11:49:56 -04:00
Diego Novillo
03000a3a38 Add testing framework for tools.
This forks the testing harness from https://github.com/google/shaderc
to allow testing CLI tools.

New features needed for SPIRV-Tools include:

1- A new PlaceHolder subclass for spirv shaders.  This place holder
   calls spirv-as to convert assembly input into SPIRV bytecode. This is
   required for most tools in SPIRV-Tools.

2- A minimal testing file for testing basic functionality of spirv-opt.

Add tests for all flags in spirv-opt.

1. Adds tests to check that known flags match the names that each pass
   advertises.
2. Adds tests to check that -O, -Os and --legalize-hlsl schedule the
   expected passes.
3. Adds more functionality to Expect classes to support regular
   expression matching on stderr.
4. Add checks for integer arguments to optimization flags.
5. Fixes #1817 by modifying the parsing of integer arguments in
   flags that take them.
6. Fixes -Oconfig file parsing (#1778). It reads every line of the file
   into a string and then parses that string by tokenizing every group of
   characters between whitespaces (using the standard cin reading
   operator).  This mimics shell command-line parsing, but it does not
   support quoting (and I'm not planning to).
2018-08-17 15:03:14 -04:00
Steven Perron
36d675a404
Change when instruction is registered in validator. (#1840)
When doing the validator checks, an instruction is currently registered
at the end of IdPass.  This creates an inconsistency.  In IdPass, an
instruction that uses its own result will treat that use as a forward
reference.  Then in the following passes it will not because the
definition can be found.

It seems best to update the state after all of the check have been done
for the current instruction.  This makes it consistent for all of the
passes.

This makes a different when trying to verify OpTypeStruct.

Fixes https://crbug.com/874372.
2018-08-15 13:18:47 -04:00
Steven Perron
e065cc208f
Keep decorations when replacing loads in access-chain-convert. (#1829)
In local-access-chain-convert, we replace loads by load the entire
variable, then doing the extract.  The extract will have the same value
as the load.  However, if the load has a decoration on it, the
decoration is lost because we do not copy any them to the new id.

This is fixed by rewritting the load into the extract and keeping the
same result id.

This change has the effect that we do not call DCEInst on the loads
because the load is not being deleted, but replaced.  This could leave
OpAccessChain instructions around that are not used.  This is not a
problem for -O and -Os.  They run local_single_*_elim passes and then
dead code elimination.  The dce will remove the unused access chains,
and the load elimination passes work even if there are unused access
chains.  I have added test to them to ensure they will not loss
opportunities.

Fixes #1787.
2018-08-15 09:14:21 -04:00
dan sinclair
ef678672fb
Remove source/message.h (#1838)
The code in source/message was only used in a single set of tests to
format the output results. This CL changes the test to verify the
message instead of all the error values and removes the source/message
code.
2018-08-14 15:41:21 -04:00
dan sinclair
1963a2dbda
Use MakeUnique. (#1837)
This CL replaces instances of reset(new ..) with MakeUnique.
2018-08-14 15:01:50 -04:00
dan sinclair
1553025f4c
Move make_unique to source/util. (#1836)
This MakeUnique code is used in places other then source/opt so move it
to source/utils.
2018-08-14 12:44:54 -04:00
Steven Perron
bf24d9b4ac
Don't copy decorations twice when rebuilding a type. (#1835)
In `TypeManager::RebuildType`, the base cases call `Clone`, which will
copy the decorations for the type.  After that it breaks out of the
switch statement and copies the decorations again.

This has not causes any real problems yet because none of those types
are allowed to have decorations.  However to make the code more robust
it is best to not copy twice because it should be empty.

This way if a new base type or decoration is added that changes this
rule the code will be correct.
2018-08-14 11:26:14 -04:00
Alan Baker
8cb949ad34 Validate correct opcode uses of OpFunction
Fixes https://crbug.com/873457

* Filed Khronos SPIR-V issue 352
* Updated bad tests
* Added new test
2018-08-14 10:13:06 -04:00
dan sinclair
5fc011b453
Move bit_stream, move_to_front and huffman_codec. (#1833)
bit_stream, move_to_front and huffman_codec are only used by
source/tools. Move into that directory to make the usage clearer.
2018-08-14 09:52:05 -04:00
alan-baker
ce4547bdc7
Disallow void types in structs (#1832)
Fixes #1831

* Adds validation check that void is not a member of a struct
 * added a test
2018-08-14 08:55:49 -04:00
Alan Baker
e7fdcdba75 Split function opcode validation into new files.
* Moved function opcode validation out of idUsage and into new files
 * minor style changes
 * General opcode checking is in validate_function.cpp
 * Execution limitation checking is in
 validate_execution_limitations.cpp
* Execution limitations was split into a new pass as it requires other
validation to register those limitations first.
2018-08-13 17:04:57 -04:00
Alan Baker
397e02442e Fixing heap overflow in validation.
* Changed entry point validation to check storage class of variable
instead of pointer
 * added a test
* Moved several checks after opcode validation
 * These checks should be able to guarantee individual instructions are
 ok
* Updated tests due to reordered checks
2018-08-13 15:23:30 -04:00
Steven Perron
bcb0b6935c
Reenable --skip-validation. (#1820)
In previous changes, the option `--skip-validation` was disabled.  This
change is to reenable it.
2018-08-13 13:18:46 -04:00
dan sinclair
da0f1dcccc
Move spirv_stats into tools/stats. (#1826)
The spirv_stats code is only used by the tools/stats module. This CL
moves the code to that module.
2018-08-13 11:48:25 -04:00
Alan Baker
6cd4441c87 Move cfg opcode validation to another file.
* Moved cfg opcode validation out of idUsage and into validate_cfg.cpp
 * minor style updates
2018-08-13 11:30:08 -04:00
dan sinclair
b6319c3a43
Split MarkV into multiple files (#1809)
This CL breaks the monolithic markv_codec file into files for the base
class, encoder, decoder and logger.
2018-08-09 17:07:19 -04:00
Alan Baker
714bf84e58 Split mode setting opcode validation into new file.
* Moved mode setting opcode validation out of idUsage and into a new
pass
 * minor style updates
2018-08-08 15:45:53 -04:00
Alan Baker
7d4b0464a3 Split annotation opcode validation into new file.
* Moves annotation opcode checks from idUsage into a new pass
 * minor style updates
2018-08-08 15:43:11 -04:00
Alan Baker
983f8f02de Replace asserts with returns
* Changes to satisfy fuzzer
2018-08-08 15:13:04 -04:00
Alan Baker
ca7278cff7 Split debug opcode validation into new file
* Removes debug opcode validation from idUsage and puts it in a separate
file
 * minor updates
2018-08-08 13:47:09 -04:00
Alan Baker
f2a990022a Move type instruction validation into separate file
* Moved type instruction validation out of validation idUsage into a new
file
* Consolidate type unique pass into new file
* Removed one bad test
* Reworked validation ordering
2018-08-08 12:55:39 -04:00
Steven Perron
5c8b4f5a1c
Validate the input to Optimizer::Run (#1799)
* Run the validator in the optimization fuzzers.

The optimizers assumes that the input to the optimizer is valid.  Since
the fuzzers do not check that the input is valid before passing the
spir-v to the optimizer, we are getting a few errors.

The solution is to run the validator in the optimizer to validate the
input.

For the legalization passes, we need to add an extra option to the
validator to accept certain types of variable pointers, even if the
capability is not given.  At the same time, we changed the option
"--legalize-hlsl" to relax the validator in the same way instead of
turning it off.
2018-08-08 11:16:19 -04:00
Alan Baker
3a20879f4d Unify validation of OpCopyMemory*
Fixes #1800

* Refactored duplication of code between OpCopyMemory and
OpCopyMemorySized validation
* Fixed some bugs in OpCopyMemorySized validation
* Replaced asserts with checks
* Added new tests
2018-08-07 19:01:58 -04:00
Alan Baker
2896b8f0e5 Refactor where opcodes are validated
* Replaced uses in opcode validation of current_function()
* Added non-const accessor to function lookup in ValidationState_t
* Updated a couple bad tests due to check reordering
2018-08-07 10:29:30 -04:00
dan sinclair
508df9a387
Remove unused bit stream methods. (#1807)
This CL deletes methods from bit stream which are never used and moves
several to the anonymous namespace in the bit_stream test file.
2018-08-07 09:10:54 -04:00
dan sinclair
e3ea909ebe
Simplify MoveToFront (#1806)
This CL removes the templating from the MoveToFront code as all non-test
code uses uint32_t as the variable.
2018-08-07 09:10:25 -04:00
dan sinclair
9991d661f8
Fix readbility/braces warnings (#1804) 2018-08-07 09:09:47 -04:00
dan sinclair
eda2cfbe12
Cleanup includes. (#1795)
This Cl cleans up the include paths to be relative to the top level
directory. Various include-what-you-use fixes have been added.
2018-08-03 15:06:09 -04:00
dan sinclair
58a6876cee
Rewrite include guards (#1793)
This CL rewrites the include guards to make PRESUBMIT.py include guard
check happy.
2018-08-03 08:05:33 -04:00
dan sinclair
d38a0a3b44
Validation within function body when doing a FunctionCall. (#1790)
When validating a FunctionCall we can trigger an assert if we are not
currently within a function body. This CL adds verification that we are
within a function before attempting to add a function call.

Issue 1789.
2018-08-02 16:58:45 -04:00
dan sinclair
6aa8a59415
Simplify validation ProcessInstruction (#1786)
This CL moves most of the logic out of validation ProcessInstruction and
groups it into validate. This places all of the validation logic in the
same place making it clearer what is running.

The Instruction class is changed to allow setting the function and block
after creation.
2018-08-02 15:12:06 -04:00
dan sinclair
1946fb4ddb
Remove ValidateInstructionAndUpdateValidationState (#1784)
This CL changes the stats aggregator to use
ValidateBinaryAndKeepValidationState to process the binary. This means
we can remove ValidateInstructionAndUpdateValidationState which expects
to be able to call ProcessInstruction in the validate anonymous
namespace. This decouples the stats aggregator from how validation
processes the binary.
2018-08-02 12:01:26 -04:00
Steven Perron
ce644d4a24
Update OpPhi instructions after splitting block. (#1783)
In the merge return pass, we will split a block, but not update the phi
instructions that reference the block.  Since the branch in the original
block is now part of the block with the new id, the phi nodes must be
updated.

This commit will change this.

I have also considered other places where an id of a basic block could
be referenced, and I don't think any of them need to change.

1) Branch and merge instructions: These jump to the start of the
original block, and so we want them to jump to the block that uses the
original id.  Nothing needs to change.

2) Names and decorations: I don't think it matters with block keeps the
name, and there are no decorations that apply to basic blocks.

Fixes #1736.
2018-08-02 11:02:50 -04:00
dan sinclair
53afb3b77b
Combine ordered_instruction loops in validation. (#1782)
There are several validation passes which loop over all ordered
instructions. This CL combines those into a single loop, calling each
pass as needed.
2018-08-02 10:00:52 -04:00
dan sinclair
c9cd73b33a
Remove instruction_counter from ValidationState. (#1781)
The instruction counter is the same as the size of the
ordered_instruction list when we insert a new instruction. This Cl
removes instruction_counter_ and uses that instead.
2018-08-01 16:12:07 -04:00
Alan Baker
d49bedcaa6 Move memory class instructions to new pass
* Refactored the Memory class of instructions in the spec out Id
validation and into a new pass
 * Tests unmodified
 * some minor disassembly changes
 * minor style changes
2018-08-01 16:10:11 -04:00
dan sinclair
a5a5ea0e2d
Remove using std::<foo> statements. (#1756)
Many of the files have using std::<foo> statements in them, but then the
use of <foo> will be inconsistently std::<foo> or <foo> scattered
through the file. This CL removes all of the using statements and
updates the code to have the required std:: prefix.
2018-08-01 14:58:12 -04:00
dan sinclair
ebd6c75a71
Remove diag() overloads. (#1776)
This CL removes the two diag() overloads and leaves only the version
which accepts an Instruction. This is safer as we never use the
implicit location from the validation state.
2018-08-01 14:55:20 -04:00
dan sinclair
aa81e62cbe
Update diag() calls in validate_capability. (#1759)
This CL updates the diag() call in validate_capability to provide the
instruction.
2018-08-01 13:48:16 -04:00
Steven Perron
c8c724cba7
Don't change decorations and names in merge return. (#1777)
When creating a new phi for a value in the function, merge return will
rewrite all uses of an id that are no longer dominated by its
definition.  Uses that are not in a basic block, like OpName or
decorations, are not dominated, but they should not be replaced.

Fixes #1736.
2018-08-01 13:47:09 -04:00