Fix regression (#3481)

Fixes #3480.
This commit is contained in:
Vasyl Teliman 2020-07-02 12:51:10 +03:00 committed by GitHub
parent 4a92579a45
commit 2c1ff230c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -105,6 +105,13 @@ void TransformationAddParameter::Apply(
if (ir_context->get_def_use_mgr()->NumUsers(old_function_type) == 1) {
// Adjust existing function type if it is used only by this function.
old_function_type->AddOperand({SPV_OPERAND_TYPE_ID, {parameter_type_id}});
// We must make sure that all dependencies of |old_function_type| are
// evaluated before |old_function_type| (i.e. the domination rules are not
// broken). Thus, we move |old_function_type| to the end of the list of all
// types in the module.
old_function_type->RemoveFromList();
ir_context->AddType(std::unique_ptr<opt::Instruction>(old_function_type));
} else {
// Otherwise, either create a new type or use an existing one.
std::vector<uint32_t> type_ids;

View File

@ -102,9 +102,9 @@ TEST(TransformationAddParameterTest, BasicTest) {
%7 = OpTypeBool
%11 = OpTypeInt 32 1
%3 = OpTypeFunction %2
%6 = OpTypeFunction %7 %7 %11
%8 = OpConstant %11 23
%12 = OpConstantTrue %7
%6 = OpTypeFunction %7 %7 %11
%4 = OpFunction %2 None %3
%5 = OpLabel
%13 = OpFunctionCall %7 %9 %12 %8