spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493)

Includes:
- Shift to use of spirv-header extinst.nonsemantic.shader grammar.json
- Remove extinst.nonsemantic.vulkan.debuginfo.100.grammar.json
- Enable all optimizations for Shader.DebugInfo

Also fixes scalar replacement to only insert DebugValue after all
OpVariables. This is not necessary for OpenCL.DebugInfo, but it is
for Shader.DebugInfo.

Likewise, fixes Private-to-Local to insert DebugDeclare after all
OpVariables.

Also fixes inlining to handle FunctionDefinition which can show up
after first block if early return processing happens.

Co-authored-by: baldurk <baldurk@baldurk.org>
This commit is contained in:
Greg Fischer 2021-09-15 12:38:53 -06:00 committed by GitHub
parent 4ac8e5e541
commit 1454c95d1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 547 additions and 858 deletions

View File

@ -184,7 +184,7 @@ SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.glsl.st
SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.std.100.grammar.json
SPV_DEBUGINFO_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.debuginfo.grammar.json
SPV_CLDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json
SPV_VKDEBUGINFO100_GRAMMAR=$(LOCAL_PATH)/source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json
SPV_VKDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json
define gen_spvtools_grammar_tables
$(call generate-file-dir,$(1)/core.insts-unified1.inc)
@ -216,7 +216,7 @@ $(LOCAL_PATH)/source/ext_inst.cpp: \
$(1)/opencl.std.insts.inc \
$(1)/debuginfo.insts.inc \
$(1)/opencl.debuginfo.100.insts.inc \
$(1)/nonsemantic.vulkan.debuginfo.100.insts.inc \
$(1)/nonsemantic.shader.debuginfo.100.insts.inc \
$(1)/spv-amd-gcn-shader.insts.inc \
$(1)/spv-amd-shader-ballot.insts.inc \
$(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
@ -246,7 +246,7 @@ endef
# We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticVulkanDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
define gen_spvtools_vendor_tables
@ -261,22 +261,10 @@ $(1)/$(2).insts.inc : \
@echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
endef
define gen_spvtools_vendor_tables_local
$(call generate-file-dir,$(1)/$(2).insts.inc)
$(1)/$(2).insts.inc : \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(LOCAL_PATH)/source/extinst.$(2).grammar.json
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--extinst-vendor-grammar=$(LOCAL_PATH)/source/extinst.$(2).grammar.json \
--vendor-insts-output=$(1)/$(2).insts.inc \
--vendor-operand-kind-prefix=$(3)
@echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
endef
# Vendor and debug extended instruction sets, with grammars from SPIRV-Tools source tree.
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
$(eval $(call gen_spvtools_vendor_tables_local,$(SPVTOOLS_OUT_PATH),nonsemantic.vulkan.debuginfo.100,"VKDEBUG100_"))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.shader.debuginfo.100,"SHDEBUG100_"))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))

View File

