Skip to content
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

Missing debug info operands can be marked also with 'DebugInfoNone' #5245

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 32 additions & 21 deletions source/val/validate_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,28 @@ spv_result_t ValidateDebugInfoOperand(
if (result != SPV_SUCCESS) return result; \
} while (0)

#define CHECK_OPTIONAL_DEBUG_OPERAND(NAME, operand_type, index) \
do { \
if (num_words == index + 1 && !DoesDebugInfoOperandMatchExpectation( \
_, \
[](CommonDebugInfoInstructions dbg_inst) { \
return dbg_inst == CommonDebugInfoDebugInfoNone; \
}, \
inst, index)) { \
CHECK_OPERAND(NAME, operand_type, index); \
} } while (false)

#define CHECK_OPTIONAL_DEBUG_OPERAND_VAL(NAME, operand_type, index) \
do { \
if (num_words == index + 1 && !DoesDebugInfoOperandMatchExpectation( \
_, \
[](CommonDebugInfoInstructions dbg_inst) { \
return dbg_inst == CommonDebugInfoDebugInfoNone; \
}, \
inst, index)) { \
CHECK_DEBUG_OPERAND(NAME, operand_type, index); \
} } while (false)

// Check that the operand of a debug info instruction |inst| at |word_index|
// is a result id of an debug info instruction with DebugTypeBasic.
spv_result_t ValidateOperandBaseType(
Expand Down Expand Up @@ -3158,7 +3180,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
}
case CommonDebugInfoDebugSource: {
CHECK_OPERAND("File", spv::Op::OpString, 5);
if (num_words == 7) CHECK_OPERAND("Text", spv::Op::OpString, 6);
CHECK_OPTIONAL_DEBUG_OPERAND("Text", spv::Op::OpString, 6);
break;
}
case CommonDebugInfoDebugTypeBasic: {
Expand Down Expand Up @@ -3388,8 +3410,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
CHECK_OPERAND("Offset", spv::Op::OpConstant, 11);
CHECK_OPERAND("Size", spv::Op::OpConstant, 12);
CHECK_CONST_UINT_OPERAND("Flags", 13);
if (num_words == 15)
CHECK_OPERAND("Value", spv::Op::OpConstant, 14);
CHECK_OPTIONAL_DEBUG_OPERAND("Value", spv::Op::OpConstant, 14);
}
break;
}
Expand Down Expand Up @@ -3438,10 +3459,8 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
// NonSemantic.Shader.DebugInfo.100 doesn't include a reference to the
// OpFunction
if (vulkanDebugInfo) {
if (num_words == 15) {
CHECK_DEBUG_OPERAND("Declaration",
CommonDebugInfoDebugFunctionDeclaration, 14);
}
CHECK_OPTIONAL_DEBUG_OPERAND_VAL("Declaration",
CommonDebugInfoDebugFunctionDeclaration, 14);
} else {
if (!DoesDebugInfoOperandMatchExpectation(
_,
Expand All @@ -3451,10 +3470,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
inst, 14)) {
CHECK_OPERAND("Function", spv::Op::OpFunction, 14);
}
if (num_words == 16) {
CHECK_DEBUG_OPERAND("Declaration",
CommonDebugInfoDebugFunctionDeclaration, 15);
}
CHECK_OPTIONAL_DEBUG_OPERAND_VAL("Declaration", CommonDebugInfoDebugFunctionDeclaration, 15);
}
break;
}
Expand All @@ -3480,16 +3496,14 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
auto validate_parent =
ValidateOperandLexicalScope(_, "Parent", inst, 8, ext_inst_name);
if (validate_parent != SPV_SUCCESS) return validate_parent;
if (num_words == 10) CHECK_OPERAND("Name", spv::Op::OpString, 9);
CHECK_OPTIONAL_DEBUG_OPERAND("Name", spv::Op::OpString, 9);
break;
}
case CommonDebugInfoDebugScope: {
auto validate_scope =
ValidateOperandLexicalScope(_, "Scope", inst, 5, ext_inst_name);
if (validate_scope != SPV_SUCCESS) return validate_scope;
if (num_words == 7) {
CHECK_DEBUG_OPERAND("Inlined At", CommonDebugInfoDebugInlinedAt, 6);
}
CHECK_OPTIONAL_DEBUG_OPERAND_VAL("Inlined At", CommonDebugInfoDebugInlinedAt, 6);
break;
}
case CommonDebugInfoDebugLocalVariable: {
Expand Down Expand Up @@ -3622,9 +3636,8 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
"OpVariable or OpConstant or DebugInfoNone";
}
}
if (num_words == 15) {
CHECK_DEBUG_OPERAND("Static Member Declaration",
CommonDebugInfoDebugTypeMember, 14);
CHECK_OPTIONAL_DEBUG_OPERAND_VAL("Static Member Declaration",
CommonDebugInfoDebugTypeMember, 14);
}
break;
}
Expand All @@ -3633,9 +3646,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
auto validate_scope =
ValidateOperandLexicalScope(_, "Scope", inst, 6, ext_inst_name);
if (validate_scope != SPV_SUCCESS) return validate_scope;
if (num_words == 8) {
CHECK_DEBUG_OPERAND("Inlined", CommonDebugInfoDebugInlinedAt, 7);
}
CHECK_OPTIONAL_DEBUG_OPERAND_VAL("Inlined", CommonDebugInfoDebugInlinedAt, 7);
break;
}
case CommonDebugInfoDebugValue: {
Expand Down