spirv-opt: Improve the code of the Instruction class#3610
spirv-opt: Improve the code of the Instruction class#3610s-perron merged 2 commits intoKhronosGroup:masterfrom
Conversation
afd
left a comment
There was a problem hiding this comment.
I took a quick look at this out of curiosity - I don't own this file so would not be comfortable approving; I recommend you ask @alan-baker or @s-perron to review. However:
-
In the PR description you should explain the nature of the improvements briefly and the motivation for them.
-
Some of the "improvements" might be subjective - e,g, I do tend to favour the longer variable names that you've introduced here, and I personally like to avoid single statement loops/conditionals, but the Google style does not disallow them and some people like them; from the Google style:
"In general, curly braces are not required for single-line statements, but they are allowed if you like them; conditional or loop statements with complex conditions or statements may be more readable with curly braces. Some projects require that an if must always have an accompanying brace."
- I wouldn't be surprised if there is push back on your replacement of calls to getters with direct member accesses, as that looked like a pretty deliberate style thing in this part of the code base.
s-perron
left a comment
There was a problem hiding this comment.
This looks reasonable, but I would be interested in knowing the reason for the change. Minor changes just for personal preference could create a lot of changes that might not add much value.
I like the braces around a single line if or for, but that is just a matter of personal preference. We don't believe it helps with readability, but I like that it make it easier to add debugging code if needed.
The longer name are good. Avoiding the single letter name like "i" is good. This help readability. However, some abbreviations are acceptable because they are so common. For example "inst" is an acceptable abbreviation. We use them because we keep our lines to 80 characters. If we named the variable "last_instruction_in_the_basic_block" it would use of almost have the line so "last_inst_in_bb" is acceptable. Splitting up a statement over multiple lines makes things less readable.
To make refactoring easier, we prefer to use the accessor functions, even if the value is available in a member variable. I know we are not consistent on this. If we were to fix this I would go the other way. Add more uses of the functions. Note that the accessor function should all be inline function, and their uses should be inlined by the compiler. That means they should not have any overhead.
|
@s-perron, I was taking a look at the |
|
Fix some of the issue. Undo those the changes that I specifically mentioned. |
0392bd9 to
092756e
Compare
|
@s-perron, I made the changes. Could you review them? |
|
@s-perron, I guess it is ready to be merged. |
Roll third_party/glslang/ 3ee5f2f..b60e067 (8 commits) KhronosGroup/glslang@3ee5f2f...b60e067 $ git log 3ee5f2f..b60e067 --date=short --no-merges --format='%ad %ae %s' 2020-08-06 john SPV: Fix KhronosGroup#1829: don't emit OpModuleProcessed use-storage-buffer 2020-08-05 john Build/Test: Dropping 2013 allows using the latest googletests. 2020-08-04 john SPV: Standalone; sanity check the client GLSL input semantics option value. 2020-08-04 john SPV: Use more correct SPV-Tools environment, partially addressing KhronosGroup#2290 2020-08-04 john SPV: Fix KhronosGroup#2363: include trailing newline named text SPV output. 2020-07-03 ShabbyX Use GLSLANG_ANGLE to strip features to what ANGLE requires 2020-07-31 bclayton Revert changes that migrate to `thread_local`. 2020-07-27 dneto Avoid spurious warning about uninit var Created with: roll-dep third_party/glslang Roll third_party/googletest/ a781fe29b..3af06fe16 (12 commits) google/googletest@a781fe2...3af06fe $ git log a781fe29b..3af06fe16 --date=short --no-merges --format='%ad %ae %s' 2020-08-05 absl-team Googletest export 2020-08-03 absl-team Googletest export 2020-08-03 absl-team Googletest export 2020-08-05 zumix.cpp fix endif comment 2020-08-02 zumix.cpp fix tests 2020-07-29 franciscogthiesen Removing tiny-dnn from "Who is using.." 2020-07-28 absl-team Googletest export 2020-07-29 zumix.cpp fix GTEST_REMOVE_LEGACY_TEST_CASEAPI_ typo 2020-07-28 absl-team Googletest export 2020-07-26 ofats Googletest export 2020-07-19 jasjuang fix clang tidy modernize-use-equals-default warnings 2020-07-02 siliconearth Fix test failing when simple regex is used Created with: roll-dep third_party/googletest Roll third_party/spirv-cross/ 0376576d2..82d1c43e4 (7 commits) KhronosGroup/SPIRV-Cross@0376576...82d1c43 $ git log 0376576d2..82d1c43e4 --date=short --no-merges --format='%ad %ae %s' 2020-08-03 cdavis MSL: Fix handling of matrices and structs in the output control point array. 2020-07-29 post Add some test cases for complex type aliasing scenario. 2020-07-29 post Ensure that we use primary alias type when emitting flattened members. 2020-07-29 post GLSL: Be more aggressive about using type_alias. 2020-07-29 post Only rewrite type aliases for the base type. 2020-07-28 post GLSL: Add option to force flattening IO blocks. 2020-07-23 tommek Adding BuiltInSampleMask in HLSL Created with: roll-dep third_party/spirv-cross Roll third_party/spirv-headers/ 979924c..3fdabd0 (4 commits) KhronosGroup/SPIRV-Headers@979924c...3fdabd0 $ git log 979924c..3fdabd0 --date=short --no-merges --format='%ad %ae %s' 2020-08-03 44190824+mmerecki Reserve SPIR-V token range for upcoming Intel extensions. (KhronosGroup#165) 2020-07-29 alanbaker Update BUILD.bazel and BUILD.gn (KhronosGroup#166) 2020-07-29 alanbaker Publish the headers for the clspv embedded reflection non-semantic extended instruction set (KhronosGroup#164) 2020-07-29 johnkslang Update the registry in spir-v.xml to modernize and split out opcodes. (KhronosGroup#156) Created with: roll-dep third_party/spirv-headers Roll third_party/spirv-tools/ b63f0e5..2990a21 (30 commits) KhronosGroup/SPIRV-Tools@b63f0e5...2990a21 $ git log b63f0e5..2990a21 --date=short --no-merges --format='%ad %ae %s' 2020-08-10 stevenperron Avoid using /MP4 for clang on windows. (KhronosGroup#3662) 2020-08-06 antonikarp spirv-fuzz: TransformationReplaceAddSubMulWithCarryingExtended (KhronosGroup#3598) 2020-08-06 andreperezmaselco.developer spirv-fuzz: Add TransformationMakeVectorOperationDynamic (KhronosGroup#3597) 2020-08-06 andreperezmaselco.developer spirv-fuzz: iterate over blocks in replace linear algebra pass (KhronosGroup#3654) 2020-08-06 stefanomil spirv-fuzz: make outliner pass use additional transformations (KhronosGroup#3604) 2020-08-05 jaebaek OpenCL.DebugInfo.100 DebugTypeArray with variable size (KhronosGroup#3549) 2020-08-05 andreperezmaselco.developer spirv-opt: Improve the code of the Instruction class (KhronosGroup#3610) 2020-08-05 vasniktel spirv-fuzz: Handle OpPhis in livesafe functions (KhronosGroup#3642) 2020-08-05 vasniktel spirv-fuzz: Handle OpPhi during constant obfuscation (KhronosGroup#3640) 2020-08-05 vasniktel spirv-fuzz: Fix FuzzerPassCopyObjects (KhronosGroup#3638) 2020-08-04 vasniktel spirv-fuzz: Remove OpFunctionCall operands in correct order (KhronosGroup#3630) 2020-08-04 vasniktel spirv-fuzz: Handle capabilities during module donation (KhronosGroup#3651) 2020-08-04 vasniktel spirv-fuzz: Refactor boilerplate in TransformationAddParameter (KhronosGroup#3625) 2020-08-03 vasniktel spirv-fuzz: TransformationMoveInstructionDown (KhronosGroup#3477) 2020-07-31 jaebaek Remove DebugDeclare only for target variables in ssa-rewrite (KhronosGroup#3511) 2020-07-31 vasniktel Fix typo in ASAN CI build (KhronosGroup#3623) 2020-07-30 stefanomil spirv-fuzz: Transformation to add loop preheader (KhronosGroup#3599) 2020-07-30 stefanomil spirv-fuzz: Pass to replace int operands with ints of opposite signedness (KhronosGroup#3612) 2020-07-30 jaebaek Debug info preservation in loop-unroll pass (KhronosGroup#3548) 2020-07-30 alanbaker Validator support for non-semantic clspv reflection (KhronosGroup#3618) 2020-07-30 vasniktel spirv-fuzz: Fix memory bugs (KhronosGroup#3622) 2020-07-29 andreperezmaselco.developer spirv-fuzz: Implement the OpOuterProduct linear algebra case (KhronosGroup#3617) 2020-07-30 vasniktel spirv-fuzz: Compute corollary facts from OpBitcast (KhronosGroup#3538) 2020-07-29 dj2 Update some language usage. (KhronosGroup#3611) 2020-07-29 vasniktel spirv-fuzz: Relax type constraints in DataSynonym facts (KhronosGroup#3602) 2020-07-29 vasniktel spirv-fuzz: Remove non-deterministic behaviour (KhronosGroup#3608) 2020-07-29 afdx Avoid use of 'sanity' and 'sanity check' in the code base (KhronosGroup#3585) 2020-07-27 andreperezmaselco.developer spirv-fuzz: Add condition to make functions livesafe (KhronosGroup#3587) 2020-07-27 rharrison Rolling 4 dependencies (KhronosGroup#3601) 2020-07-27 andreperezmaselco.developer spirv-fuzz: Implement the OpTranspose linear algebra case (KhronosGroup#3589) Created with: roll-dep third_party/spirv-tools
This PR makes some improvements to the source code of the Instruction class,
choosing better names for variables and avoiding unnecessary function calls.