@ -3,7 +3,7 @@ load(
"COMMON_COPTS",
"DEBUGINFO_GRAMMAR_JSON_FILE",
"CLDEBUGINFO100_GRAMMAR_JSON_FILE",
"VKDEBUGINFO100_GRAMMAR_JSON_FILE",
"SHDEBUGINFO100_GRAMMAR_JSON_FILE",
"TEST_COPTS",
"base_test",
"generate_core_tables",
@ -12,7 +12,6 @@ load(
"generate_glsl_tables",
"generate_opencl_tables",
"generate_vendor_tables",
"generate_vendor_tables_local",
"link_test",
"lint_test",
"opt_test",
@ -62,7 +61,7 @@ generate_vendor_tables("debuginfo")
generate_vendor_tables("opencl.debuginfo.100", "CLDEBUG100_")
generate_vendor_tables_local("nonsemantic.vulkan.debuginfo.100", "VKDEBUG100_")
generate_vendor_tables("nonsemantic.shader.debuginfo.100", "SHDEBUG100_")
generate_vendor_tables("nonsemantic.clspvreflection")
@ -70,7 +69,7 @@ generate_extinst_lang_headers("DebugInfo", DEBUGINFO_GRAMMAR_JSON_FILE)
generate_extinst_lang_headers("OpenCLDebugInfo100", CLDEBUGINFO100_GRAMMAR_JSON_FILE)
generate_extinst_lang_headers("NonSemanticVulkanDebugInfo100", VKDEBUGINFO100_GRAMMAR_JSON_FILE)
generate_extinst_lang_headers("NonSemanticShaderDebugInfo100", SHDEBUGINFO100_GRAMMAR_JSON_FILE)
py_binary(
name = "generate_registry_tables",
@ -108,14 +107,14 @@ cc_library(
":gen_enum_string_mapping",
":gen_extinst_lang_headers_DebugInfo",
":gen_extinst_lang_headers_OpenCLDebugInfo100",
":gen_extinst_lang_headers_NonSemanticVulkanDebugInfo100",
":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
":gen_glsl_tables_unified1",
":gen_opencl_tables_unified1",
":gen_registry_tables",
":gen_vendor_tables_debuginfo",
":gen_vendor_tables_nonsemantic_clspvreflection",
":gen_vendor_tables_opencl_debuginfo_100",
":gen_vendor_tables_nonsemantic_vulkan_debuginfo_100",
":gen_vendor_tables_nonsemantic_shader_debuginfo_100",
":gen_vendor_tables_spv_amd_gcn_shader",
":gen_vendor_tables_spv_amd_shader_ballot",
":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter",

View File

@ -300,8 +300,8 @@ spvtools_language_header("cldebuginfo100") {
grammar_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
}
spvtools_language_header("vkdebuginfo100") {
name = "NonSemanticVulkanDebugInfo100"
grammar_file = "source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json"
name = "NonSemanticShaderDebugInfo100"
grammar_file = "${spirv_headers}/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json"
}
spvtools_vendor_tables = [
@ -336,8 +336,8 @@ spvtools_vendor_tables = [
]
spvtools_vendor_tables_local = [ [
"nonsemantic.vulkan.debuginfo.100",
"VKDEBUG100_",
"nonsemantic.shader.debuginfo.100",
"SHDEBUG100_",
] ]
foreach(table_def, spvtools_vendor_tables) {

View File

@ -41,7 +41,7 @@ TEST_COPTS = COMMON_COPTS + select({
DEBUGINFO_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_debuginfo_grammar_unified1"
CLDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_opencl_debuginfo_100_grammar_unified1"
VKDEBUGINFO100_GRAMMAR_JSON_FILE = "source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json"
SHDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_nonsemantic_shader_debuginfo_100_grammar_unified1"
def generate_core_tables(version = None):
if not version:
@ -165,28 +165,6 @@ def generate_vendor_tables(extension, operand_kind_prefix = ""):
visibility = ["//visibility:private"],
)
def generate_vendor_tables_local(extension, operand_kind_prefix = ""):
if not extension:
fail("Must specify extension", "extension")
extension_rule = extension.replace("-", "_").replace(".", "_")
grammars = ["source/extinst.{}.grammar.json".format(extension)]
outs = ["{}.insts.inc".format(extension)]
prefices = [operand_kind_prefix]
fmtargs = grammars + outs + prefices
native.genrule(
name = "gen_vendor_tables_" + extension_rule,
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--extinst-vendor-grammar=$(location {0}) " +
"--vendor-insts-output=$(location {1}) " +
"--vendor-operand-kind-prefix={2}"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_extinst_lang_headers(name, grammar = None):
if not grammar:
fail("Must specify grammar", "grammar")

View File

@ -309,7 +309,7 @@ typedef enum spv_ext_inst_type_t {
SPV_EXT_INST_TYPE_DEBUGINFO,
SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100,
SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION,
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100,
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100,
// Multiple distinct extended instruction set types could return this
// value, if they are prefixed with NonSemantic. and are otherwise

View File

@ -20,10 +20,7 @@ set(LANG_HEADER_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_lang
# Pull in grammar files that have migrated to SPIRV-Headers
set(DEBUGINFO_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.debuginfo.grammar.json")
set(CLDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json")
# For now, assume the NonSemantic.Vulkan.DebugInfo grammar file is in the current directory.
# It will later migrate to SPIRV-Headers.
set(VKDEBUGINFO100_GRAMMAR_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json")
set(VKDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json")
# macro() definitions are used in the following because we need to append .inc
# file paths into some global lists (*_CPP_DEPENDS). And those global lists are
@ -154,11 +151,11 @@ spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs" "")
spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb" "")
spvtools_vendor_tables("debuginfo" "debuginfo" "")
spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_")
spvtools_vendor_tables("nonsemantic.vulkan.debuginfo.100" "vkdi100" "VKDEBUG100_")
spvtools_vendor_tables("nonsemantic.shader.debuginfo.100" "shdi100" "SHDEBUG100_")
spvtools_vendor_tables("nonsemantic.clspvreflection" "clspvreflection" "")
spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE})
spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE})
spvtools_extinst_lang_headers("NonSemanticVulkanDebugInfo100" ${VKDEBUGINFO100_GRAMMAR_JSON_FILE})
spvtools_extinst_lang_headers("NonSemanticShaderDebugInfo100" ${VKDEBUGINFO100_GRAMMAR_JSON_FILE})
spvtools_vimsyntax("unified1" "1.0")
add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE})

View File

@ -18,8 +18,8 @@
#define SOURCE_COMMON_DEBUG_INFO_HEADER_H_
// This enum defines the known common set of instructions that are the same
// between OpenCL.DebugInfo.100 and NonSemantic.Vulkan.DebugInfo.100.
// note that NonSemantic.DebugInfo.100 instructions can still have slightly
// between OpenCL.DebugInfo.100 and NonSemantic.Shader.DebugInfo.100.
// Note that NonSemantic.Shader.* instructions can still have slightly
// different encoding, as it does not use literals anywhere and only constants.
enum CommonDebugInfoInstructions {
CommonDebugInfoDebugInfoNone = 0,

View File

@ -29,7 +29,7 @@
#include "debuginfo.insts.inc"
#include "glsl.std.450.insts.inc"
#include "nonsemantic.clspvreflection.insts.inc"
#include "nonsemantic.vulkan.debuginfo.100.insts.inc"
#include "nonsemantic.shader.debuginfo.100.insts.inc"
#include "opencl.debuginfo.100.insts.inc"
#include "opencl.std.insts.inc"
@ -56,9 +56,9 @@ static const spv_ext_inst_group_t kGroups_1_0[] = {
debuginfo_entries},
{SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100,
ARRAY_SIZE(opencl_debuginfo_100_entries), opencl_debuginfo_100_entries},
{SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100,
ARRAY_SIZE(nonsemantic_vulkan_debuginfo_100_entries),
nonsemantic_vulkan_debuginfo_100_entries},
{SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100,
ARRAY_SIZE(nonsemantic_shader_debuginfo_100_entries),
nonsemantic_shader_debuginfo_100_entries},
{SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION,
ARRAY_SIZE(nonsemantic_clspvreflection_entries),
nonsemantic_clspvreflection_entries},
@ -130,8 +130,8 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
if (!strcmp("OpenCL.DebugInfo.100", name)) {
return SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100;
}
if (!strcmp("NonSemantic.Vulkan.DebugInfo.100", name)) {
return SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100;
if (!strcmp("NonSemantic.Shader.DebugInfo.100", name)) {
return SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100;
}
if (!strncmp("NonSemantic.ClspvReflection.", name, 28)) {
return SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION;
@ -146,7 +146,7 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) {
if (type == SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN ||
type == SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100 ||
type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 ||
type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION) {
return true;
}
@ -155,7 +155,7 @@ bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) {
bool spvExtInstIsDebugInfo(const spv_ext_inst_type_t type) {
if (type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 ||
type == SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100 ||
type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 ||
type == SPV_EXT_INST_TYPE_DEBUGINFO) {
return true;
}

View File

@ -1,638 +0,0 @@
{
"copyright" : [
"Copyright (c) 2018 The Khronos Group Inc.",
"",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and/or associated documentation files (the \"Materials\"),",
"to deal in the Materials without restriction, including without limitation",
"the rights to use, copy, modify, merge, publish, distribute, sublicense,",
"and/or sell copies of the Materials, and to permit persons to whom the",
"Materials are furnished to do so, subject to the following conditions:",
"",
"The above copyright notice and this permission notice shall be included in",
"all copies or substantial portions of the Materials.",
"",
"MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS",
"STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND",
"HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ",
"",
"THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS",
"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL",
"THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING",
"FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS",
"IN THE MATERIALS."
],
"version" : 100,
"revision" : 2,
"instructions" : [
{
"opname" : "DebugInfoNone",
"opcode" : 0
},
{
"opname" : "DebugCompilationUnit",
"opcode" : 1,
"operands" : [
{ "kind" : "IdRef", "name" : "'Version'" },
{ "kind" : "IdRef", "name" : "'DWARF Version'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Language'" }
]
},
{
"opname" : "DebugTypeBasic",
"opcode" : 2,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "IdRef", "name" : "'Encoding'" },
{ "kind" : "IdRef", "name" : "'Flags'" }
]
},
{
"opname" : "DebugTypePointer",
"opcode" : 3,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Storage Class'" },
{ "kind" : "IdRef", "name" : "'Flags'" }
]
},
{
"opname" : "DebugTypeQualifier",
"opcode" : 4,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Type Qualifier'" }
]
},
{
"opname" : "DebugTypeArray",
"opcode" : 5,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Component Counts'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeVector",
"opcode" : 6,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Component Count'" }
]
},
{
"opname" : "DebugTypedef",
"opcode" : 7,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugTypeFunction",
"opcode" : 8,
"operands" : [
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Return Type'" },
{ "kind" : "IdRef", "name" : "'Parameter Types'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeEnum",
"opcode" : 9,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Underlying Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "PairIdRefIdRef", "name" : "'Value, Name, Value, Name, ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeComposite",
"opcode" : 10,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Tag'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Members'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeMember",
"opcode" : 11,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Offset'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Value'", "quantifier" : "?" }
]
},
{
"opname" : "DebugTypeInheritance",
"opcode" : 12,
"operands" : [
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Offset'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "IdRef", "name" : "'Flags'" }
]
},
{
"opname" : "DebugTypePtrToMember",
"opcode" : 13,
"operands" : [
{ "kind" : "IdRef", "name" : "'Member Type'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugTypeTemplate",
"opcode" : 14,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "IdRef", "name" : "'Parameters'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeTemplateParameter",
"opcode" : 15,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Actual Type'" },
{ "kind" : "IdRef", "name" : "'Value'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" }
]
},
{
"opname" : "DebugTypeTemplateTemplateParameter",
"opcode" : 16,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Template Name'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" }
]
},
{
"opname" : "DebugTypeTemplateParameterPack",
"opcode" : 17,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Template Parameters'", "quantifier" : "*" }
]
},
{
"opname" : "DebugGlobalVariable",
"opcode" : 18,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Static Member Declaration'", "quantifier" : "?" }
]
},
{
"opname" : "DebugFunctionDeclaration",
"opcode" : 19,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Flags'" }
]
},
{
"opname" : "DebugFunction",
"opcode" : 20,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Scope Line'" },
{ "kind" : "IdRef", "name" : "'Declaration'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLexicalBlock",
"opcode" : 21,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Name'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLexicalBlockDiscriminator",
"opcode" : 22,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Discriminator'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugScope",
"opcode" : 23,
"operands" : [
{ "kind" : "IdRef", "name" : "'Scope'" },
{ "kind" : "IdRef", "name" : "'Inlined At'", "quantifier" : "?" }
]
},
{
"opname" : "DebugNoScope",
"opcode" : 24
},
{
"opname" : "DebugInlinedAt",
"opcode" : 25,
"operands" : [
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Scope'" },
{ "kind" : "IdRef", "name" : "'Inlined'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLocalVariable",
"opcode" : 26,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Arg Number'", "quantifier" : "?" }
]
},
{
"opname" : "DebugInlinedVariable",
"opcode" : 27,
"operands" : [
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "IdRef", "name" : "'Inlined'" }
]
},
{
"opname" : "DebugDeclare",
"opcode" : 28,
"operands" : [
{ "kind" : "IdRef", "name" : "'Local Variable'" },
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "IdRef", "name" : "'Expression'" }
]
},
{
"opname" : "DebugValue",
"opcode" : 29,
"operands" : [
{ "kind" : "IdRef", "name" : "'Local Variable'" },
{ "kind" : "IdRef", "name" : "'Value'" },
{ "kind" : "IdRef", "name" : "'Expression'" },
{ "kind" : "IdRef", "name" : "'Indexes'", "quantifier" : "*" }
]
},
{
"opname" : "DebugOperation",
"opcode" : 30,
"operands" : [
{ "kind" : "IdRef", "name" : "'OpCode'" },
{ "kind" : "IdRef", "name" : "'Operands ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugExpression",
"opcode" : 31,
"operands" : [
{ "kind" : "IdRef", "name" : "'Operands ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugMacroDef",
"opcode" : 32,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Value'", "quantifier" : "?" }
]
},
{
"opname" : "DebugMacroUndef",
"opcode" : 33,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Macro'" }
]
},
{
"opname" : "DebugImportedEntity",
"opcode" : 34,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Tag'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Entity'" },
{ "kind" : "IdRef", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugSource",
"opcode" : 35,
"operands" : [
{ "kind" : "IdRef", "name" : "'File'" },
{ "kind" : "IdRef", "name" : "'Text'", "quantifier" : "?" }
]
},
{
"opname" : "DebugFunctionDefinition",
"opcode" : 101,
"operands" : [
{ "kind" : "IdRef", "name" : "'Function'" },
{ "kind" : "IdRef", "name" : "'Definition'" }
]
}
],
"operand_kinds" : [
{
"category" : "BitEnum",
"kind" : "DebugInfoFlags",
"enumerants" : [
{
"enumerant" : "FlagIsProtected",
"value" : "0x01"
},
{
"enumerant" : "FlagIsPrivate",
"value" : "0x02"
},
{
"enumerant" : "FlagIsPublic",
"value" : "0x03"
},
{
"enumerant" : "FlagIsLocal",
"value" : "0x04"
},
{
"enumerant" : "FlagIsDefinition",
"value" : "0x08"
},
{
"enumerant" : "FlagFwdDecl",
"value" : "0x10"
},
{
"enumerant" : "FlagArtificial",
"value" : "0x20"
},
{
"enumerant" : "FlagExplicit",
"value" : "0x40"
},
{
"enumerant" : "FlagPrototyped",
"value" : "0x80"
},
{
"enumerant" : "FlagObjectPointer",
"value" : "0x100"
},
{
"enumerant" : "FlagStaticMember",
"value" : "0x200"
},
{
"enumerant" : "FlagIndirectVariable",
"value" : "0x400"
},
{
"enumerant" : "FlagLValueReference",
"value" : "0x800"
},
{
"enumerant" : "FlagRValueReference",
"value" : "0x1000"
},
{
"enumerant" : "FlagIsOptimized",
"value" : "0x2000"
},
{
"enumerant" : "FlagIsEnumClass",
"value" : "0x4000"
},
{
"enumerant" : "FlagTypePassByValue",
"value" : "0x8000"
},
{
"enumerant" : "FlagTypePassByReference",
"value" : "0x10000"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugBaseTypeAttributeEncoding",
"enumerants" : [
{
"enumerant" : "Unspecified",
"value" : "0"
},
{
"enumerant" : "Address",
"value" : "1"
},
{
"enumerant" : "Boolean",
"value" : "2"
},
{
"enumerant" : "Float",
"value" : "3"
},
{
"enumerant" : "Signed",
"value" : "4"
},
{
"enumerant" : "SignedChar",
"value" : "5"
},
{
"enumerant" : "Unsigned",
"value" : "6"
},
{
"enumerant" : "UnsignedChar",
"value" : "7"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugCompositeType",
"enumerants" : [
{
"enumerant" : "Class",
"value" : "0"
},
{
"enumerant" : "Structure",
"value" : "1"
},
{
"enumerant" : "Union",
"value" : "2"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugTypeQualifier",
"enumerants" : [
{
"enumerant" : "ConstType",
"value" : "0"
},
{
"enumerant" : "VolatileType",
"value" : "1"
},
{
"enumerant" : "RestrictType",
"value" : "2"
},
{
"enumerant" : "AtomicType",
"value" : "3"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugOperation",
"enumerants" : [
{
"enumerant" : "Deref",
"value" : "0"
},
{
"enumerant" : "Plus",
"value" : "1"
},
{
"enumerant" : "Minus",
"value" : "2"
},
{
"enumerant" : "PlusUconst",
"value" : "3",
"parameters" : [
{ "kind" : "IdRef" }
]
},
{
"enumerant" : "BitPiece",
"value" : "4",
"parameters" : [
{ "kind" : "IdRef" },
{ "kind" : "IdRef" }
]
},
{
"enumerant" : "Swap",
"value" : "5"
},
{
"enumerant" : "Xderef",
"value" : "6"
},
{
"enumerant" : "StackValue",
"value" : "7"
},
{
"enumerant" : "Constu",
"value" : "8",
"parameters" : [
{ "kind" : "IdRef" }
]
},
{
"enumerant" : "Fragment",
"value" : "9",
"parameters" : [
{ "kind" : "IdRef" },
{ "kind" : "IdRef" }
]
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugImportedEntity",
"enumerants" : [
{
"enumerant" : "ImportedModule",
"value" : "0"
},
{
"enumerant" : "ImportedDeclaration",
"value" : "1"
}
]
}
]
}

View File

@ -579,8 +579,8 @@ std::function<bool(unsigned)> spvOperandCanBeForwardDeclaredFunction(
std::function<bool(unsigned)> spvDbgInfoExtOperandCanBeForwardDeclaredFunction(
spv_ext_inst_type_t ext_type, uint32_t key) {
// The Vulkan debug info extended instruction set is non-semantic so allows no
// forward references ever.
if (ext_type == SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
// forward references ever
if (ext_type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
return [](unsigned) { return false; };
}

View File

@ -145,6 +145,19 @@ bool AggressiveDCEPass::AllExtensionsSupported() const {
if (extensions_allowlist_.find(extName) == extensions_allowlist_.end())
return false;
}
// Only allow NonSemantic.Shader.DebugInfo.100, we cannot safely optimise
// around unknown extended instruction sets even if they are non-semantic
for (auto& inst : context()->module()->ext_inst_imports()) {
assert(inst.opcode() == SpvOpExtInstImport &&
"Expecting an import of an extension's instruction set.");
const char* extension_name =
reinterpret_cast<const char*>(&inst.GetInOperand(0).words[0]);
if (0 == std::strncmp(extension_name, "NonSemantic.", 12) &&
0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100",
32)) {
return false;
}
}
return true;
}
@ -1002,6 +1015,7 @@ void AggressiveDCEPass::InitExtensions() {
"SPV_KHR_subgroup_uniform_control_flow",
"SPV_KHR_integer_dot_product",
"SPV_EXT_shader_image_int64",
"SPV_KHR_non_semantic_info",
});
}

View File

@ -18,7 +18,7 @@
#include "source/opt/ir_context.h"
// Constants for OpenCL.DebugInfo.100 & NonSemantic.Vulkan.DebugInfo.100
// Constants for OpenCL.DebugInfo.100 & NonSemantic.Shader.DebugInfo.100
// extension instructions.
static const uint32_t kOpLineOperandLineIndex = 1;
@ -117,14 +117,14 @@ void DebugInfoManager::RegisterDbgFunction(Instruction* inst) {
fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
"Register DebugFunction for a function that already has DebugFunction");
fn_id_to_dbg_fn_[fn_id] = inst;
} else if (inst->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugFunctionDefinition) {
} else if (inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
auto fn_id = inst->GetSingleWordOperand(
kDebugFunctionDefinitionOperandOpFunctionIndex);
auto fn_inst = GetDbgInst(inst->GetSingleWordOperand(
kDebugFunctionDefinitionOperandDebugFunctionIndex));
assert(fn_inst && fn_inst->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugFunction);
assert(fn_inst && fn_inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunction);
assert(fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
"Register DebugFunctionDefinition for a function that already has "
"DebugFunctionDefinition");
@ -155,7 +155,7 @@ uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
spv_operand_type_t line_number_type =
spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER;
// In NonSemantic.Vulkan.DebugInfo.100, all constants are IDs of OpConstant,
// In NonSemantic.Shader.DebugInfo.100, all constants are IDs of OpConstant,
// not literals.
if (setId ==
context()->get_feature_mgr()->GetExtInstImportId_Vulkan100DebugInfo())
@ -307,7 +307,7 @@ Instruction* DebugInfoManager::GetDebugOperationWithDeref() {
}));
} else {
uint32_t deref_id = context()->get_constant_mgr()->GetUIntConst(
NonSemanticVulkanDebugInfo100Deref);
NonSemanticShaderDebugInfo100Deref);
deref_operation = std::unique_ptr<Instruction>(
new Instruction(context(), SpvOpExtInst,
@ -316,7 +316,7 @@ Instruction* DebugInfoManager::GetDebugOperationWithDeref() {
{SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(
NonSemanticVulkanDebugInfo100DebugOperation)}},
NonSemanticShaderDebugInfo100DebugOperation)}},
{SPV_OPERAND_TYPE_ID, {deref_id}},
}));
}
@ -574,8 +574,8 @@ Instruction* DebugInfoManager::AddDebugValueForDecl(
}
uint32_t DebugInfoManager::GetVulkanDebugOperation(Instruction* inst) {
assert(inst->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugOperation &&
assert(inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation &&
"inst must be Vulkan DebugOperation");
return context()
->get_constant_mgr()
@ -606,7 +606,7 @@ uint32_t DebugInfoManager::GetVariableIdOfDebugValueUsedForDeclare(
}
} else {
uint32_t operation_const = GetVulkanDebugOperation(operation);
if (operation_const != NonSemanticVulkanDebugInfo100Deref) {
if (operation_const != NonSemanticShaderDebugInfo100Deref) {
return 0;
}
}
@ -682,8 +682,8 @@ void DebugInfoManager::AnalyzeDebugInst(Instruction* inst) {
RegisterDbgInst(inst);
if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction ||
inst->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugFunctionDefinition) {
inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
RegisterDbgFunction(inst);
}
@ -695,10 +695,10 @@ void DebugInfoManager::AnalyzeDebugInst(Instruction* inst) {
}
if (deref_operation_ == nullptr &&
inst->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugOperation) {
inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation) {
uint32_t operation_const = GetVulkanDebugOperation(inst);
if (operation_const == NonSemanticVulkanDebugInfo100Deref) {
if (operation_const == NonSemanticShaderDebugInfo100Deref) {
deref_operation_ = inst;
}
}
@ -759,8 +759,11 @@ void DebugInfoManager::ConvertDebugGlobalToLocalVariable(
{spv_operand_type_t::SPV_OPERAND_TYPE_ID,
{GetEmptyDebugExpression()->result_id()}},
}));
auto* added_dbg_decl =
local_var->NextNode()->InsertBefore(std::move(new_dbg_decl));
// Must insert after all OpVariables in block
Instruction* insert_before = local_var;
while (insert_before->opcode() == SpvOpVariable)
insert_before = insert_before->NextNode();
auto* added_dbg_decl = insert_before->InsertBefore(std::move(new_dbg_decl));
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_decl);
if (context()->AreAnalysesValid(
@ -818,8 +821,8 @@ void DebugInfoManager::ClearDebugInfo(Instruction* instr) {
instr->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex);
fn_id_to_dbg_fn_.erase(fn_id);
}
if (instr->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugFunction) {
if (instr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunction) {
auto fn_id = instr->GetSingleWordOperand(
kDebugFunctionDefinitionOperandOpFunctionIndex);
fn_id_to_dbg_fn_.erase(fn_id);
@ -851,11 +854,10 @@ void DebugInfoManager::ClearDebugInfo(Instruction* instr) {
deref_operation_ = &*dbg_instr_itr;
break;
} else if (instr != &*dbg_instr_itr &&
dbg_instr_itr->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugOperation) {
dbg_instr_itr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation) {
uint32_t operation_const = GetVulkanDebugOperation(&*dbg_instr_itr);
if (operation_const == NonSemanticVulkanDebugInfo100Deref) {
if (operation_const == NonSemanticShaderDebugInfo100Deref) {
deref_operation_ = &*dbg_instr_itr;
break;
}

View File

@ -68,7 +68,7 @@ class DebugInlinedAtContext {
};
// A class for analyzing, managing, and creating OpenCL.DebugInfo.100 and
// NonSemantic.Vulkan.DebugInfo.100 extension instructions.
// NonSemantic.Shader.DebugInfo.100 extension instructions.
class DebugInfoManager {
public:
// Constructs a debug information manager from the given |context|.

View File

@ -81,7 +81,7 @@ void FeatureManager::AddExtInstImportIds(Module* module) {
extinst_importid_OpenCL100DebugInfo_ =
module->GetExtInstImportId("OpenCL.DebugInfo.100");
extinst_importid_Vulkan100DebugInfo_ =
module->GetExtInstImportId("NonSemantic.Vulkan.DebugInfo.100");
module->GetExtInstImportId("NonSemantic.Shader.DebugInfo.100");
}
bool operator==(const FeatureManager& a, const FeatureManager& b) {

View File

@ -97,7 +97,7 @@ class FeatureManager {
// for performance.
uint32_t extinst_importid_OpenCL100DebugInfo_ = 0;
// Common NonSemanticVulkan100DebugInfo external instruction import ids,
// Common NonSemanticShader100DebugInfo external instruction import ids,
// cached for performance.
uint32_t extinst_importid_Vulkan100DebugInfo_ = 0;
};

View File

@ -405,8 +405,8 @@ bool InlinePass::InlineEntryBlock(
while (callee_inst_itr != callee_first_block->end()) {
// Don't inline function definition links, the calling function is not a
// definition.
if (callee_inst_itr->GetVulkan100DebugOpcode() ==
NonSemanticVulkanDebugInfo100DebugFunctionDefinition) {
if (callee_inst_itr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
++callee_inst_itr;
continue;
}
@ -441,6 +441,11 @@ std::unique_ptr<BasicBlock> InlinePass::InlineBasicBlocks(
auto tail_inst_itr = callee_block_itr->end();
for (auto inst_itr = callee_block_itr->begin(); inst_itr != tail_inst_itr;
++inst_itr) {
// Don't inline function definition links, the calling function is not a
// definition
if (inst_itr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition)
continue;
if (!InlineSingleInstruction(
callee2caller, new_blk_ptr.get(), &*inst_itr,
context()->get_debug_info_mgr()->BuildDebugInlinedAtChain(

View File

@ -16,7 +16,6 @@
#include <initializer_list>
#include "NonSemanticVulkanDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/disassemble.h"
#include "source/opt/fold.h"
@ -33,7 +32,7 @@ const uint32_t kLoadBaseIndex = 0;
const uint32_t kPointerTypeStorageClassIndex = 0;
const uint32_t kTypeImageSampledIndex = 5;
// Constants for OpenCL.DebugInfo.100 / NonSemantic.Vulkan.DebugInfo.100
// Constants for OpenCL.DebugInfo.100 / NonSemantic.Shader.DebugInfo.100
// extension instructions.
const uint32_t kExtInstSetIdInIdx = 0;
const uint32_t kExtInstInstructionInIdx = 1;
@ -624,22 +623,22 @@ OpenCLDebugInfo100Instructions Instruction::GetOpenCL100DebugOpcode() const {
GetSingleWordInOperand(kExtInstInstructionInIdx));
}
NonSemanticVulkanDebugInfo100Instructions Instruction::GetVulkan100DebugOpcode()
NonSemanticShaderDebugInfo100Instructions Instruction::GetShader100DebugOpcode()
const {
if (opcode() != SpvOpExtInst) {
return NonSemanticVulkanDebugInfo100InstructionsMax;
return NonSemanticShaderDebugInfo100InstructionsMax;
}
if (!context()->get_feature_mgr()->GetExtInstImportId_Vulkan100DebugInfo()) {
return NonSemanticVulkanDebugInfo100InstructionsMax;
return NonSemanticShaderDebugInfo100InstructionsMax;
}
if (GetSingleWordInOperand(kExtInstSetIdInIdx) !=
context()->get_feature_mgr()->GetExtInstImportId_Vulkan100DebugInfo()) {
return NonSemanticVulkanDebugInfo100InstructionsMax;
return NonSemanticShaderDebugInfo100InstructionsMax;
}
return NonSemanticVulkanDebugInfo100Instructions(
return NonSemanticShaderDebugInfo100Instructions(
GetSingleWordInOperand(kExtInstInstructionInIdx));
}

View File

@ -22,7 +22,7 @@
#include <utility>
#include <vector>
#include "NonSemanticVulkanDebugInfo100.h"
#include "NonSemanticShaderDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/common_debug_info.h"
#include "source/latest_version_glsl_std_450_header.h"
@ -552,13 +552,13 @@ class Instruction : public utils::IntrusiveNodeBase<Instruction> {
// OpenCLDebugInfo100InstructionsMax.
OpenCLDebugInfo100Instructions GetOpenCL100DebugOpcode() const;
// Returns debug opcode of a NonSemantic.Vulkan.DebugInfo.100 instruction. If
// it is not a NonSemantic.Vulkan.DebugInfo.100 instruction, just returns
// NonSemanticVulkanDebugInfo100InstructionsMax.
NonSemanticVulkanDebugInfo100Instructions GetVulkan100DebugOpcode() const;
// Returns debug opcode of an NonSemantic.Shader.DebugInfo.100 instruction. If
// it is not an NonSemantic.Shader.DebugInfo.100 instruction, just return
// NonSemanticShaderDebugInfo100InstructionsMax.
NonSemanticShaderDebugInfo100Instructions GetShader100DebugOpcode() const;
// Returns debug opcode of an OpenCL.100.DebugInfo or
// NonSemantic.Vulkan.DebugInfo.100 instruction. Since these overlap, we
// NonSemantic.Shader.DebugInfo.100 instruction. Since these overlap, we
// return the OpenCLDebugInfo code
CommonDebugInfoInstructions GetCommonDebugOpcode() const;
@ -566,10 +566,11 @@ class Instruction : public utils::IntrusiveNodeBase<Instruction> {
bool IsOpenCL100DebugInstr() const {
return GetOpenCL100DebugOpcode() != OpenCLDebugInfo100InstructionsMax;
}
// Returns true if it is a NonSemantic.Vulkan.DebugInfo.100 instruction.
bool IsVulkan100DebugInstr() const {
return GetVulkan100DebugOpcode() !=
NonSemanticVulkanDebugInfo100InstructionsMax;
// Returns true if it is an NonSemantic.Shader.DebugInfo.100 instruction.
bool IsShader100DebugInstr() const {
return GetShader100DebugOpcode() !=
NonSemanticShaderDebugInfo100InstructionsMax;
}
bool IsCommonDebugInstr() const {
return GetCommonDebugOpcode() != CommonDebugInfoInstructionsMax;

View File

@ -30,7 +30,7 @@ static const int kSpvDecorateBuiltinInIdx = 2;
static const int kEntryPointInterfaceInIdx = 3;
static const int kEntryPointFunctionIdInIdx = 1;
// Constants for OpenCL.DebugInfo.100 / NonSemantic.Vulkan.DebugInfo.100
// Constants for OpenCL.DebugInfo.100 / NonSemantic.Shader.DebugInfo.100
// extension instructions.
static const uint32_t kDebugFunctionOperandFunctionIndex = 13;
static const uint32_t kDebugGlobalVariableOperandVariableIndex = 11;

View File

@ -17,7 +17,6 @@
#include <utility>
#include "DebugInfo.h"
#include "NonSemanticVulkanDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/ext_inst.h"
#include "source/opt/log.h"
@ -56,7 +55,7 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) {
const uint32_t ext_inst_index = inst->words[kExtInstSetIndex];
if (inst->ext_inst_type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 ||
inst->ext_inst_type ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
const CommonDebugInfoInstructions ext_inst_key =
CommonDebugInfoInstructions(ext_inst_index);
if (ext_inst_key == CommonDebugInfoDebugScope) {
@ -243,15 +242,15 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) {
}
}
} else if (inst->ext_inst_type ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
const NonSemanticVulkanDebugInfo100Instructions ext_inst_key =
NonSemanticVulkanDebugInfo100Instructions(ext_inst_index);
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
const NonSemanticShaderDebugInfo100Instructions ext_inst_key =
NonSemanticShaderDebugInfo100Instructions(ext_inst_index);
switch (ext_inst_key) {
case NonSemanticVulkanDebugInfo100DebugDeclare:
case NonSemanticVulkanDebugInfo100DebugValue:
case NonSemanticVulkanDebugInfo100DebugScope:
case NonSemanticVulkanDebugInfo100DebugNoScope:
case NonSemanticVulkanDebugInfo100DebugFunctionDefinition: {
case NonSemanticShaderDebugInfo100DebugDeclare:
case NonSemanticShaderDebugInfo100DebugValue:
case NonSemanticShaderDebugInfo100DebugScope:
case NonSemanticShaderDebugInfo100DebugNoScope:
case NonSemanticShaderDebugInfo100DebugFunctionDefinition: {
if (block_ == nullptr) { // Inside function but outside blocks
Errorf(consumer_, src, loc,
"Debug info extension instruction found inside function "

View File

@ -333,6 +333,20 @@ bool LocalAccessChainConvertPass::AllExtensionsSupported() const {
if (extensions_allowlist_.find(extName) == extensions_allowlist_.end())
return false;
}
// only allow NonSemantic.Shader.DebugInfo.100, we cannot safely optimise
// around unknown extended
// instruction sets even if they are non-semantic
for (auto& inst : context()->module()->ext_inst_imports()) {
assert(inst.opcode() == SpvOpExtInstImport &&
"Expecting an import of an extension's instruction set.");
const char* extension_name =
reinterpret_cast<const char*>(&inst.GetInOperand(0).words[0]);
if (0 == std::strncmp(extension_name, "NonSemantic.", 12) &&
0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100",
32)) {
return false;
}
}
return true;
}
@ -421,6 +435,7 @@ void LocalAccessChainConvertPass::InitExtensions() {
"SPV_KHR_subgroup_uniform_control_flow",
"SPV_KHR_integer_dot_product",
"SPV_EXT_shader_image_int64",
"SPV_KHR_non_semantic_info",
});
}

View File

@ -188,6 +188,20 @@ bool LocalSingleBlockLoadStoreElimPass::AllExtensionsSupported() const {
if (extensions_allowlist_.find(extName) == extensions_allowlist_.end())
return false;
}
// only allow NonSemantic.Shader.DebugInfo.100, we cannot safely optimise
// around unknown extended
// instruction sets even if they are non-semantic
for (auto& inst : context()->module()->ext_inst_imports()) {
assert(inst.opcode() == SpvOpExtInstImport &&
"Expecting an import of an extension's instruction set.");
const char* extension_name =
reinterpret_cast<const char*>(&inst.GetInOperand(0).words[0]);
if (0 == std::strncmp(extension_name, "NonSemantic.", 12) &&
0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100",
32)) {
return false;
}
}
return true;
}
@ -273,6 +287,7 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
"SPV_KHR_subgroup_uniform_control_flow",
"SPV_KHR_integer_dot_product",
"SPV_EXT_shader_image_int64",
"SPV_KHR_non_semantic_info",
});
}

View File

@ -53,6 +53,20 @@ bool LocalSingleStoreElimPass::AllExtensionsSupported() const {
if (extensions_allowlist_.find(extName) == extensions_allowlist_.end())
return false;
}
// only allow NonSemantic.Shader.DebugInfo.100, we cannot safely optimise
// around unknown extended
// instruction sets even if they are non-semantic
for (auto& inst : context()->module()->ext_inst_imports()) {
assert(inst.opcode() == SpvOpExtInstImport &&
"Expecting an import of an extension's instruction set.");
const char* extension_name =
reinterpret_cast<const char*>(&inst.GetInOperand(0).words[0]);
if (0 == std::strncmp(extension_name, "NonSemantic.", 12) &&
0 != std::strncmp(extension_name, "NonSemantic.Shader.DebugInfo.100",
32)) {
return false;
}
}
return true;
}
@ -126,6 +140,7 @@ void LocalSingleStoreElimPass::InitExtensionAllowList() {
"SPV_KHR_subgroup_uniform_control_flow",
"SPV_KHR_integer_dot_product",
"SPV_EXT_shader_image_int64",
"SPV_KHR_non_semantic_info",
});
}
bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) {

View File

@ -104,7 +104,7 @@ class Module {
inline void AddDebug3Inst(std::unique_ptr<Instruction> d);
// Appends a debug info extension (OpenCL.DebugInfo.100,
// NonSemantic.Vulkan.DebugInfo.100, or DebugInfo) instruction to this module.
// NonSemantic.Shader.DebugInfo.100, or DebugInfo) instruction to this module.
inline void AddExtInstDebugInfo(std::unique_ptr<Instruction> d);
// Appends an annotation instruction to this module.

View File

@ -172,10 +172,14 @@ bool ScalarReplacementPass::ReplaceWholeDebugDeclare(
// Add DebugValue instruction with Indexes operand and Deref operation.
int32_t idx = 0;
for (const auto* var : replacements) {
Instruction* insert_before = var->NextNode();
while (insert_before->opcode() == SpvOpVariable)
insert_before = insert_before->NextNode();
assert(insert_before != nullptr && "unexpected end of list");
Instruction* added_dbg_value =
context()->get_debug_info_mgr()->AddDebugValueForDecl(
dbg_decl, /*value_id=*/var->result_id(),
/*insert_before=*/var->NextNode(), /*scope_and_line=*/dbg_decl);
/*insert_before=*/insert_before, /*scope_and_line=*/dbg_decl);
if (added_dbg_value == nullptr) return false;
added_dbg_value->AddOperand(

View File

@ -63,7 +63,7 @@ spv_result_t ValidateAdjacency(ValidationState_t& _) {
// NOTE: This does not apply to the non-semantic vulkan debug info.
if (!spvExtInstIsDebugInfo(inst.ext_inst_type()) ||
inst.ext_inst_type() ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
adjacency_status = PHI_AND_VAR_INVALID;
}
break;

View File

@ -20,7 +20,7 @@
#include "spirv/unified1/NonSemanticClspvReflection.h"
#include "NonSemanticVulkanDebugInfo100.h"
#include "NonSemanticShaderDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/common_debug_info.h"
#include "source/diagnostic.h"
@ -98,7 +98,7 @@ spv_result_t ValidateOperandForDebugInfo(
return SPV_SUCCESS;
}
// For NonSemantic.Vulkan.DebugInfo.100 check that the operand of a debug info
// For NonSemantic.Shader.DebugInfo.100 check that the operand of a debug info
// instruction |inst| at |word_index| is a result id of a 32-bit integer
// OpConstant instruction. For OpenCL.DebugInfo.100 the parameter is a literal
// word so cannot be validated.
@ -140,7 +140,7 @@ bool DoesDebugInfoOperandMatchExpectation(
if (debug_inst->opcode() != SpvOpExtInst ||
(debug_inst->ext_inst_type() != SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 &&
debug_inst->ext_inst_type() !=
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) ||
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) ||
!expectation(CommonDebugInfoInstructions(debug_inst->word(4)))) {
return false;
}
@ -706,7 +706,7 @@ bool IsDebugVariableWithIntScalarType(ValidationState_t& _,
const spv_ext_inst_type_t ext_inst_type =
spv_ext_inst_type_t(inst->ext_inst_type());
const bool vulkanDebugInfo =
ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100;
ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100;
uint32_t encoding = dbg_type->word(7);
if (!vulkanDebugInfo || IsUint32Constant(_, encoding)) {
auto ocl_encoding = OpenCLDebugInfo100DebugBaseTypeAttributeEncoding(
@ -2707,7 +2707,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
}
} else if (ext_inst_type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 ||
ext_inst_type ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
if (!_.IsVoidType(result_type)) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< ext_inst_name() << ": "
@ -2716,7 +2716,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
}
const bool vulkanDebugInfo =
ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100;
ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100;
auto num_words = inst->words().size();
@ -2965,7 +2965,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 7);
CHECK_CONST_UINT_OPERAND("Line", 8);
CHECK_CONST_UINT_OPERAND("Column", 9);
// NonSemantic.Vulkan.DebugInfo doesn't have the Parent operand
// NonSemantic.Shader.DebugInfo doesn't have the Parent operand
if (vulkanDebugInfo) {
CHECK_OPERAND("Offset", SpvOpConstant, 10);
CHECK_OPERAND("Size", SpvOpConstant, 11);
@ -3023,7 +3023,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
CHECK_OPERAND("Linkage Name", SpvOpString, 11);
CHECK_CONST_UINT_OPERAND("Flags", 12);
CHECK_CONST_UINT_OPERAND("Scope Line", 13);
// NonSemantic.Vulkan.DebugInfo.100 doesn't include a reference to the
// NonSemantic.Shader.DebugInfo.100 doesn't include a reference to the
// OpFunction
if (vulkanDebugInfo) {
if (num_words == 15) {

View File

@ -17,7 +17,7 @@
#include <cassert>
#include "DebugInfo.h"
#include "NonSemanticVulkanDebugInfo100.h"
#include "NonSemanticShaderDebugInfo100.h"
#include "OpenCLDebugInfo100.h"
#include "source/diagnostic.h"
#include "source/opcode.h"
@ -51,15 +51,15 @@ spv_result_t ModuleScopedInstructions(ValidationState_t& _,
local_debug_info = true;
}
} else if (inst->ext_inst_type() ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
const NonSemanticVulkanDebugInfo100Instructions ext_inst_key =
NonSemanticVulkanDebugInfo100Instructions(ext_inst_index);
if (ext_inst_key == NonSemanticVulkanDebugInfo100DebugScope ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugNoScope ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugDeclare ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugValue ||
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
const NonSemanticShaderDebugInfo100Instructions ext_inst_key =
NonSemanticShaderDebugInfo100Instructions(ext_inst_index);
if (ext_inst_key == NonSemanticShaderDebugInfo100DebugScope ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugNoScope ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugDeclare ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugValue ||
ext_inst_key ==
NonSemanticVulkanDebugInfo100DebugFunctionDefinition) {
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
local_debug_info = true;
}
} else {
@ -256,15 +256,15 @@ spv_result_t FunctionScopedInstructions(ValidationState_t& _,
local_debug_info = true;
}
} else if (inst->ext_inst_type() ==
SPV_EXT_INST_TYPE_NONSEMANTIC_VULKAN_DEBUGINFO_100) {
const NonSemanticVulkanDebugInfo100Instructions ext_inst_key =
NonSemanticVulkanDebugInfo100Instructions(ext_inst_index);
if (ext_inst_key == NonSemanticVulkanDebugInfo100DebugScope ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugNoScope ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugDeclare ||
ext_inst_key == NonSemanticVulkanDebugInfo100DebugValue ||
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) {
const NonSemanticShaderDebugInfo100Instructions ext_inst_key =
NonSemanticShaderDebugInfo100Instructions(ext_inst_index);
if (ext_inst_key == NonSemanticShaderDebugInfo100DebugScope ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugNoScope ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugDeclare ||
ext_inst_key == NonSemanticShaderDebugInfo100DebugValue ||
ext_inst_key ==
NonSemanticVulkanDebugInfo100DebugFunctionDefinition) {
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
local_debug_info = true;
}
} else {

View File

@ -7063,6 +7063,168 @@ TEST_F(AggressiveDCETest, DebugInfoKeepInFunctionElimStoreVar) {
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
}
TEST_F(AggressiveDCETest, ShaderDebugInfoKeepInFunctionElimStoreVar) {
// Verify that dead local variable tc and store eliminated but all
// in-function NonSemantic Shader debuginfo kept.
const std::string text = R"(
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %MainPs "MainPs" %g_tColor %g_sAniso %in_var_TEXCOORD2 %out_var_SV_Target0
OpExecutionMode %MainPs OriginUpperLeft
%7 = OpString "foo.frag"
%8 = OpString "PS_OUTPUT"
%9 = OpString "float"
%10 = OpString "vColor"
%11 = OpString "PS_INPUT"
%12 = OpString "vTextureCoords"
%13 = OpString "@type.2d.image"
%14 = OpString "type.2d.image"
%15 = OpString "Texture2D.TemplateParam"
%16 = OpString "src.MainPs"
%17 = OpString "tc"
%18 = OpString "ps_output"
%19 = OpString "i"
%20 = OpString "@type.sampler"
%21 = OpString "type.sampler"
%22 = OpString "g_sAniso"
%23 = OpString "g_tColor"
OpName %type_2d_image "type.2d.image"
OpName %g_tColor "g_tColor"
OpName %type_sampler "type.sampler"
OpName %g_sAniso "g_sAniso"
OpName %in_var_TEXCOORD2 "in.var.TEXCOORD2"
OpName %out_var_SV_Target0 "out.var.SV_Target0"
OpName %MainPs "MainPs"
OpName %PS_INPUT "PS_INPUT"
OpMemberName %PS_INPUT 0 "vTextureCoords"
OpName %param_var_i "param.var.i"
OpName %PS_OUTPUT "PS_OUTPUT"
OpMemberName %PS_OUTPUT 0 "vColor"
OpName %type_sampled_image "type.sampled.image"
OpDecorate %in_var_TEXCOORD2 Location 0
OpDecorate %out_var_SV_Target0 Location 0
OpDecorate %g_tColor DescriptorSet 0
OpDecorate %g_tColor Binding 0
OpDecorate %g_sAniso DescriptorSet 0
OpDecorate %g_sAniso Binding 1
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%uint_32 = OpConstant %uint 32
%float = OpTypeFloat 32
%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown
%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
%type_sampler = OpTypeSampler
%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler
%v2float = OpTypeVector %float 2
%_ptr_Input_v2float = OpTypePointer Input %v2float
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%void = OpTypeVoid
%uint_128 = OpConstant %uint 128
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%uint_7 = OpConstant %uint 7
%uint_8 = OpConstant %uint 8
%uint_10 = OpConstant %uint 10
%uint_11 = OpConstant %uint 11
%uint_12 = OpConstant %uint 12
%uint_14 = OpConstant %uint 14
%uint_15 = OpConstant %uint 15
%uint_16 = OpConstant %uint 16
%uint_17 = OpConstant %uint 17
%uint_19 = OpConstant %uint 19
%uint_29 = OpConstant %uint 29
%uint_64 = OpConstant %uint 64
%45 = OpTypeFunction %void
%PS_INPUT = OpTypeStruct %v2float
%_ptr_Function_PS_INPUT = OpTypePointer Function %PS_INPUT
%PS_OUTPUT = OpTypeStruct %v4float
%47 = OpTypeFunction %PS_OUTPUT %_ptr_Function_PS_INPUT
%_ptr_Function_PS_OUTPUT = OpTypePointer Function %PS_OUTPUT
%_ptr_Function_v2float = OpTypePointer Function %v2float
%type_sampled_image = OpTypeSampledImage %type_2d_image
%_ptr_Function_v4float = OpTypePointer Function %v4float
%g_tColor = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant
%g_sAniso = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant
%in_var_TEXCOORD2 = OpVariable %_ptr_Input_v2float Input
%out_var_SV_Target0 = OpVariable %_ptr_Output_v4float Output
%51 = OpExtInst %void %1 DebugInfoNone
%52 = OpExtInst %void %1 DebugExpression
%53 = OpExtInst %void %1 DebugOperation %uint_0
%54 = OpExtInst %void %1 DebugExpression %53
%55 = OpExtInst %void %1 DebugSource %7
%56 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %55 %uint_5
%59 = OpExtInst %void %1 DebugTypeBasic %9 %uint_32 %uint_3 %uint_0
%60 = OpExtInst %void %1 DebugTypeVector %59 %uint_4
%58 = OpExtInst %void %1 DebugTypeMember %10 %60 %55 %uint_12 %uint_5 %uint_0 %uint_128 %uint_3
%57 = OpExtInst %void %1 DebugTypeComposite %8 %uint_1 %55 %uint_10 %uint_1 %56 %8 %uint_128 %uint_3 %58
%63 = OpExtInst %void %1 DebugTypeVector %59 %uint_2
%62 = OpExtInst %void %1 DebugTypeMember %12 %63 %55 %uint_7 %uint_5 %uint_0 %uint_64 %uint_3
%61 = OpExtInst %void %1 DebugTypeComposite %11 %uint_1 %55 %uint_5 %uint_1 %56 %11 %uint_64 %uint_3 %62
%64 = OpExtInst %void %1 DebugTypeComposite %13 %uint_0 %55 %uint_0 %uint_0 %56 %14 %51 %uint_3
%67 = OpExtInst %void %1 DebugTypeFunction %uint_3 %57 %61
%68 = OpExtInst %void %1 DebugFunction %16 %67 %55 %uint_15 %uint_1 %56 %16 %uint_3 %uint_16
%69 = OpExtInst %void %1 DebugLexicalBlock %55 %uint_16 %uint_1 %68
%70 = OpExtInst %void %1 DebugLocalVariable %17 %63 %55 %uint_19 %uint_12 %69 %uint_4
%71 = OpExtInst %void %1 DebugLocalVariable %18 %57 %55 %uint_17 %uint_15 %69 %uint_4
%72 = OpExtInst %void %1 DebugLocalVariable %19 %61 %55 %uint_15 %uint_29 %68 %uint_4 %uint_1
%73 = OpExtInst %void %1 DebugTypeComposite %20 %uint_1 %55 %uint_0 %uint_0 %56 %21 %51 %uint_3
%74 = OpExtInst %void %1 DebugGlobalVariable %22 %73 %55 %uint_3 %uint_14 %56 %22 %g_sAniso %uint_8
%75 = OpExtInst %void %1 DebugGlobalVariable %23 %64 %55 %uint_1 %uint_11 %56 %23 %g_tColor %uint_8
%MainPs = OpFunction %void None %45
%76 = OpLabel
%78 = OpVariable %_ptr_Function_PS_OUTPUT Function
%79 = OpVariable %_ptr_Function_v2float Function
%81 = OpVariable %_ptr_Function_PS_OUTPUT Function
%param_var_i = OpVariable %_ptr_Function_PS_INPUT Function
%82 = OpLoad %v2float %in_var_TEXCOORD2
%83 = OpCompositeConstruct %PS_INPUT %82
OpStore %param_var_i %83
%112 = OpExtInst %void %1 DebugFunctionDefinition %68 %MainPs
%109 = OpExtInst %void %1 DebugScope %68
%85 = OpExtInst %void %1 DebugDeclare %72 %param_var_i %52
%110 = OpExtInst %void %1 DebugScope %69
%87 = OpExtInst %void %1 DebugDeclare %71 %78 %52
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugFunctionDefinition %68 %MainPs
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugScope %68
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugDeclare %72 %param_var_i %52
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugScope %69
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugDeclare %71 %78 %52
%88 = OpAccessChain %_ptr_Function_v2float %param_var_i %int_0
%89 = OpLoad %v2float %88
OpStore %79 %89
;CHECK-NOT: OpStore %79 %89
%106 = OpExtInst %void %1 DebugValue %70 %89 %52
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugValue %70 %89 %52
%91 = OpLoad %type_2d_image %g_tColor
%92 = OpLoad %type_sampler %g_sAniso
%94 = OpSampledImage %type_sampled_image %91 %92
%95 = OpImageSampleImplicitLod %v4float %94 %89 None
%96 = OpAccessChain %_ptr_Function_v4float %78 %int_0
OpStore %96 %95
%97 = OpLoad %PS_OUTPUT %78
OpStore %81 %97
%111 = OpExtInst %void %1 DebugNoScope
;CHECK: {{%\w+}} = OpExtInst %void %1 DebugNoScope
%100 = OpCompositeExtract %v4float %97 0
OpStore %out_var_SV_Target0 %100
OpReturn
OpFunctionEnd
)";
SetTargetEnv(SPV_ENV_VULKAN_1_2);
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
}
TEST_F(AggressiveDCETest, DebugInfoDeclareKeepsStore) {
// Verify that local variable tc and its store are kept by DebugDeclare.
//

View File

@ -2165,6 +2165,140 @@ OpFunctionEnd
SinglePassRunAndMatch<SSARewritePass>(text, true);
}
TEST_F(LocalSSAElimTest, ShaderDebugForLoop) {
const std::string text = R"(
; CHECK: [[f_name:%\w+]] = OpString "f"
; CHECK: [[i_name:%\w+]] = OpString "i"
; CHECK: [[dbg_f:%\w+]] = OpExtInst %void [[ext:%\d+]] DebugLocalVariable [[f_name]]
; CHECK: [[dbg_i:%\w+]] = OpExtInst %void [[ext]] DebugLocalVariable [[i_name]]
; CHECK: OpStore %f %float_0
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_f]] %float_0
; CHECK-NEXT: OpStore %i %int_0
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_i]] %int_0
; CHECK-NOT: DebugDeclare
; CHECK: [[loop_head:%\w+]] = OpLabel
; CHECK: [[phi0:%\w+]] = OpPhi %float %float_0
; CHECK: [[phi1:%\w+]] = OpPhi %int %int_0
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_f]] [[phi0]]
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_i]] [[phi1]]
; CHECK: OpLoopMerge [[loop_merge:%\w+]] [[loop_cont:%\w+]] None
; CHECK-NEXT: OpBranch [[loop_body:%\w+]]
; CHECK-NEXT: [[loop_body]] = OpLabel
; CHECK: OpBranchConditional {{%\w+}} [[bb:%\w+]] [[loop_merge]]
; CHECK: [[bb]] = OpLabel
; CHECK: OpStore %f [[f_val:%\w+]]
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_f]] [[f_val]]
; CHECK-NEXT: OpBranch [[loop_cont]]
; CHECK: [[loop_cont]] = OpLabel
; CHECK: OpStore %i [[i_val:%\w+]]
; CHECK-NEXT: OpExtInst %void [[ext]] DebugValue [[dbg_i]] [[i_val]]
; CHECK-NEXT: OpBranch [[loop_head]]
; CHECK: [[loop_merge]] = OpLabel
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%1 = OpExtInstImport "GLSL.std.450"
%ext = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %BC %fo
OpExecutionMode %main OriginUpperLeft
%file_name = OpString "test"
OpSource GLSL 140
%float_name = OpString "float"
%main_name = OpString "main"
%f_name = OpString "f"
%i_name = OpString "i"
OpName %main "main"
OpName %f "f"
OpName %i "i"
OpName %BC "BC"
OpName %fo "fo"
%void = OpTypeVoid
%8 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%float_0 = OpConstant %float 0
%int = OpTypeInt 32 1
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%uint_10 = OpConstant %uint 10
%uint_32 = OpConstant %uint 32
%_ptr_Function_int = OpTypePointer Function %int
%int_0 = OpConstant %int 0
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%v4float = OpTypeVector %float 4
%_ptr_Input_v4float = OpTypePointer Input %v4float
%BC = OpVariable %_ptr_Input_v4float Input
%_ptr_Input_float = OpTypePointer Input %float
%int_1 = OpConstant %int 1
%_ptr_Output_float = OpTypePointer Output %float
%fo = OpVariable %_ptr_Output_float Output
%null_expr = OpExtInst %void %ext DebugExpression
%src = OpExtInst %void %ext DebugSource %file_name
%cu = OpExtInst %void %ext DebugCompilationUnit %uint_1 %uint_4 %src %uint_5
%dbg_tf = OpExtInst %void %ext DebugTypeBasic %float_name %uint_32 %uint_3 %uint_0
%dbg_v4f = OpExtInst %void %ext DebugTypeVector %dbg_tf %uint_4
%main_ty = OpExtInst %void %ext DebugTypeFunction %uint_3 %dbg_v4f %dbg_v4f
%dbg_main = OpExtInst %void %ext DebugFunction %main_name %main_ty %src %uint_0 %uint_0 %cu %main_name %uint_3 %uint_10
%dbg_f = OpExtInst %void %ext DebugLocalVariable %f_name %dbg_v4f %src %uint_0 %uint_0 %dbg_main %uint_4
%dbg_i = OpExtInst %void %ext DebugLocalVariable %i_name %dbg_v4f %src %uint_0 %uint_0 %dbg_main %uint_4
%main = OpFunction %void None %8
%22 = OpLabel
%s0 = OpExtInst %void %ext DebugScope %dbg_main
%f = OpVariable %_ptr_Function_float Function
%i = OpVariable %_ptr_Function_int Function
OpStore %f %float_0
OpStore %i %int_0
%decl0 = OpExtInst %void %ext DebugDeclare %dbg_f %f %null_expr
%decl1 = OpExtInst %void %ext DebugDeclare %dbg_i %i %null_expr
OpBranch %23
%23 = OpLabel
%s1 = OpExtInst %void %ext DebugScope %dbg_main
OpLoopMerge %24 %25 None
OpBranch %26
%26 = OpLabel
%s2 = OpExtInst %void %ext DebugScope %dbg_main
%27 = OpLoad %int %i
%28 = OpSLessThan %bool %27 %int_4
OpBranchConditional %28 %29 %24
%29 = OpLabel
%s3 = OpExtInst %void %ext DebugScope %dbg_main
%30 = OpLoad %float %f
%31 = OpLoad %int %i
%32 = OpAccessChain %_ptr_Input_float %BC %31
%33 = OpLoad %float %32
%34 = OpFAdd %float %30 %33
OpStore %f %34
OpBranch %25
%25 = OpLabel
%s4 = OpExtInst %void %ext DebugScope %dbg_main
%35 = OpLoad %int %i
%36 = OpIAdd %int %35 %int_1
OpStore %i %36
OpBranch %23
%24 = OpLabel
%s5 = OpExtInst %void %ext DebugScope %dbg_main
%37 = OpLoad %float %f
OpStore %fo %37
OpReturn
OpFunctionEnd
)";
SinglePassRunAndMatch<SSARewritePass>(text, true);
}
TEST_F(LocalSSAElimTest, AddDebugValueForFunctionParameterWithPhi) {
// Test the distribution of DebugValue for a parameter of an inlined function
// and the visibility of Phi instruction. The ssa-rewrite pass must add

View File

@ -1935,12 +1935,12 @@ OpName %6 "simple_struct"
; CHECK: [[dbg_local_var:%\w+]] = OpExtInst %void [[ext]] DebugLocalVariable
; CHECK: [[deref_expr:%\w+]] = OpExtInst %void [[ext]] DebugExpression [[deref]]
; CHECK: [[repl3:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl3]] [[deref_expr]] %int_3
; CHECK: [[repl2:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl2]] [[deref_expr]] %int_2
; CHECK: [[repl1:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl1]] [[deref_expr]] %int_1
; CHECK: [[repl0:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl3]] [[deref_expr]] %int_3
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl2]] [[deref_expr]] %int_2
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl1]] [[deref_expr]] %int_1
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl0]] [[deref_expr]] %int_0
; CHECK-NOT: DebugDeclare
%decl = OpExtInst %1 %ext DebugDeclare %dbg_foo %14 %null_expr
@ -2058,10 +2058,10 @@ OpName %6 "simple_struct"
; CHECK: [[repl2:%\w+]] = OpVariable %_ptr_Function_float Function %float_1
; CHECK: [[repl1:%\w+]] = OpVariable %_ptr_Function_uint Function %uint_32
; CHECK: [[repl3:%\w+]] = OpVariable %_ptr_Function_float Function %float_1
; CHECK: [[repl0:%\w+]] = OpVariable %_ptr_Function_uint Function %uint_32
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl3]] [[deref_expr]] %int_2
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl1]] [[deref_expr]] %int_1 %int_0
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl2]] [[deref_expr]] %int_1 %int_1
; CHECK: [[repl0:%\w+]] = OpVariable %_ptr_Function_uint Function %uint_32
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl0]] [[deref_expr]] %int_0
; CHECK-NOT: DebugDeclare
%decl = OpExtInst %1 %ext DebugDeclare %dbg_foo %14 %null_expr
@ -2174,12 +2174,12 @@ OpName %6 "simple_struct"
; CHECK: [[dbg_local_var:%\w+]] = OpExtInst %void [[ext:%\w+]] DebugLocalVariable
; CHECK: [[repl3:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl3]] [[deref_expr:%\w+]] %int_3
; CHECK: [[repl2:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl2]] [[deref_expr]] %int_2
; CHECK: [[repl1:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl1]] [[deref_expr]] %int_1
; CHECK: [[repl0:%\w+]] = OpVariable %_ptr_Function_uint Function
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl3]] [[deref_expr:%\w+]] %int_3
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl2]] [[deref_expr]] %int_2
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl1]] [[deref_expr]] %int_1
; CHECK: OpExtInst %void [[ext]] DebugValue [[dbg_local_var]] [[repl0]] [[deref_expr]] %int_0
OpBranch %20

