Steven Perron [Fri, 12 Jan 2018 16:23:57 +0000 (11:23 -0500)]
Move initialization of the const mgr to the constructor.
The current code expects the users of the constant manager to initialize
it with all of the constants in the module. The problem is that you do
not want to redo the work multiple times. So I decided to move that
code to the constructor of the constant manager. This way it will
always be initialized on first use.
I also removed an assert that expects all constant instructions to be
successfully mapped. This is because not all OpConstant* instruction
can map to a constant, and neither do the OpSpecConstant* instructions.
The real problem is that an OpConstantComposite can contain a member
that is OpUndef. I tried to treat OpUndef like OpConstantNull, but this
failed because an OpSpecConstantComposite with an OpUndef cannot be
changed to an OpConstantComposite. Since I feel this case will not be
common, I decided to not complicate the code.
Fixes #1193.
David Neto [Fri, 12 Jan 2018 18:33:43 +0000 (13:33 -0500)]
Start v2018.0-dev
David Neto [Fri, 12 Jan 2018 18:32:04 +0000 (13:32 -0500)]
Finalize v2017.3
Alan Baker [Wed, 10 Jan 2018 19:23:47 +0000 (14:23 -0500)]
Adding ostream operators for IR structures
* Added for Instruction, BasicBlock, Function and Module
* Uses new disassembly functionality that can disassemble individual
instructions
* For debug use only (no caching is done)
* Each output converts module to binary, parses and outputs an
individual instruction
* Added a test for whole module output
* Disabling Microsoft checked iterator warnings
* Updated check_copyright.py to accept 2018
Alan Baker [Thu, 11 Jan 2018 20:05:39 +0000 (15:05 -0500)]
Maintain instruction to block mapping in phi insertion
* Changed MemPass::InsertPhiInstructions to set basic blocks for new
phis
* Local SSA elim now maintains instr to block mapping
* Added a test and confirmed it fails without the updated phis
* IRContext::set_instr_block no longer builds the map if the analysis is
invalid
* Added instruction to block mapping verification to
IRContext::IsConsistent()
Greg Fischer [Fri, 29 Dec 2017 23:44:43 +0000 (16:44 -0700)]
InsertExtractElim: Optimize through VectorShuffle, Mix
This improves Extract replacement to continue through VectorShuffle.
It will also handle Mix with 0.0 or 1.0 in the a-value of the desired
component.
To facilitate optimization of VectorShuffle, the algorithm was refactored
to pass around the indices of the extract in a vector rather than pass the
extract instruction itself. This allows the indices to be modified as the
algorithm progresses.
Steven Perron [Tue, 9 Jan 2018 17:45:46 +0000 (12:45 -0500)]
Add generic folding function and use in CCP
The current folding routines have a very cumbersome interface, make them
harder to use, and not a obvious how to extend.
This change is to create a new interface for the folding routines, and
show how it can be used by calling it from CCP.
This does not make a significant change to the behaviour of CCP. In
general it should produce the same code as before; however it is
possible that an instruction that takes 32-bit integers as inputs and
the result is not a 32-bit integer or bool will not be folded as before.
Alan Baker [Mon, 18 Dec 2017 17:13:10 +0000 (12:13 -0500)]
Adding additional functionality to ADCE.
Modified ADCE to remove dead globals.
* Entry point and execution mode instructions are marked as alive
* Reachable functions and their parameters are marked as alive
* Instruction deletion now deferred until the end of the pass
* Eliminated dead insts set, added IsDead to calculate that value
instead
* Ported applicable dead variable elimination tests
* Ported dead constant elim tests
Added dead function elimination to ADCE
* ported dead function elim tests
Added handling of decoration groups in ADCE
* Uses a custom sorter to traverse decorations in a specific order
* Simplifies necessary checks
Updated -O and -Os pass lists.
Andrey Tuganov [Tue, 9 Jan 2018 16:08:44 +0000 (11:08 -0500)]
Fix validation rules for GLSL pack/unpack 2x32
Alan Baker [Thu, 4 Jan 2018 22:04:03 +0000 (17:04 -0500)]
Rewriting dead branch elimination.
Pass now paints live blocks and fixes constant branches and switches as
it goes. No longer requires structured control flow. It also removes
unreachable blocks as a side effect. It fixes the IR (phis) before doing
any code removal (other than terminator changes).
Added several unit tests for updated/new functionality.
Does not remove dead edge from a phi node:
* Checks that incoming edges are live in order to retain them
* Added BasicBlock::IsSuccessor
* added test
Fixing phi updates in the presence of extra backedge blocks
* Added tests to catch bug
Reworked how phis are updated
* Instead of creating a new Phi and RAUW'ing the old phi with it, I now
replace the phi operands, but maintain the def/use manager correctly.
For unreachable merge:
* When considering unreachable continue blocks the code now properly
checks whether the incoming edge will continue to be live.
Major refactoring for review
* Broke into 4 major functions
* marking live blocks
* marking structured targets
* fixing phis
* deleting blocks
Diego Novillo [Mon, 8 Jan 2018 16:56:57 +0000 (11:56 -0500)]
Fix constant propagation of induction variables.
This fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1143.
When an instruction transitions from constant to bottom (varying) in the
lattice, we were telling the propagator that the instruction was
varying, but never updating the actual value in the values table.
This led to incorrect value substitutions at the end of propagation.
The patch also re-enables CCP in -O and -Os.
David Neto [Mon, 8 Jan 2018 15:42:02 +0000 (10:42 -0500)]
Fix method comment for BasicBlock::MegeBlockIdIfAny
Fixes #1177
Lei Zhang [Sun, 7 Jan 2018 15:50:01 +0000 (10:50 -0500)]
Allow relaxing validation of pointers in logical addressing mode
In HLSL structured buffer legalization, pointer to pointer types
are emitted to indicate a structured buffer variable should be
treated as an alias of some other variable. We need an option to
relax the check of pointer types in logical addressing mode to
catch other validation errors.
Victor Lomuller [Thu, 21 Dec 2017 14:47:25 +0000 (14:47 +0000)]
Add loop descriptors and some required dominator tree extensions.
Add post-order tree iterator.
Add DominatorTreeNode extensions:
- Add begin/end methods to do pre-order and post-order tree traversal from a given DominatorTreeNode
Add DominatorTree extensions:
- Add begin/end methods to do pre-order and post-order tree traversal
- Tree traversal ignore by default the pseudo entry block
- Retrieve a DominatorTreeNode from a basic block
Add loop descriptor:
- Add a LoopDescriptor class to register all loops in a given function.
- Add a Loop class to describe a loop:
- Loop parent
- Nested loops
- Loop depth
- Loop header, merge, continue and preheader
- Basic blocks that belong to the loop
Correct a bug that forced dominator tree to be constantly rebuilt.
David Neto [Fri, 5 Jan 2018 23:08:31 +0000 (18:08 -0500)]
AnalyzeInstUse: Reuse the instruction lookup
David Neto [Fri, 5 Jan 2018 18:21:36 +0000 (13:21 -0500)]
Remove CCP from size and performance recipes, pending bugfixes
Currently CCP is incorrectly optimizing loops.
See https://github.com/KhronosGroup/SPIRV-Tools/issues/1143
Pierre Moreau [Wed, 3 Jan 2018 00:54:55 +0000 (01:54 +0100)]
Linker code cleanups
Turn `Linker::Link()` into free functions
As very little information was kept in the Linker class, we can get rid
of the whole class and have the `Link()` as free functions instead; the
environment target as well as the consumer are passed along through an
`spv_context` object.
The resulting linked_binary is passed as a pointer rather than a
reference to follow the Google C++ Style guidelines.
Addresses remaining comments from
https://github.com/KhronosGroup/SPIRV-Tools/pull/693 about the SPIR-V
linker.
Fix variable naming in the linker
Some of the variables were using mixed case, which did not follow the
Google C++ Style guidelines.
Linker: Use EXPECT_EQ when possible and update some test
* Replace occurrences of ASSERT_EQ by EXPECT_EQ when possible;
* Reformulated some of the error messages;
* Added the symbol name in the error message when there is a type or
decoration mismatch between the imported and exported declarations.
Opt: List all duplicates removed by RemoveDuplicatePass in the header
Opt: Make the const version of GetLabelInst() return a pointer
For consistency with the non-const version, as well as other similar
functions.
Opt: Rename function_end to EndInst()
As pointed out by dneto0 the previous name was quite confusing and could
be mistaken with a function returning an end iterator.
Also change the return type of the const version to a pointer rather
than a reference, for consistency.
Opt: Add performance comment to RemoveDuplicateTypes and decorations
This comment was requested during the review of
https://github.com/KhronosGroup/SPIRV-Tools/pull/693.
Opt: Add comments and fix variable naming in RemoveDuplicatePass
* Add missing comments to private functions;
* Rename variables that were using mixed case;
* Add TODO for moving AreTypesEqual out.
Linker: Remove commented out code and add TODOs
Linker: Merged together strings that were too much splitted
Implement a C++ RAII wrapper around spv_context
Steven Perron [Thu, 4 Jan 2018 16:37:19 +0000 (11:37 -0500)]
Allow getting the base pointer of an image load/store.
In value numbering, we treat loads and stores of images, ie OpImageLoad,
as a memory operation where it is interested in the "base address" of
the instruction. In those cases, it is an image instruction.
The problem is that `Instruction::GetBaseAddress()` does not account for
the image instructions, so the assert at the end to make sure it found
a valid base address for its addressing mode fails.
The solution is to look at the load/store instruction to determine how
the assertion should be done.
Fixes #1160.
Diego Novillo [Fri, 5 Jan 2018 14:34:18 +0000 (09:34 -0500)]
Fix infinite simulation cycles in SSA propagator.
This fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1159. I
had missed a nuance in the original algorithm. When simulating Phi
instructions, the SSA edges out of a Phi instruction should never be
added to the list of edges to simulate.
Phi instructions can be in SSA def-use cycles with other Phi
instructions. This was causing the propagator to fall into an infinite
loop when the same def-use edge kept being added to the queue.
The original algorithm in the paper specifically separates the visit of
a Phi instruction vs the visit of a regular instruction. This fix makes
the implementation match the original algorithm.
Pierre Moreau [Thu, 4 Jan 2018 22:16:39 +0000 (23:16 +0100)]
Ignore clang-format-diff.py from copyrights check
Having that script locally, for example to run check_code_format.sh
before sending a pull request, would cause the copyright notices check
to fail.
David Neto [Thu, 4 Jan 2018 23:52:38 +0000 (18:52 -0500)]
dead branch elim: Track killed backedges
When deleting branches and blocks, also remove them from
the backedges set, in case they were there.
This prevents us from keeping stale pointers to deleted Instruction
objects. That memory could be used later by another instruction,
incorrectly signaling that something has a backedge reference, and
the dead branch eliminator could end up deleting live blocks.
Adds accessor method ir::BasicBlock::terminator
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1168
David Neto [Thu, 4 Jan 2018 17:59:50 +0000 (12:59 -0500)]
Add --print-all optimizer option
Adds optimizer API to write disassembly to a given output stream
before each pass, and after the last pass.
Adds spirv-opt --print-all option to write disassembly to stderr
before each pass, and after the last pass.
Pierre Moreau [Sun, 24 Dec 2017 10:15:14 +0000 (11:15 +0100)]
Opt: Make DecorationManager::HaveTheSameDecorations symmetric
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1112
Also: Add SpvOpDecorateId to IsAnnotationInst()
Andrey Tuganov [Tue, 2 Jan 2018 21:02:55 +0000 (16:02 -0500)]
Validator checks out of bounds composite access
1. Added OpCompositeExtract/Insert out of bounds checks where possible
(everything except RuntimeArray)
2. Moved validation of OpCompositeExtract/Insert from validate_id.cpp to
validate_composites.cpp.
Diego Novillo [Thu, 4 Jan 2018 18:20:18 +0000 (13:20 -0500)]
Address review comments from https://github.com/KhronosGroup/SPIRV-Tools/pull/985.
Steven Perron [Wed, 3 Jan 2018 19:03:07 +0000 (14:03 -0500)]
Update legalization passes
I've a few passes the legalization passes. The first is to add the
more specialized load-store removal passes to help improve the compile
time, as was suggested in #1118.
I've also added dead branch elimination while we wait for the behaviour
of dead branch elimination to be folded into CFG cleanup.
I did not add CCP because it seems like most of the constant propagation
what is needed is already being done by the load-store removal passes,
which call `ReplaceAllUsesWith`. We can reconsider this if needed.
Steven Perron [Wed, 3 Jan 2018 18:23:57 +0000 (13:23 -0500)]
Replace calls to `ToNop` by `KillInst`.
Calling `ToNop` leaves around instructions that are pointless. In
general it is better to remove the instruction completely. That way
other optimizations will not need to look at them.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1003.
Diego Novillo [Wed, 3 Jan 2018 20:25:03 +0000 (15:25 -0500)]
Handle execution termination instructions when building edges.
This fixes issue https://github.com/KhronosGroup/SPIRV-Tools/issues/1153.
When building CFG edges, edges out of a OpKill and OpUnreachable
instruction should be directed to the CFG's pseudo exit block.
Diego Novillo [Wed, 3 Jan 2018 17:38:21 +0000 (12:38 -0500)]
Do not insert Phi nodes in CCP propagator.
In CCP we should not need to insert Phi nodes because CCP never looks at
loads/stores. This required adjusting two tests that relied on Phi
instructions being inserted. I changed the tests to have the Phi
instructions pre-inserted.
I also added a new test to make sure that CCP does not try to look
through stores and loads.
Finally, given that CCP does not handle loads/stores, it's better to run
mem2reg before it. I've changed the -O/-Os schedules to run local
multi-store elimination before CCP.
Although this is just an efficiency fix for CCP, it is
also working around a bug in Phi insertion. When Phi instructions are
inserted, they are never associated a basic block. This causes a
segfault when the propagator tries to lookup CFG edges when analyzing
Phi instructions.
Andrey Tuganov [Wed, 13 Dec 2017 16:56:09 +0000 (11:56 -0500)]
Add ExtInst validation pass (GLSL only for now)
Validates all GLSL.std.450 extended instructions.
GregF [Thu, 28 Dec 2017 00:12:04 +0000 (17:12 -0700)]
Test: Fix linux/gcc defined-but-not-used warnings/errors
Leo Izen [Thu, 28 Dec 2017 16:13:06 +0000 (11:13 -0500)]
utils/generate_grammar_tables.py: use spaces for indentation
One part of this file had indented using tabs. This causes newer
versions of python to complain. This changes the indentation to
consistently use four spaces throughout the file, to be consistent
with the rest of the file and the rest of the project.
Diego Novillo [Fri, 22 Dec 2017 17:38:02 +0000 (12:38 -0500)]
Fix https://github.com/KhronosGroup/SPIRV-Tools/issues/1130
This addresses review feedback for the CCP implementation (which fixes
https://github.com/KhronosGroup/SPIRV-Tools/issues/889).
This adds more protection around the folding of instructions that would
not be supported by the folder.
Andrey Tuganov [Thu, 21 Dec 2017 20:24:27 +0000 (15:24 -0500)]
Disallow Dim=SubpassData for OpImageSparseRead
David Neto [Sun, 3 Dec 2017 17:30:08 +0000 (12:30 -0500)]
Add asm, dis support for DebugInfo extended instruction set
Add grammar file for DebugInfo extended instruction set
- Each new operand enum kind in extinst.debuginfo.grammar.json maps
to a new value in spv_operand_type_t.
- Add new concrete enum operand types for DebugInfo
Generate a C header for the DebugInfo extended instruction set
Add table lookup of DebugInfo extended instrutions
Handle the debug info operand types in binary parser,
disassembler, and assembler.
Add DebugInfo round trip tests for assembler, disassembler
Android.mk: Support DebugInfo extended instruction set
The extinst.debuginfo.grammar.json file is currently part of
SPIRV-Tools source.
It contributes operand type enums, so it has to be processed
along with the core grammar files.
We also generate a C header DebugInfo.h.
Add necessary grammar file processing to Android.mk.
David Neto [Thu, 21 Dec 2017 16:25:31 +0000 (11:25 -0500)]
CONTRIBUTING: If you fixed a bug, say so
Diego Novillo [Tue, 5 Dec 2017 16:39:25 +0000 (11:39 -0500)]
Implement SSA CCP (SSA Conditional Constant Propagation).
This implements the conditional constant propagation pass proposed in
Constant propagation with conditional branches,
Wegman and Zadeck, ACM TOPLAS 13(2):181-210.
The main logic resides in CCPPass::VisitInstruction. Instruction that
may produce a constant value are evaluated with the constant folder. If
they produce a new constant, the instruction is considered interesting.
Otherwise, it's considered varying (for unfoldable instructions) or
just not interesting (when not enough operands have a constant value).
The other main piece of logic is in CCPPass::VisitBranch. This
evaluates the selector of the branch. When it's found to be a known
value, it computes the destination basic block and sets it. This tells
the propagator which branches to follow.
The patch required extensions to the constant manager as well. Instead
of hashing the Constant pointers, this patch changes the constant pool
to hash the contents of the Constant. This allows the lookups to be
done using the actual values of the Constant, preventing duplicate
definitions.
Steven Perron [Tue, 19 Dec 2017 19:18:13 +0000 (14:18 -0500)]
Store all enabled capabilities in the feature manger.
In order to keep track of all of the implicit capabilities as well as
the explicit ones, we will add them all to the feature manager. That is
the object that needs to be queried when checking if a capability is
enabled.
The name of the "HasCapability" function in the module was changed to
make it more obvious that it does not check for implied capabilities.
Keep an spv_context and AssemblyGrammar in IRContext
David Neto [Thu, 21 Dec 2017 15:42:46 +0000 (10:42 -0500)]
Update CHANGES
Alan Baker [Mon, 18 Dec 2017 22:02:19 +0000 (17:02 -0500)]
Fixing bugs in type manager memory management
* changed the way duplicate types are removed to stop copying
instructions
* Reworked RemoveDuplicatesPass::AreTypesSame to use type manager and
type equality
* Reworked TypeManager memory management to store a pool of unique
pointers of types
* removed unique pointers from id map
* fixed instances where free'd memory could be accessed
Steven Perron [Tue, 19 Dec 2017 20:08:54 +0000 (15:08 -0500)]
Update the legalization passes.
Changes the set of optimizations done for legalization. While doing
this, I added documentation to explain why we want each optimization.
A new option "--legalize-hlsl" is added so the legalization passes can
be easily run from the command line.
The legalize option implies skip-validation.
David Neto [Tue, 19 Dec 2017 18:52:23 +0000 (13:52 -0500)]
Make a string parameter const ref
David Neto [Tue, 19 Dec 2017 23:30:10 +0000 (18:30 -0500)]
Fix CHANGES: there is no OpImageSparseWrite
David Neto [Tue, 19 Dec 2017 22:50:01 +0000 (17:50 -0500)]
Update CHANGES for recent changes
Pierre Moreau [Wed, 29 Nov 2017 23:29:34 +0000 (00:29 +0100)]
Opt: Fix implementation and comment of AreDecorationsTheSame
Target should not be ignored when comparing decorations in RemoveDuplicates
Opt: Remove unused code in RemoveDuplicateDecorations
Steven Perron [Mon, 11 Dec 2017 18:10:24 +0000 (13:10 -0500)]
Allow pointers to pointers in logical addressing mode.
A few optimizations are updates to handle code that is suppose to be
using the logical addressing mode, but still has variables that contain
pointers as long as the pointer are to opaque objects. This is called
"relaxed logical addressing".
|Instruction::GetBaseAddress| will check that pointers that are use meet
the relaxed logical addressing rules. Optimization that now handle
relaxed logical addressing instead of logical addressing are:
- aggressive dead-code elimination
- local access chain convert
- local store elimination passes.
Steven Perron [Mon, 11 Dec 2017 18:10:24 +0000 (13:10 -0500)]
Convert private variables to function scope.
When a private variable is used in a single function, it can be
converted to a function scope variable in that function. This adds a
pass that does that. The pass can be enabled using the option
`--private-to-local`.
This transformation allows other transformations to act on these
variables.
Also moved `FindPointerToType` from the inline class to the type manager.
David Neto [Fri, 15 Dec 2017 18:19:09 +0000 (13:19 -0500)]
More validation on primitive instructions
- Test validation success for OpEmitVertex OpEndPrimitive
- Test missing capabilities for primitive instructions
- Primitive instructions require Geometry execution model
Jesus Carabano [Wed, 18 Oct 2017 09:00:02 +0000 (12:00 +0300)]
validate & test of literal's upper bits
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/660
Pierre Moreau [Wed, 29 Nov 2017 23:26:20 +0000 (00:26 +0100)]
Opt: Remove commented out duplicated type_id function
This code was wrongly added by #693.
Jeremy Hayes [Mon, 18 Dec 2017 17:44:18 +0000 (10:44 -0700)]
Fix comment in primitives validation
Also refactor type query for efficiency.
Andrey Tuganov [Mon, 18 Dec 2017 16:21:38 +0000 (11:21 -0500)]
Image Operand Sample allows sparse image opcodes
@ehsannas had filed an issue against SPIR-V spec, concerning
Image Operands section (3.14):
Sample
A following operand is the sample number of the sample to use. Only
valid with OpImageFetch, OpImageRead, and OpImageWrite.
Relaxing the check to allow OpImageSparseRead and
OpImageSparseFetch to fix failing tests.
Pierre Moreau [Sat, 25 Nov 2017 17:58:50 +0000 (18:58 +0100)]
Export a config file for pkg-config
Fixes #1031
Extracts the current version from the file CHANGES
The -dev suffix maps to a minor version number of .0
No -dev suffix maps to a minor version number of .1
Uses a first class target spirv-tools-pkg-config
David Neto [Sun, 3 Dec 2017 19:26:16 +0000 (14:26 -0500)]
Remove concept of FIRST_CONCRETE_* operand types
Alan Baker [Fri, 8 Dec 2017 20:33:19 +0000 (15:33 -0500)]
Improving the usability of the type manager. The type manager hashes
types. This allows the lookup of type declaration ids from arbitrarily
constructed types. Users should be cautious when dealing with non-unique
types (structs and potentially pointers) to get the exact id if
necessary.
* Changed the spec composite constant folder to handle ambiguous composites
* Added functionality to create necessary instructions for a type
* Added ability to remove ids from the type manager
David Neto [Fri, 15 Dec 2017 23:24:41 +0000 (18:24 -0500)]
Start v2017.3-dev
David Neto [Fri, 15 Dec 2017 23:21:55 +0000 (18:21 -0500)]
Finalize v2017.2
GregF [Tue, 12 Dec 2017 21:27:46 +0000 (14:27 -0700)]
ADCE: Only mark true breaks and continues of live loops
This fixes issue #1075
- Mark continue when conditional branch with merge block.
Only mark if merge block is not continue block.
- Handle conditional branch break with preceding merge
Jeremy Hayes [Thu, 14 Dec 2017 22:29:37 +0000 (15:29 -0700)]
Add primitive instruction validation pass
Andrey Tuganov [Wed, 13 Dec 2017 22:55:00 +0000 (17:55 -0500)]
Refactor include of latest spir-v header versions
Andrey Tuganov [Thu, 30 Nov 2017 16:29:05 +0000 (11:29 -0500)]
Add validation rules for atomic instructions
Validates all OpAtomicXXX instructions.
Diego Novillo [Tue, 12 Dec 2017 20:46:09 +0000 (15:46 -0500)]
Fix uninitialized warning at -Os.
Greg Fischer [Wed, 25 Oct 2017 00:58:48 +0000 (18:58 -0600)]
ADCE: Empty Loop Elimination
This entirely eliminates loops which do not contain live code.
Steven Perron [Mon, 11 Dec 2017 18:10:24 +0000 (13:10 -0500)]
Set the parent for basic blocks during inlining.
Inlining is not setting the parent (function) for each basic block.
This can cause problems for later optimizations. The solution is to set
the parent for each new block just before it is linked into the
function.
Lei Zhang [Tue, 12 Dec 2017 15:46:39 +0000 (10:46 -0500)]
Appveyor: stop testing on VS 2013
re2 requires VS2015 or later since:
https://github.com/google/re2/commit/
97957299d1c9f7617cfe653f344536d733582d9e
Andrey Tuganov [Fri, 8 Dec 2017 22:57:12 +0000 (17:57 -0500)]
Add validator checks for sparse image opcodes
Pierre Moreau [Wed, 29 Nov 2017 23:49:23 +0000 (00:49 +0100)]
Support OpenCL 1.2 and 2.0 target environments
include: Add target environment enums for OpenCL 1.2 and 2.0
Validator: Validate OpenCL capabilities
Update validate capabilities to handle embedded profiles
Add test for OpenCL capabilities validation
Update messages to mention the OpenCL profile used
Re-format val_capability_test.cpp
David Neto [Mon, 11 Dec 2017 20:50:51 +0000 (15:50 -0500)]
AppVeyor: Put VS 2017 first
VS 2017 is the newest compiler, with the most interesting feedback.
Place it first so we get its feedback first.
David Neto [Mon, 11 Dec 2017 17:05:04 +0000 (12:05 -0500)]
Force gtest to expose ::testing::Combine
Work around faulty logic in googletest, where ::testing::Combine
is accidentally disabled for VS 2017.
See https://github.com/google/googletest/issues/1352
Andrey Tuganov [Mon, 11 Dec 2017 17:33:11 +0000 (12:33 -0500)]
Reenable OpCopyObject validation rules
Vulkan CTS fix has been submitted.
Alan Baker [Thu, 30 Nov 2017 22:03:06 +0000 (17:03 -0500)]
Add scalar replacement
Adds a scalar replacement pass. The pass considers all function scope
variables of composite type. If there are accesses to individual
elements (and it is legal) the pass replaces the variable with a
variable for each composite element and updates all the uses.
Added the pass to -O
Added NumUses and NumUsers to DefUseManager
Added some helper methods for the inst to block mapping in context
Added some helper methods for specific constant types
No longer generate duplicate pointer types.
* Now searches for an existing pointer of the appropriate type instead
of failing validation
* Fixed spec constant extracts
* Addressed changes for review
* Changed RunSinglePassAndMatch to be able to run validation
* current users do not enable it
Added handling of acceptable decorations.
* Decorations are also transfered where appropriate
Refactored extension checking into FeatureManager
* Context now owns a feature manager
* consciously NOT an analysis
* added some test
* fixed some minor issues related to decorates
* added some decorate related tests for scalar replacement
GregF [Fri, 8 Dec 2017 17:44:15 +0000 (10:44 -0700)]
MultiStore: Support OpVariable Initialization
Treat an OpVariable with initialization as if it was an OpStore.
With PR #1073, this completes work for issue #1017.
Pierre Moreau [Sat, 9 Dec 2017 20:50:38 +0000 (21:50 +0100)]
Add external/SPIRV-Headers to .gitignore
b93c066b allowed for both SPIRV-Headers and spirv-headers as valid
paths, but only the latter is being ignored by Git.
GregF [Thu, 7 Dec 2017 19:11:29 +0000 (12:11 -0700)]
SingleStore: Support OpVariable Initialization
Treat an OpVariable with initialization as if it was an OpStore.
This fixes issue #1017.
Steven Perron [Thu, 7 Dec 2017 15:55:57 +0000 (10:55 -0500)]
Add option to spirv-opt to skip the validator.
The option --skip-validation is added. When used it will skip the
validation step.
Also rearranged the help text to fix two options that are out of order.
Diego Novillo [Thu, 7 Dec 2017 21:42:27 +0000 (16:42 -0500)]
Add a new constant manager class.
This patch adds a new constant manager class to interface with
analysis::Constant. The new constant manager lives in ir::IRContext
together with the type manager (analysis::TypeManager).
The new analysis::ConstantManager is used by the spec constant folder
and the constant propagator (in progress).
Another cleanup introduced by this patch removes the ID management from
the fold spec constant pass, and ir::IRContext and moves it to
ir::Module. SSA IDs were maintained by IRContext and Module. That's
pointless and leads to mismatch IDs. Fixed by moving all the bookkeeping
to ir::Module.
Steven Perron [Mon, 4 Dec 2017 17:29:51 +0000 (12:29 -0500)]
Add global redundancy elimination
Adds a pass that looks for redundant instruction in a function, and
removes them. The algorithm is a hash table based value numbering
algorithm that traverses the dominator tree.
This pass removes completely redundant instructions, not partially
redundant ones.
Steven Perron [Thu, 7 Dec 2017 03:09:20 +0000 (22:09 -0500)]
Kill names and decoration in inlining.
Currently when inlining a call, the name and decorations for the result of the
call is not deleted. This should be changed. Added a test for this as well.
This fixes issue #622.
Victor Lomuller [Mon, 4 Dec 2017 14:36:05 +0000 (14:36 +0000)]
Add depth first iterator for trees
- Add generic depth first iterator
- Update the dominator tree to use this iterator instead of "randomly"
iterate over the nodes
Diego Novillo [Wed, 6 Dec 2017 19:56:56 +0000 (14:56 -0500)]
Revert extraneous changes from commit
8ec62deb2.
Commit
8ec62deb2 merged the code from PR #810, but it also re-introduces
code that had been removed in #885.
This patch removes the (now superfluous code).
Stephen McGroarty [Mon, 27 Nov 2017 21:21:26 +0000 (21:21 +0000)]
Dominator Tree Analysis (#3)
Support for dominator and post dominator analysis on ir::Functions. This patch contains a DominatorTree class for building the tree and DominatorAnalysis and DominatorAnalysisPass classes for interfacing and caching the built trees.
Diego Novillo [Tue, 5 Dec 2017 16:28:12 +0000 (11:28 -0500)]
Sort flags in help message - NFC.
It's slightly easier to read flags from --help if they're sorted.
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