Lei Zhang [Tue, 5 Dec 2017 15:55:00 +0000 (10:55 -0500)]
CMake: allow both SPIRV-Headers and spirv-headers
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1057
Andrey Tuganov [Tue, 5 Dec 2017 15:15:51 +0000 (10:15 -0500)]
Add composite instruction validation pass
Validates instructions in the opcode range from OpVectorExtractDynamic
to OpTranspose.
Lei Zhang [Tue, 5 Dec 2017 03:43:26 +0000 (22:43 -0500)]
Do not zip and deploy for check formatting
Lei Zhang [Tue, 5 Dec 2017 00:39:00 +0000 (19:39 -0500)]
Go back to root directory
Lei Zhang [Fri, 1 Dec 2017 03:24:13 +0000 (22:24 -0500)]
Travis CI: add clang-format check
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1029
Diego Novillo [Mon, 4 Dec 2017 20:41:41 +0000 (15:41 -0500)]
Update .appveyor.yml
Andrey Tuganov [Mon, 4 Dec 2017 17:50:47 +0000 (12:50 -0500)]
Fix some of the known issues in image validation
Applied some of the spec clarifications made in conversation with
@johnkslang.
Steven Perron [Mon, 4 Dec 2017 17:29:51 +0000 (12:29 -0500)]
DCEInst kill the same instruction twice.
In DCEInst, it is possible that the same instruction ends up in the
queue multiple times, if the same id is used multiple times in the
same instruction.
The solution is to keep the ids in a set, to ensure no duplication in
the list.
Diego Novillo [Mon, 4 Dec 2017 20:45:56 +0000 (15:45 -0500)]
Change Release builds to Release with debug info on Linux
For Linux builds, we want to add debug information on the generated binary (for timing and profiling purposes). This patch changes Release builds to RelWithDebInfo.
Diego Novillo [Mon, 4 Dec 2017 20:28:21 +0000 (15:28 -0500)]
Remove cfg_ field from SSAPropagator class - NFC.
When I moved the CFG into IRContext
(https://github.com/KhronosGroup/SPIRV-Tools/pull/1019), I forgot to
update SSAPropagator to stop requiring one.
Fixed with this patch.
Steven Perron [Tue, 21 Nov 2017 19:47:46 +0000 (14:47 -0500)]
Change IRContext::KillInst to delete instructions.
The current method of removing an instruction is to call ToNop. The
problem with this is that it leaves around an instruction that later
passes will look at. We should just delete the instruction.
In MemPass there is a utility routine called DCEInst. It can delete
essentially any instruction, which can invalidate pointers now that they
are actually deleted. The interface was changed to add a call back that
can be used to update any local data structures that contain
ir::Intruction*.
Steven Perron [Mon, 27 Nov 2017 20:07:34 +0000 (15:07 -0500)]
Compute value number when the value table is constructed.
Computing the value numbers on demand, as we do now, can lead to
different results depending on the order in which the users asks for
the value numbers. To make things more stable, we compute them ahead
of time.
Daan Wendelen [Sun, 3 Dec 2017 20:27:21 +0000 (21:27 +0100)]
Fixed typo that leaked to the binary
The typo was found by lintian when I was packaging glslang
Diego Novillo [Fri, 1 Dec 2017 18:10:34 +0000 (13:10 -0500)]
Add simplified instructions for pushing a reviewed PR.
Lei Zhang [Fri, 1 Dec 2017 04:06:55 +0000 (23:06 -0500)]
Travis: mark MacOS builds as optional
MacOS support in Travis is flakey right now. MacOS build jobs
take a long time to start.
We have extensive checks for Linux and Windows, which should give
us confidence.
Diego Novillo [Fri, 1 Dec 2017 17:17:47 +0000 (12:17 -0500)]
Re-format CONTRIBUTING.md - NFC.
I'm about to change this file. I re-formatted it for easier editing.
Lei Zhang [Thu, 30 Nov 2017 23:01:11 +0000 (18:01 -0500)]
Fix Dref type check in validator
Dref should be of 32-bit scalar floating type.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1012
Lei Zhang [Fri, 1 Dec 2017 02:12:23 +0000 (21:12 -0500)]
Appveyor: use ninja instead of MSBuild
Pierre Moreau [Thu, 30 Nov 2017 21:32:44 +0000 (22:32 +0100)]
Opt: Remove unused lambda captures
Those are reported as errors by clang 5.0.0, due to the flags -Werror
and -Wunused-lambda-capture.
Lei Zhang [Thu, 30 Nov 2017 21:35:22 +0000 (16:35 -0500)]
Support outputting ANSI color escape sequences in library
Previously we required _PRINT to enable _COLOR, which forbids
outputting colored disassembly into a string in library.
This commit will allow library users to request enabling
ANSI color escape sequences.
David Neto [Wed, 29 Nov 2017 20:58:35 +0000 (15:58 -0500)]
Erase decorations removed from internal collections
Fixes Android arm-64-v8a build with NDK r14. That's because
we no longer ignore the result of the std::remove.
David Neto [Fri, 24 Nov 2017 19:18:17 +0000 (14:18 -0500)]
Fix validation of group ops in SPV_AMD_shader_ballot
This needs custom code since the rules from the extension
are not encoded in the grammar.
Changes are:
- The new group instructions don't require Group capability
when the extension is declared.
- The Reduce, InclusiveScan, ExclusiveScan normally require the Kernel
capability, but don't when the extension is declared.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/991
Diego Novillo [Wed, 29 Nov 2017 18:36:17 +0000 (13:36 -0500)]
Fix #1034 - Give Edge::operator<() weak ordering semantics.
This should fix #1034. It changes the predicate on operator< to use
label IDs from each block and compares them as std:pair to define a weak
ordering for std::set.
Andrey Tuganov [Wed, 22 Nov 2017 21:57:37 +0000 (16:57 -0500)]
Validate OpTypeImage and OpTypeSampleImage
Added new validation rules to the validate image pass.
Daniel Schürmann [Wed, 29 Nov 2017 13:38:27 +0000 (14:38 +0100)]
Linker: Fix incorrect exit status.
Steven Perron [Fri, 24 Nov 2017 14:33:18 +0000 (09:33 -0500)]
Create CONTRIBUTING.md
This is intended to be a document that people who want to help the project
can get a quick overview of how things are done. Please comment and suggest
any changes.
GregF [Tue, 28 Nov 2017 23:18:05 +0000 (16:18 -0700)]
AggressiveDCE: Add merge and continue branches for live loop.
This ensures that an if-break is not eliminated from a loop.
This fixes issue #989
Lei Zhang [Mon, 27 Nov 2017 22:51:18 +0000 (17:51 -0500)]
Update README about the automatic master-tot relase
Diego Novillo [Mon, 27 Nov 2017 19:20:32 +0000 (14:20 -0500)]
Convert the CFG to an on-demand analysis - NFC.
This fixes some TODOs by moving the CFG into the IRContext as an
analysis.
Diego Novillo [Tue, 28 Nov 2017 13:27:10 +0000 (08:27 -0500)]
Fix windows build. unsigned vs signed comparison in EXPECT_EQ.
Diego Novillo [Fri, 17 Nov 2017 13:59:25 +0000 (08:59 -0500)]
Generic value propagation engine.
This class implements a generic value propagation algorithm based on the
conditional constant propagation algorithm proposed in
Constant propagation with conditional branches,
Wegman and Zadeck, ACM TOPLAS 13(2):181-210.
The implementation is based on
A Propagation Engine for GCC
Diego Novillo, GCC Summit 2005
http://ols.fedoraproject.org/GCC/Reprints-2005/novillo-Reprint.pdf
The purpose of this implementation is to act as a common framework for any
transformation that needs to propagate values from statements producing new
values to statements using those values.
Diego Novillo [Mon, 27 Nov 2017 19:40:03 +0000 (14:40 -0500)]
Fix windows build.
This fixes the lack of uint32_t definition in source/val/decoration.h.
Diego Novillo [Mon, 27 Nov 2017 15:16:41 +0000 (10:16 -0500)]
Re-format source tree - NFC.
Re-formatted the source tree with the command:
$ /usr/bin/clang-format -style=file -i \
$(find include source tools test utils -name '*.cpp' -or -name '*.h')
This required a fix to source/val/decoration.h. It was not including
spirv.h, which broke builds when the #include headers were re-ordered by
clang-format.
Andrey Tuganov [Fri, 24 Nov 2017 15:29:05 +0000 (10:29 -0500)]
Derivative opcodes require Fragment exec model
Added validator check that all derivative opcodes require Fragment
execution model.
Andrey Tuganov [Fri, 24 Nov 2017 15:55:05 +0000 (10:55 -0500)]
Relaxed OpImageWrite texel type check
David Neto [Fri, 24 Nov 2017 15:17:13 +0000 (10:17 -0500)]
Update CHANGES to mention fixes for 1007 and 1009
Andrey Tuganov [Fri, 24 Nov 2017 15:05:07 +0000 (10:05 -0500)]
Relaxed OpImageRead validation rules
Removed the check that result type of OpImageRead should be a vector4.
Will reenable/adapt once the spec is clarified on what the right
dimension should be.
Alan Baker [Fri, 24 Nov 2017 04:08:58 +0000 (23:08 -0500)]
Notify the context of instructions that are being erased.
Fixes use-after-free error in RemoveDuplicatesPass
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1004
Andrey Tuganov [Thu, 23 Nov 2017 17:11:15 +0000 (12:11 -0500)]
Add validation checks for Execution Model
Currently checks that these instructions are called from entry points
with Fragment execution model.
OpImageImplicit*
OpImageQueryLod
OpKill
David Neto [Wed, 22 Nov 2017 22:03:55 +0000 (17:03 -0500)]
Test for pollution of the global namespace
Works on Linux only for now. That's a good start.
Move ValidateBinaryUsingContextAndValidationState into anonymous
namespace in source/validate.cpp.
Steven Perron [Thu, 23 Nov 2017 17:41:10 +0000 (12:41 -0500)]
Remove derivative instructions from the list of combinators.
These instructions compute their value based the value of the immediate
neighbours of the current fragment. This means the result is not
defined purely by the operands of the instruction.
David Neto [Thu, 23 Nov 2017 23:16:41 +0000 (18:16 -0500)]
Start v2017.2-dev
David Neto [Thu, 23 Nov 2017 23:12:23 +0000 (18:12 -0500)]
Finalize 2017.1
Updated CHANGES to cover main updates since 2017.0
Lei Zhang [Fri, 17 Nov 2017 21:50:43 +0000 (16:50 -0500)]
Add RegisterLegalizationPasses() into the interface
Add note to mention the use scenario. The original list came
from Glslang.
Alan Baker [Tue, 14 Nov 2017 19:11:50 +0000 (14:11 -0500)]
Adding new def -> use mapping container
Replaced representation of uses
* Changed uses from unordered_map<uint32_t, UseList> to
set<pairInstruction*, Instruction*>>
* Replaced GetUses with ForEachUser and ForEachUse functions
* updated passes to use new functions
* partially updated tests
* lots of cleanup still todo
Adding an unique id to Instruction generated by IRContext
Each instruction is given an unique id that can be used for ordering
purposes. The ids are generated via the IRContext.
Major changes:
* Instructions now contain a uint32_t for unique id and a cached context
pointer
* Most constructors have been modified to take a context as input
* unfortunately I cannot remove the default and copy constructors, but
developers should avoid these
* Added accessors to parents of basic block and function
* Removed the copy constructors for BasicBlock and Function and replaced
them with Clone functions
* Reworked BuildModule to return an IRContext owning the built module
* Since all instructions require a context, the context now becomes the
basic unit for IR
* Added a constructor to context to create an owned module internally
* Replaced uses of Instruction's copy constructor with Clone whereever I
found them
* Reworked the linker functionality to perform clones into a different
context instead of moves
* Updated many tests to be consistent with the above changes
* Still need to add new tests to cover added functionality
* Added comparison operators to Instruction
Adding tests for Instruction, IRContext and IR loading
Fixed some header comments for BuildModule
Fixes to get tests passing again
* Reordered two linker steps to avoid use/def problems
* Fixed def/use manager uses in merge return pass
* Added early return for GetAnnotations
* Changed uses of Instruction::ToNop in passes to IRContext::KillInst
Simplifying the uses for some contexts in passes
Lei Zhang [Thu, 23 Nov 2017 20:16:48 +0000 (15:16 -0500)]
Allow derived access chain without uses in access chain conversion
Andrey Tuganov [Wed, 22 Nov 2017 17:07:23 +0000 (12:07 -0500)]
Add derivatives validation pass
Checks operands of instructions in opcode range from OpDPdx to
OpFwidthCoarse.
David Neto [Wed, 22 Nov 2017 20:18:37 +0000 (15:18 -0500)]
Move SetContextMessageConsumer into libspirv namespace
Avoid polluting the global namespace.
Steven Perron [Sat, 11 Nov 2017 01:26:55 +0000 (20:26 -0500)]
Create a local value numbering pass
Creates a pass that removes redundant instructions within the same basic
block. This will be implemented using a hash based value numbering
algorithm.
Added a number of functions that check for the Vulkan descriptor types.
These are used to determine if we are variables are read-only or not.
Implemented a function to check if loads and variables are read-only.
Implemented kernel specific and shader specific versions.
A big change is that the Combinator analysis in ADCE is factored out
into the IRContext as an analysis. This was done because it is being
reused in the value number table.
Andrey Tuganov [Thu, 26 Oct 2017 19:30:23 +0000 (15:30 -0400)]
Validator pass for image instructions
Includes validation rules for OpImageXXX and ImageOperand.
Doesn't include OpTypeImage and OpImageSparseXXX.
Disabled an invalid test.
GregF [Fri, 17 Nov 2017 23:47:11 +0000 (16:47 -0700)]
Optimize loads/stores on nested structs
Also fix LocalAccessChainConvert test: nested structs now convert
Add InsertExtractElim test for nested struct
Andrey Tuganov [Mon, 20 Nov 2017 22:56:01 +0000 (17:56 -0500)]
Fix move semantics in iterator make_range
Andrey Tuganov [Tue, 14 Nov 2017 22:02:42 +0000 (17:02 -0500)]
Add new compression algorithm and models
Add new "short descriptor" algorithm to MARK-V codec.
Add three shader compression models:
lite - fast, poor compression
mid - balanced
max - best compression
Alan Baker [Tue, 14 Nov 2017 19:11:50 +0000 (14:11 -0500)]
Adding an unique id to Instruction generated by IRContext
Each instruction is given an unique id that can be used for ordering
purposes. The ids are generated via the IRContext.
Major changes:
* Instructions now contain a uint32_t for unique id and a cached context
pointer
* Most constructors have been modified to take a context as input
* unfortunately I cannot remove the default and copy constructors, but
developers should avoid these
* Added accessors to parents of basic block and function
* Removed the copy constructors for BasicBlock and Function and replaced
them with Clone functions
* Reworked BuildModule to return an IRContext owning the built module
* Since all instructions require a context, the context now becomes the
basic unit for IR
* Added a constructor to context to create an owned module internally
* Replaced uses of Instruction's copy constructor with Clone whereever I
found them
* Reworked the linker functionality to perform clones into a different
context instead of moves
* Updated many tests to be consistent with the above changes
* Still need to add new tests to cover added functionality
* Added comparison operators to Instruction
* Added an internal option to LinkerOptions to verify merged ids are
unique
* Added a test for the linker to verify merged ids are unique
* Updated MergeReturnPass to supply a context
* Updated DecorationManager to supply a context for cloned decorations
* Reworked several portions of the def use tests in anticipation of next
set of changes
Steven Perron [Fri, 17 Nov 2017 18:03:17 +0000 (13:03 -0500)]
Add dead function elimination to -O and -Os
This pass is very useful in reducing the size of the code, and reducing
the amount of work done by other optimizations.
Lei Zhang [Fri, 17 Nov 2017 21:33:32 +0000 (16:33 -0500)]
Fix hard-coded header path
If SPIRV-Tools is used as an external project and have
googletest being kept in the same directory as it, we
won't have gmock-matchers.h in external/. This will
result in a compilation error.
Use gmock.h instead.
David Neto [Wed, 15 Nov 2017 18:37:52 +0000 (13:37 -0500)]
Git should ignore external repos
Ignore googletest, spirv-headers, effcee, and re2
Steven Perron [Mon, 13 Nov 2017 20:31:43 +0000 (15:31 -0500)]
Add the decoration manager to the IRContext.
To make the decoration manger available everywhere, and to reduce the
number of times it needs to be build, I add one the IRContext.
As the same time, I move code that modifies decoration instruction into
the IRContext from mempass and the decoration manager. This will make
it easier to keep everything up to date.
This should take care of issue #928.
Alan Baker [Wed, 8 Nov 2017 21:22:10 +0000 (16:22 -0500)]
Initial implementation of merge return pass.
Works with current DefUseManager infrastructure.
Added merge return to the standard opts.
Added validation to passes.
Disabled pass for shader capabilty.
Lei Zhang [Tue, 14 Nov 2017 14:18:42 +0000 (09:18 -0500)]
Appveyor: skip building tags
Lei Zhang [Mon, 13 Nov 2017 19:55:20 +0000 (14:55 -0500)]
Appveyor: Stop testing VS 2013/2015 Debug
VS2017 Debug tests should suffice for intresting Debug cases.
This will save us ~30min of waiting time for each build job.
Diego Novillo [Fri, 10 Nov 2017 14:39:00 +0000 (09:39 -0500)]
Add analysis to compute mappings between instructions and basic blocks.
This analysis builds a map from instructions to the basic block that
contains them. It is accessed via get_instr_block(). Once built, it is kept
up-to-date by the IRContext, as long as instructions are removed via
KillInst.
I have not yet marked passes that preserve this analysis. I will do it
in a separate change.
Other changes:
- Add documentation about analysis values requirement to be powers of 2.
- Force a re-build of the def-use manager in tests.
- Fix AllPreserveFirstOnlyAfterPassWithChange to use the
DummyPassPreservesFirst pass.
- Fix sentinel value for IRContext::Analysis enum.
- Fix logic for checking if the instr<->block mapping is valid in KillInst.
Daniel Schürmann [Tue, 24 Oct 2017 16:28:18 +0000 (18:28 +0200)]
Fix decorations of inlined functions.
Fixes issue #728. Currently the inliner is not generating decorations for
inlined code which corresponds to function code which has decorations. An
example of decorations that are relevant: RelaxedPrecision, NoContraction.
The solution is to replicate the decoration during inlining.
David Neto [Wed, 8 Nov 2017 05:23:42 +0000 (00:23 -0500)]
Tests: Add optional dependency on Effcee stateful matcher
Add Effcee as an optional dependency for use in tests. In future it will
be a required dependency.
Effcee is a stateful pattern matcher that has much of the functionality
of LLVM's FileCheck, except in library form. Effcee makes it much easier
to write tests for optimization passes.
Demonstrate its use in a test for the strength-reduction pass.
Update README.md with example commands of how to get sources.
Update Appveyor and Travis-CI build rules.
Also: Include test libraries if not SPIRV_SKIP_TESTS
- SPIRV_SKIP_TESTS is implied by SPIRV_SKIP_EXECUTABLES
Steven Perron [Thu, 9 Nov 2017 16:24:41 +0000 (11:24 -0500)]
Have all MemPasses preserve the def-use manager.
Originally the passes that extended from MemPass were those that are
of the def-use manager. I am assuming they would be able to preserve
it because of that.
Added a check to verify consistency of the IRContext. The IRContext
relies on the pass to tell it if something is invalidated.
It is possible that the pass lied. To help identify those situations,
we will check if the valid analyses are correct after each pass.
This will be enabled by default for the debug build, and disabled in the
production build. It can be disabled in the debug build by adding
"-DSPIRV_CHECK_CONTEXT=OFF" to the cmake command.
Lei Zhang [Thu, 9 Nov 2017 00:41:17 +0000 (19:41 -0500)]
Travis: auto deploy build artifacts to GitHub Releases
Pushing a commit to the master branch will trigger a build on
Travis. If the build is successful, the artifacts will be
collected and pushed to GitHub Releases, under the "master-tot"
release.
Lei Zhang [Wed, 8 Nov 2017 21:44:53 +0000 (16:44 -0500)]
Appveyor: auto deploy build artifacts to GitHub Releases
Pushing a commit to the master branch will trigger a build on
Appveyor. If the build is successful, the artifacts will be
collected and pushed to GitHub Releases, under the "master-tot"
release.
Diego Novillo [Wed, 8 Nov 2017 17:40:02 +0000 (12:40 -0500)]
Re-format files in source, source/opt, source/util, source/val and tools.
NFC. This just makes sure every file is formatted following the
formatting definition in .clang-format.
Re-formatted with:
$ clang-format -i $(find source tools include -name '*.cpp')
$ clang-format -i $(find source tools include -name '*.h')
Steven Perron [Thu, 2 Nov 2017 18:25:48 +0000 (14:25 -0400)]
Add the IRContext (part 2): Add def-use manager
This change will move the instances of the def-use manager to the
IRContext. This allows it to persists across optimization, and does
not have to be rebuilt multiple times.
Added test to ensure that the IRContext is validating and invalidating
the analyses correctly.
GregF [Mon, 6 Nov 2017 18:25:24 +0000 (11:25 -0700)]
Opt: Fix HasLoads to not report decoration as load.
GregF [Tue, 7 Nov 2017 00:00:44 +0000 (17:00 -0700)]
Opt: Remove CommonUniformElimination from -O and -Os (for now)
It is causing crashes for some drivers. Will try to re-enable it once
existing drivers are able to deal better with it.
David Neto [Wed, 4 Oct 2017 21:02:39 +0000 (17:02 -0400)]
Describe public_spirv_tools_dev@khronos.org mailing list
Nuno Subtil [Wed, 1 Nov 2017 03:08:23 +0000 (20:08 -0700)]
Validate storage class of target pointer for OpStore
Diego Novillo [Thu, 2 Nov 2017 15:51:07 +0000 (11:51 -0400)]
Move class CFG from namespace opt to namespace ir.
It makes more sense to have the CFG inside the ir name space, as it is
descriptive of the representation.
Diego Novillo [Mon, 30 Oct 2017 21:42:26 +0000 (17:42 -0400)]
Add a new class opt::CFG to represent the CFG for the module.
This class moves some of the CFG-related functionality into a new
class opt::CFG. There is some other code related to the CFG in the
inliner and in opt::LocalSingleStoreElimPass that should also be moved,
but that require more changes than this pure restructuring.
I will move those bits in a follow-up PR.
Currently, the CFG is computed every time a pass is instantiated, but
this should be later moved to the new IRContext class that @s-perron is
working on.
Other re-factoring:
- Add BasicBlock::ContinueBlockIdIfAny. Re-factored out of MergeBlockIdIfAny
- Rewrite IsLoopHeader in terms of GetLoopMergeInst.
- Run clang-format on some files.
Steven Perron [Mon, 30 Oct 2017 15:13:24 +0000 (11:13 -0400)]
Add the IRContext (part 1)
This is the first part of adding the IRContext. This class is meant to
hold the extra data that is build on top of the module that it
owns.
The first part will simply create the IRContext class and get it passed
to the passes in place of the module. For now it does not have any
functionality of its own, but it acts more as a wrapper for the module.
The functions that I added to the IRContext are those that either
traverse the headers or add to them. I did this because we may decide
to have other ways of dealing with these sections (for example adding a
type pool, or use the decoration manager).
I also added the function that add to the header because the IRContext
needs to know when an instruction is added to update other data
structures appropriately.
Note that there is still lots of work that needs to be done. There are
still many places that change the module, and do not inform the context.
That will be the next step.
Nuno Subtil [Thu, 26 Oct 2017 20:20:32 +0000 (13:20 -0700)]
Add validation for OpBranchConditional
Andrey Tuganov [Mon, 30 Oct 2017 17:17:58 +0000 (13:17 -0400)]
Lowered initial capacity of move-to-front sequence
Also fixed outdated comments.
Steven Perron [Mon, 30 Oct 2017 19:31:19 +0000 (15:31 -0400)]
Fix copyright check when the build directory is in the source directory.
The IDE I am using places the cmake build directory inside the source
directory. When that happens the copyright check fails because the
build process creates a file CMakeCXXCompilerId.cpp. That file does
not have the copyright information, so the test fails.
I want this file to be ignored, so I added its directory, CompilerIdCXX,
to the list of directories to be ignored.
GregF [Tue, 17 Oct 2017 22:33:43 +0000 (16:33 -0600)]
ADCE: Dead if elimination
Mark structured conditional branches live only if one or more instructions
in their associated construct is marked live. After closure, replace dead
structured conditional branches with a branch to its merge and remove
dead blocks.
ADCE: Dead If Elim: Remove duplicate StructuredOrder code
Also generalize ComputeStructuredOrder so that the caller can specify the
root block for the order. Phi insertion uses pseudo_entry_block and adce and
dead branch elim use the first block of the function.
ADCE: Dead If Elim: Pull redundant code out of InsertPhiInstructions
ADCE: Dead If Elim: Encapsulate CFG Cleanup Initialization
ADCE: Dead If Elim: Remove redundant code from ADCE initialization
ADCE: Dead If: Use CFGCleanup to eliminate newly dead blocks
Moved bulk of CFG Cleanup code into MemPass.
Diego Novillo [Mon, 30 Oct 2017 13:02:03 +0000 (09:02 -0400)]
More re-factoring to simplify pass initialization.
This implements two cleanups suggested by @s-perron
(https://github.com/KhronosGroup/SPIRV-Tools/pull/921):
- Move FindNamedOrDecoratedIds() into MemPass::InitializeProcessing().
- Remove FinalizeNextId(). Always call SetIdBound() from
Pass::TakeNextId().
Steven Perron [Tue, 24 Oct 2017 19:13:13 +0000 (15:13 -0400)]
Add option to relax validation of store types.
There are a number of users of spriv-opt that are hitting errors
because of stores with different types. In general, this is wrong, but,
in these cases, the types are the exact same except for decorations.
The options is "--relax-store-struct", and it can be used with the
validator or the optimizer.
We assume that if layout information is missing it is consistent. For
example if one struct has a offset of one of its members, and the other
one does not, we will still consider them as being layout compatible.
The problem will be if both struct has and offset decoration for
corresponding members, and the offset are different.
Andrey Tuganov [Fri, 27 Oct 2017 15:31:39 +0000 (11:31 -0400)]
Compression: removed 'presumed index' feature
The feature used to improve compression of const integers which were
presumed to be indices. Now obsolete as descriptor-based compression
does this in a more generalized way.
Jesus Carabano [Fri, 27 Oct 2017 12:28:50 +0000 (15:28 +0300)]
Use std::lower_bound for opcode lookup
Use std::lower_bound for opcode-to-string
Stable sort the generated instruction table.
Diego Novillo [Wed, 25 Oct 2017 17:26:25 +0000 (13:26 -0400)]
Re-factor Phi insertion code out of LocalMultiStoreElimPass
Including a re-factor of common behaviour into class Pass:
The following functions are now in class Pass:
- IsLoopHeader.
- ComputeStructuredOrder
- ComputeStructuredSuccessors (annoyingly, I could not re-factor all
instances of this function, the copy in common_uniform_elim_pass.cpp
is slightly different and fails with the common implementation).
- GetPointeeTypeId
- TakeNextId
- FinalizeNextId
- MergeBlockIdIfAny
This is a NFC (non-functional change)
Steven Perron [Fri, 13 Oct 2017 18:25:21 +0000 (14:25 -0400)]
Change the sections in the module to use the InstructionList class.
This change will replace a number of the
std::vector<std::unique_ptr<Instruction>> member of the module to
InstructionList. This is for consistency and to make it easier to
delete instructions that are no longer needed.
Lei Zhang [Wed, 25 Oct 2017 16:15:51 +0000 (12:15 -0400)]
Turn all function static non-POD variables into global POD variables
Function static non-POD data causes problems with DLL lifetime.
This pull request turns all static info tables into strict POD
tables. Specifically, the capabilities/extensions field of
opcode/operand/extended-instruction table are turned into two
fields, one for the count and the other a pointer to an array of
capabilities/extensions. CapabilitySet/EnumSet are not used in
the static table anymore, but they are still used for checking
inclusion by constructing on the fly, which should be cheap for
the majority cases.
Also moves all these tables into the global namespace to avoid
C++11 function static thread-safe initialization overhead.
Józef Kucia [Fri, 13 Oct 2017 19:53:58 +0000 (21:53 +0200)]
Validate SpvOpVectorShuffle
Jesus Carabano [Sat, 21 Oct 2017 16:39:32 +0000 (19:39 +0300)]
restrict opcodes targeting OpDecorationGroup
Daniel Schürmann [Tue, 24 Oct 2017 11:24:08 +0000 (13:24 +0200)]
Fixed --eliminate-common-uniform so that it does not eliminate loads of volatile variables.
David Neto [Mon, 23 Oct 2017 14:53:28 +0000 (10:53 -0400)]
Optimizer: Line and NoLine are not debug1 or debug2
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/911
Andrey Tuganov [Tue, 17 Oct 2017 21:38:04 +0000 (17:38 -0400)]
Refactored compression debugger
Markv codec now receives two optional callbacks:
LogConsumer for internal codec logging
DebugConsumer for testing if encoding->decoding produces the original
results.
Steven Perron [Mon, 23 Oct 2017 19:48:29 +0000 (15:48 -0400)]
Run dead variable elimination when using -O and -Os
We want to run the optimization when using -O and -Os, but it was not
added at part of https://github.com/KhronosGroup/SPIRV-Tools/pull/905.
This change will add that a well as some minor formatting changes
requested in that same pull request.
GregF [Mon, 16 Oct 2017 23:30:52 +0000 (17:30 -0600)]
DeadBranchElim: Fix dead block elimination
The previous algorithm would leave invalid code in the case of unreachable
blocks pointing into a dead branch. It would leave the unreachable blocks
branching to labels that no longer exist. The previous algorithm also left
unreachable blocks in some cases (a loop following an orphaned merge block).
This fix also addresses that.
This code will soon be replaced with the coming CFG cleanup.
Steven Perron [Fri, 20 Oct 2017 16:17:41 +0000 (12:17 -0400)]
Add pass to remove dead variables at the module level.
There does not seem to be any pass that remove global variables. I
think we could use one. This pass will look specifically for global
variables that are not referenced and are not exported. Any decoration
associated with the variable will also be removed. However, this could
cause types or constants to become unreferenced. They will not be
removed. Another pass will have to be called to remove those.
David Neto [Fri, 20 Oct 2017 22:04:20 +0000 (18:04 -0400)]
Optimizer: OpModuleProcessed is in its own layout section
This is a recent decision from the SPIR WG. The spec update
has not yet been published.
Khronos SPIR-V internal issue 199
Andrey Tuganov [Thu, 19 Oct 2017 20:02:47 +0000 (16:02 -0400)]
Add Android.mk build to Travis CI
Added NDK_LIBS_OUT
Andrey Tuganov [Fri, 20 Oct 2017 18:34:32 +0000 (14:34 -0400)]
Added dummy android test application
The application is needed to test Android.mk build.
David Neto [Fri, 20 Oct 2017 20:51:20 +0000 (16:51 -0400)]
Fix cfg_cleanup.cpp. My bad.
David Neto [Thu, 19 Oct 2017 19:56:23 +0000 (15:56 -0400)]
Remove coding redundancy in cfg_cleanup_pass.cpp