-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle conflict between debug info and existing validation rule #3104
Conversation
3a560d9
to
e7bdcdc
Compare
After submitting this CL, I will create a separate PR for the validation of debug info itself. |
source/opt/ir_context.h
Outdated
// Iterators for debug info instructions (excluding OpLine & OpNoLine) | ||
// contained in this module. These are OpExtInst for OpenCL.DebugInfo.100 | ||
// or DebugInfo extension placed between section 9 and 10. | ||
inline Module::inst_iterator debuginfo_begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is confusing because there are so many kinds of debug info.
Please rename this to ext_inst_debuginfo or ext_inst_debug_info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/opt/ir_context.h
Outdated
@@ -1018,6 +1044,10 @@ void IRContext::AddDebug3Inst(std::unique_ptr<Instruction>&& d) { | |||
module()->AddDebug3Inst(std::move(d)); | |||
} | |||
|
|||
void IRContext::AddDebugInfoInst(std::unique_ptr<Instruction>&& d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename this method to AddExtInstDebugInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/opt/ir_loader.cpp
Outdated
const uint32_t ext_inst_index = inst->words[4]; | ||
const OpenCLDebugInfo100Instructions ext_inst_key = | ||
OpenCLDebugInfo100Instructions(ext_inst_index); | ||
if (ext_inst_key != OpenCLDebugInfo100DebugScope && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this code is executed with a module using the older DebugInfo extended instruction set?
Does it work by accident? fail by accident?
Please add a comment about what is expected to work. And if it's easy to make work with DebugInfo, then please do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I just added supporting the old DebugInfo extension as well.
Note that there is a serious spec issue in the old DebugInfo that it requires to use the result id of OpSource
for DebugCompilationUnit
, which does not exist (OpSource
does not have a result id).
I just added only one simple test case for the old DebugInfo.
@@ -52,6 +52,13 @@ RemoveUnreferencedInstructionReductionOpportunityFinder:: | |||
result.push_back(MakeUnique<RemoveInstructionReductionOpportunity>(&inst)); | |||
} | |||
|
|||
for (auto& inst : context->module()->debuginfo()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a nice touch to add this to the fuzzer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL!
source/opt/ir_context.h
Outdated
// Iterators for debug info instructions (excluding OpLine & OpNoLine) | ||
// contained in this module. These are OpExtInst for OpenCL.DebugInfo.100 | ||
// or DebugInfo extension placed between section 9 and 10. | ||
inline Module::inst_iterator debuginfo_begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/opt/ir_context.h
Outdated
@@ -1018,6 +1044,10 @@ void IRContext::AddDebug3Inst(std::unique_ptr<Instruction>&& d) { | |||
module()->AddDebug3Inst(std::move(d)); | |||
} | |||
|
|||
void IRContext::AddDebugInfoInst(std::unique_ptr<Instruction>&& d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/opt/ir_loader.cpp
Outdated
const uint32_t ext_inst_index = inst->words[4]; | ||
const OpenCLDebugInfo100Instructions ext_inst_key = | ||
OpenCLDebugInfo100Instructions(ext_inst_index); | ||
if (ext_inst_key != OpenCLDebugInfo100DebugScope && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I just added supporting the old DebugInfo extension as well.
Note that there is a serious spec issue in the old DebugInfo that it requires to use the result id of OpSource
for DebugCompilationUnit
, which does not exist (OpSource
does not have a result id).
I just added only one simple test case for the old DebugInfo.
c2d40f4
to
eadbeb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good.
I'd like another test please.
source/val/validate_layout.cpp
Outdated
if (_.current_layout_section() < kLayoutTypes || | ||
_.current_layout_section() >= kLayoutFunctionDeclarations) { | ||
return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) | ||
<< "OpenCL.DebugInfo.100 instructions other than " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This applies to both OpenCL.DebugInfo.100 and DebugInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the wording "Debug info extension instructions other than .. "
// DebugScope, DebugNoScope, DebugDeclare, DebugValue must | ||
// appear in a function body. | ||
return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) | ||
<< "DebugScope, DebugNoScope, DebugDeclare, DebugValue " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This failure is not tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
source/val/validate_layout.cpp
Outdated
if (_.current_layout_section() < kLayoutTypes || | ||
_.current_layout_section() >= kLayoutFunctionDeclarations) { | ||
return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) | ||
<< "OpenCL.DebugInfo.100 instructions other than " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the wording "Debug info extension instructions other than .. "
// DebugScope, DebugNoScope, DebugDeclare, DebugValue must | ||
// appear in a function body. | ||
return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) | ||
<< "DebugScope, DebugNoScope, DebugDeclare, DebugValue " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
Roll third_party/glslang/ 965bd4d..19ec0d2 (4 commits) KhronosGroup/glslang@965bd4d...19ec0d2 $ git log 965bd4d..19ec0d2 --date=short --no-merges --format='%ad %ae %s' 2020-01-27 cepheus Build: Fix more build warnings caused by PR KhronosGroup#2038. 2020-01-26 cepheus Build warning: Fix KhronosGroup#2062, missing enum value in a switch. 2019-12-24 laddoc Add Tess machine dependent built-in variables initialization for GLES 3.2 2019-10-18 timo.suoranta Fixes for gcc 9 / -Werror=deprecated-copy Roll third_party/googletest/ 8b4817e3d..10b1902d8 (6 commits) google/googletest@8b4817e...10b1902 $ git log 8b4817e3d..10b1902d8 --date=short --no-merges --format='%ad %ae %s' 2020-01-21 absl-team Googletest export 2020-01-17 absl-team Googletest export 2020-01-16 absl-team Googletest export 2020-01-15 36923279+ivan1993br Remove exclusion of *-main and*-all targets 2020-01-12 hilmanbeyri Use IsReadableTypeName IsReadableTypeName in OfType function in gmock-matchers_test.cc 2020-01-12 hilmanbeyri fix unit test failure on NoShortCircuitOnFailure and DetectsFlakyShortCircuit when GTEST_HAS_RTTI is 1 Roll third_party/spirv-cross/ f9818f080..68bf0f824 (6 commits) KhronosGroup/SPIRV-Cross@f9818f0...68bf0f8 $ git log f9818f080..68bf0f824 --date=short --no-merges --format='%ad %ae %s' 2020-01-27 post Compile fix on older compilers. 2020-01-27 post GLSL: Support GL_ARB_enchanced_layouts for XFB. 2020-01-25 cdavis MSL: Move inline uniform blocks to the end of the argument buffer. 2019-12-16 cdavis MSL: Support inline uniform blocks in argument buffers. 2020-01-23 post Make SmallVector noexcept. 2020-01-22 42098783+barath121 Typo at line 324 Roll third_party/spirv-headers/ 204cd13..dc77030 (2 commits) KhronosGroup/SPIRV-Headers@204cd13...dc77030 $ git log 204cd13..dc77030 --date=short --no-merges --format='%ad %ae %s' 2020-01-20 dneto Fix the license to match LICENSE 2020-01-20 syoussefi Add BUILD.gn Roll third_party/spirv-tools/ 323a81f..1b34410 (9 commits) KhronosGroup/SPIRV-Tools@323a81f...1b34410 $ git log 323a81f..1b34410 --date=short --no-merges --format='%ad %ae %s' 2020-01-24 syoussefi Fix chromium build (KhronosGroup#3152) 2020-01-24 dneto Clarify mapping of target env to SPIR-V version (KhronosGroup#3150) 2020-01-24 greg Use dummy switch instead of dummy loop in MergeReturn pass. (KhronosGroup#3151) 2020-01-23 alanbaker Fix structured exit validation (KhronosGroup#3141) 2020-01-23 dneto Add spvParseVulkanEnv (KhronosGroup#3142) 2020-01-23 jaebaek Handle conflict between debug info and existing validation rule (KhronosGroup#3104) 2020-01-23 syoussefi Use spirv-headers' BUILD.gn (KhronosGroup#3148) 2020-01-23 syoussefi Roll external/spirv-headers/ af64a9e..dc77030 (4 commits) (KhronosGroup#3147) 2020-01-21 afdx spirv-fuzz: Refactoring and type-related fixes (KhronosGroup#3144) Created with: roll-dep third_party/effcee third_party/glslang third_party/googletest third_party/re2 third_party/spirv-cross third_party/spirv-headers third_party/spirv-tools
This commit includes several changes to resolve conflict between
OpenCL.100.debug extension instructions and existing validation
rule.
OpExtInst
between section 9 (type, const) andsection 10 (function) when it is used for debug info (fixes Contradiction between OpExtInst and debug extension spec #3086).
OpFunction
fromDebugFunction
(fixes DebugFunction has a function as its operand which results in spirv-val "not defined ID" error #3102).OpExtInst
forDebugScope
,DebugNoScope
,DebugDeclare
, andDebugValue
betweenOpLabel
andOpVariable
for function local variable (fixes OpVariable whose storage class is Function right after debug info instructions causes a spirv-val error #3103).
running spirv-opt the same with the initial SPIR-V code with debug
info.