View File

@ -354,7 +354,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugSourceInFunction) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst,
@ -436,7 +436,7 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string constants = R"(
@ -738,7 +738,7 @@ INSTANTIATE_TEST_SUITE_P(OpenCLAndVkDebugInfo100, ValidateXDebugInfo,
)",
R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)",
}));
@ -798,7 +798,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugCompilationUnitFail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string constants = R"(
@ -872,7 +872,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailName) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -941,7 +941,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailSize) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1107,7 +1107,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1141,7 +1141,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1398,7 +1398,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1436,7 +1436,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1466,7 +1466,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1499,7 +1499,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1534,7 +1534,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1569,7 +1569,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountZero) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1610,7 +1610,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1762,7 +1762,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1792,7 +1792,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1825,7 +1825,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1858,7 +1858,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -1967,7 +1967,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2001,7 +2001,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -2152,7 +2152,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2184,7 +2184,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2219,7 +2219,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2349,7 +2349,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2383,7 +2383,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -2705,7 +2705,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -2753,7 +2753,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -2822,7 +2822,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -3029,7 +3029,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -3069,7 +3069,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -3133,7 +3133,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -3290,7 +3290,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLexicalBlock) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -3321,7 +3321,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -3363,7 +3363,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -3394,7 +3394,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -3505,7 +3505,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -3540,7 +3540,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -3736,7 +3736,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -3753,7 +3753,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclareParam) {
CompileSuccessfully(R"(
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%1 = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %in_var_COLOR
%4 = OpString "test.hlsl"
@ -3843,7 +3843,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const auto& param = GetParam();
@ -3913,7 +3913,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpression) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header,
@ -3929,7 +3929,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpressionFail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header,
@ -4159,7 +4159,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4198,7 +4198,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4237,7 +4237,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4274,7 +4274,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4315,7 +4315,7 @@ main() {}
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4522,7 +4522,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4555,7 +4555,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4587,7 +4587,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4618,7 +4618,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
@ -4652,7 +4652,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(),
@ -4806,7 +4806,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -4844,7 +4844,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -4883,7 +4883,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -5042,7 +5042,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValue) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -5084,7 +5084,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const std::string body = R"(
@ -5122,7 +5122,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) {
const std::string extension = R"(
OpExtension "SPV_KHR_non_semantic_info"
%DbgExt = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
)";
const auto& param = GetParam();
@ -5153,7 +5153,7 @@ TEST_F(ValidateVulkan100DebugInfo, VulkanDebugInfoSample) {
ss << R"(
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%id_1 = OpExtInstImport "NonSemantic.Vulkan.DebugInfo.100"
%id_1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %id_MainPs "MainPs" %id_in_var_TEXCOORD2 %id_out_var_SV_Target0
OpExecutionMode %id_MainPs OriginUpperLeft