linked_module->AddDebug2Inst(
std::unique_ptr<Instruction>(inst.Clone(linked_context)));
+ for (const auto& module : input_modules)
+ for (const auto& inst : module->debugs3())
+ linked_module->AddDebug3Inst(
+ std::unique_ptr<Instruction>(inst.Clone(linked_context)));
+
+ // If the generated module uses SPIR-V 1.1 or higher, add an
+ // OpModuleProcessed instruction about the linking step.
+ if (linked_module->version() >= 0x10100) {
+ const std::string processed_string("Linked by SPIR-V Tools Linker");
+ const size_t words_nb =
+ processed_string.size() / 4u + (processed_string.size() % 4u != 0u);
+ std::vector<uint32_t> processed_words(words_nb, 0u);
+ std::memcpy(processed_words.data(), processed_string.data(), words_nb * 4u);
+ linked_module->AddDebug3Inst(std::unique_ptr<Instruction>(
+ new Instruction(linked_context, SpvOpModuleProcessed, 0u, 0u,
+ {{SPV_OPERAND_TYPE_LITERAL_STRING, processed_words}})));
+ }
+
for (const auto& module : input_modules)
for (const auto& inst : module->annotations())
linked_module->AddAnnotationInst(
EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary))
<< GetErrorMessage();
- const std::string expected_res = R"(%1 = OpTypeFloat 32
+ const std::string expected_res =
+ R"(OpModuleProcessed "Linked by SPIR-V Tools Linker"
+%1 = OpTypeFloat 32
%2 = OpVariable %1 Input
%3 = OpConstant %1 42
%4 = OpVariable %1 Uniform %3
EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary))
<< GetErrorMessage();
- const std::string expected_res = R"(%1 = OpTypeFloat 32
+ const std::string expected_res =
+ R"(OpModuleProcessed "Linked by SPIR-V Tools Linker"
+%1 = OpTypeFloat 32
%2 = OpVariable %1 Uniform
)";
std::string res_body;
<< GetErrorMessage();
const std::string expected_res = R"(OpCapability Linkage
+OpModuleProcessed "Linked by SPIR-V Tools Linker"
OpDecorate %1 LinkageAttributes "foo" Export
%2 = OpTypeFloat 32
%1 = OpVariable %2 Uniform
<< GetErrorMessage();
const std::string expected_res = R"(OpCapability Kernel
+OpModuleProcessed "Linked by SPIR-V Tools Linker"
OpDecorate %1 FuncParamAttr Sext
%2 = OpTypeVoid
%3 = OpTypeInt 32 0
EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary))
<< GetErrorMessage();
- const std::string expected_res = R"(%1 = OpTypeVoid
+ const std::string expected_res =
+ R"(OpModuleProcessed "Linked by SPIR-V Tools Linker"
+%1 = OpTypeVoid
%2 = OpTypeFunction %1
%3 = OpTypeFloat 32
%4 = OpVariable %3 Uniform
AssembleAndLink({body1, body2}, &linked_binary, linker_options));
const std::string expected_res = R"(OpCapability Linkage
+OpModuleProcessed "Linked by SPIR-V Tools Linker"
OpDecorate %1 LinkageAttributes "foo" Import
%2 = OpTypeFloat 32
%1 = OpVariable %2 Uniform