Commit Graph

149 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
dan sinclair
ab061afc83
Update diag() calls in validate_type_unique. (#1775)
This CL updates the diag() calls in validate_type_unique to pass the
relevant instruction.
2018-08-01 13:13:44 -04:00
dan sinclair
78335c927a
Update diag() calls in validate_primitives. (#1774)
This CL updates the diag() calls in validate_primitives to provide the
relevant instruction.
2018-08-01 13:00:38 -04:00
dan sinclair
6bb9ab48b8
Update diag() calls in validate_non_uniform. (#1773)
This CL upldates diag() calls in validate_non_uniform to provide the
relevant instruction.
2018-08-01 12:49:43 -04:00
dan sinclair
7c9a73fc30
Update diag() calls in validate_logicals. (#1772)
This CL updates the diag() calls in validate_logicals to provide the
Instruction.
2018-08-01 12:41:57 -04:00
dan sinclair
72766d9e88
Update diag() calls in validate_literals. (#1771)
This CL updates the diag() call in validate_literals to provide the
relevant instruction.
2018-08-01 12:41:46 -04:00
dan sinclair
e1e20f1abe
Update diag() calls in validate_layout. (#1770)
This CL updates the diag() calls in validate_layout to pass the relevant
instruction.
2018-08-01 12:01:35 -04:00
dan sinclair
f37e8d74e7
Update diag() call in validate_interface. (#1769)
This CL upldates validate_interface to pass the instruction to the
diag() method.
2018-08-01 11:58:37 -04:00
dan sinclair
d792ccd1ee
Update diag() calls in validate_instruction. (#1768)
This CL updates validate_instruction to pass the Instruction to diag().
2018-08-01 11:37:02 -04:00
dan sinclair
176cb5e593
Update diag() calls in validate_image. (#1767)
This CL updates the diag() calls in validate_image to provide the
relvant instruction.
2018-08-01 11:30:28 -04:00
dan sinclair
c64bad70d9
Update diag() calls in validate_ext_inst. (#1766)
This CL updates the diag() usage in validate_ext_inst to provide the
relevant instruction.
2018-08-01 11:11:23 -04:00
dan sinclair
441c0190eb
Update diag() calls in validate_derivatives. (#1765)
This CL updates diag() in validate_derivatives to provide the
instruction of interest.
2018-08-01 11:04:22 -04:00
dan sinclair
83b7f2b674
Update diag() calls in validate_decorations. (#1764)
Several of the diag() calls in validate_decorations do not provide the
line number, and will output the last line in the file. This CL updates
the diag() calls to provide the instruction of interest.
2018-08-01 10:44:27 -04:00
dan sinclair
a504656dad
Remove std::deque in favour of std::vector. (#1755)
This CL removes the two deque's from ValidationState and converts them
into std::vectors. In order to maintain the stability of instructions we
walk over the binary and counter the instructions and functions in the
ValidationState constructor and reserve the required number of items in
the module_functions_ and ordered_instructions_ vectors.

Issue #1176.
2018-08-01 10:37:36 -04:00
dan sinclair
fae987b470
Update diag() calls in validate_datarules. (#1763)
This CL updates validate_datarules to provide the instruction to diag().
2018-08-01 10:35:19 -04:00
dan sinclair
5a59a06e24
Update diag() calls in validate_conversion. (#1762)
This CL updates validate_conversion to provide the instruction to diag()
calls.
2018-08-01 10:18:06 -04:00
dan sinclair
eb03b152da
Update diag() calls in validate_composites. (#1761)
This CL updates the diag() calls in validate_composites to provide the
instruction directly.
2018-08-01 10:07:53 -04:00
dan sinclair
2c5f1b01d8
Update diag() calls in validate_cfg. (#1760)
This CL updates the diag() calls in validate_cfg to provide the
associated instruction. This fixes a couple places where we output the
last line of the file instead of the instruction as the disassembly.
2018-08-01 09:52:16 -04:00
dan sinclair
3619de9ad5
Update diag() use in validate_builtin. (#1758)
This CL updates the calls to diag() in vlidate_builtings to provide the
instruction.
2018-08-01 09:31:31 -04:00
dan sinclair
12c1f2b603
Update diag() usage in validate_bitwise. (#1757)
This Cl upldates the diag() calls to pass the instruction in
validate_bitwise.
2018-08-01 09:19:37 -04:00
dan sinclair
111933537b
Update diag() in validate_barriers (#1754)
This CL updates validate_barriers to provide an explicit instruction
when calling diag().
2018-07-31 18:44:35 -04:00
dan sinclair
32ccf0d04c
Update diag() in validate_atomics (#1753)
This CL updates validate_atomics to explicitly provide the instruction
when caling diag().
2018-07-31 17:20:43 -04:00
dan sinclair
a4fe771da7
Pass the instruction to diag in arithmetic validation (#1752)
This CL updates the diag() calls in validate_arithmetics to explicitly
provide the instruction the diagnostic is attached too.
2018-07-31 16:26:58 -04:00
dan sinclair
dfb53f9f1a
Fix disassembly line for adjacency validations. (#1751)
Previously the adjacency messages would output the last line of the file
as the disassembly. This is incorrect, as we have an instruction they
can be attached too. This CL fixes the messages to attach to the correct
line number.
2018-07-31 15:31:09 -04:00
dan sinclair
b7afe4e7ae
Switch validate to use explicit diag() method. (#1750)
This CL changes validate.cpp to use diag providing an explicit
instruction. This changes the result of the function end checks to not
output a disassembly anymore as printing the last line of the module
didn't seem to make sense.
2018-07-31 14:53:10 -04:00
dan sinclair
a9d8fceec9
Change ValidationState::diag to accept an Instruction. (#1749)
This CL changes the signature of diag() to accept an Instruction instead
of the instructions position.

A deprecated variant that accepts the position is available but will be
removed in the near future.
2018-07-31 14:19:34 -04:00
Dan Sinclair
f28ed82fd9 Make sure all instructions are in the ordered list.
Currently, some instructions will be missing from the list of
ordered_instructions. This will cause issues due to the debug change
which passed the last instruction into subsequent passes.

This CL moves the addition to the ordered list out of the
RegisterInstruction method into AddOrderedInstruction. This method is
called first in ProcessInstruction and the CapabilitiesPass and IdPass
are updated to take an Instruction parameter.
2018-07-31 09:55:57 -04:00
dan sinclair
dcea11fa03
Update error messages in validate_composites. (#1743)
This CL removes the redundant operator name from the error messages in
validate_composites. The operator will be printed on the next line with
the disassembly.
2018-07-31 09:52:14 -04:00
dan sinclair
dcb0dc21de
Split ImagePass into individual methods. (#1742)
This CL splits the switch in ImagePass into individual validate
functions. The error messages have been updated to drop the
suffix/prefix of the opcode name since it will be displayed in the
disassembly.
2018-07-30 16:59:29 -04:00
dan sinclair
673483d6a7
Move OpVectorShuffle check into validate_composites (#1741)
This CL moves the OpVectorShuffle ID check out of validate_id and into
validate_composites with the rest of the composite checks.
2018-07-30 16:12:49 -04:00
dan sinclair
ee22928bd9
Move CompositePass code into methods. (#1740)
This Cl splits the CompositePass switch to have one method per case
label. This makes the code a lot simpler to follow.
2018-07-30 13:06:03 -04:00