Fix regression (#3481)
Fixes #3480.
diff --git a/source/fuzz/transformation_add_parameter.cpp b/source/fuzz/transformation_add_parameter.cpp
index e1d1597..b2dd7be 100644
--- a/source/fuzz/transformation_add_parameter.cpp
+++ b/source/fuzz/transformation_add_parameter.cpp
@@ -105,6 +105,13 @@
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;
diff --git a/test/fuzz/transformation_add_parameter_test.cpp b/test/fuzz/transformation_add_parameter_test.cpp
index b95f5dd..62e7dc1 100644
--- a/test/fuzz/transformation_add_parameter_test.cpp
+++ b/test/fuzz/transformation_add_parameter_test.cpp
@@ -102,9 +102,9 @@
%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