|
@@ -27,6 +27,7 @@
|
|
|
#include "source/fuzz/transformation_add_function.h"
|
|
#include "source/fuzz/transformation_add_function.h"
|
|
|
#include "source/fuzz/transformation_add_global_undef.h"
|
|
#include "source/fuzz/transformation_add_global_undef.h"
|
|
|
#include "source/fuzz/transformation_add_global_variable.h"
|
|
#include "source/fuzz/transformation_add_global_variable.h"
|
|
|
|
|
+#include "source/fuzz/transformation_add_spec_constant_op.h"
|
|
|
#include "source/fuzz/transformation_add_type_array.h"
|
|
#include "source/fuzz/transformation_add_type_array.h"
|
|
|
#include "source/fuzz/transformation_add_type_boolean.h"
|
|
#include "source/fuzz/transformation_add_type_boolean.h"
|
|
|
#include "source/fuzz/transformation_add_type_float.h"
|
|
#include "source/fuzz/transformation_add_type_float.h"
|
|
@@ -413,14 +414,41 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
|
|
|
argument_type_ids));
|
|
argument_type_ids));
|
|
|
}
|
|
}
|
|
|
} break;
|
|
} break;
|
|
|
|
|
+ case SpvOpSpecConstantOp: {
|
|
|
|
|
+ new_result_id = GetFuzzerContext()->GetFreshId();
|
|
|
|
|
+ auto type_id = original_id_to_donated_id->at(type_or_value.type_id());
|
|
|
|
|
+ auto opcode = static_cast<SpvOp>(type_or_value.GetSingleWordInOperand(0));
|
|
|
|
|
+
|
|
|
|
|
+ // Make sure we take into account |original_id_to_donated_id| when
|
|
|
|
|
+ // computing operands for OpSpecConstantOp.
|
|
|
|
|
+ opt::Instruction::OperandList operands;
|
|
|
|
|
+ for (uint32_t i = 1; i < type_or_value.NumInOperands(); ++i) {
|
|
|
|
|
+ const auto& operand = type_or_value.GetInOperand(i);
|
|
|
|
|
+ auto data =
|
|
|
|
|
+ operand.type == SPV_OPERAND_TYPE_ID
|
|
|
|
|
+ ? opt::Operand::OperandData{original_id_to_donated_id->at(
|
|
|
|
|
+ operand.words[0])}
|
|
|
|
|
+ : operand.words;
|
|
|
|
|
+
|
|
|
|
|
+ operands.push_back({operand.type, std::move(data)});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ApplyTransformation(TransformationAddSpecConstantOp(
|
|
|
|
|
+ new_result_id, type_id, opcode, std::move(operands)));
|
|
|
|
|
+ } break;
|
|
|
|
|
+ case SpvOpSpecConstantTrue:
|
|
|
|
|
+ case SpvOpSpecConstantFalse:
|
|
|
case SpvOpConstantTrue:
|
|
case SpvOpConstantTrue:
|
|
|
case SpvOpConstantFalse: {
|
|
case SpvOpConstantFalse: {
|
|
|
// It is OK to have duplicate definitions of True and False, so add
|
|
// It is OK to have duplicate definitions of True and False, so add
|
|
|
// these to the module, using a remapped Bool type.
|
|
// these to the module, using a remapped Bool type.
|
|
|
new_result_id = GetFuzzerContext()->GetFreshId();
|
|
new_result_id = GetFuzzerContext()->GetFreshId();
|
|
|
- ApplyTransformation(TransformationAddConstantBoolean(
|
|
|
|
|
- new_result_id, type_or_value.opcode() == SpvOpConstantTrue));
|
|
|
|
|
|
|
+ auto value = type_or_value.opcode() == SpvOpConstantTrue ||
|
|
|
|
|
+ type_or_value.opcode() == SpvOpSpecConstantTrue;
|
|
|
|
|
+ ApplyTransformation(
|
|
|
|
|
+ TransformationAddConstantBoolean(new_result_id, value));
|
|
|
} break;
|
|
} break;
|
|
|
|
|
+ case SpvOpSpecConstant:
|
|
|
case SpvOpConstant: {
|
|
case SpvOpConstant: {
|
|
|
// It is OK to have duplicate constant definitions, so add this to the
|
|
// It is OK to have duplicate constant definitions, so add this to the
|
|
|
// module using a remapped result type.
|
|
// module using a remapped result type.
|
|
@@ -433,6 +461,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
|
|
|
new_result_id, original_id_to_donated_id->at(type_or_value.type_id()),
|
|
new_result_id, original_id_to_donated_id->at(type_or_value.type_id()),
|
|
|
data_words));
|
|
data_words));
|
|
|
} break;
|
|
} break;
|
|
|
|
|
+ case SpvOpSpecConstantComposite:
|
|
|
case SpvOpConstantComposite: {
|
|
case SpvOpConstantComposite: {
|
|
|
assert(original_id_to_donated_id->count(type_or_value.type_id()) &&
|
|
assert(original_id_to_donated_id->count(type_or_value.type_id()) &&
|
|
|
"Composite types for which it is possible to create a constant "
|
|
"Composite types for which it is possible to create a constant "
|