aboutsummaryrefslogtreecommitdiff
path: root/source/fuzz/fuzzer_pass_add_dead_breaks.cpp
diff options
context:
space:
mode:
authorAlastair Donaldson <afdx@google.com>2019-06-25 20:49:46 +0100
committerGitHub <noreply@github.com>2019-06-25 20:49:46 +0100
commitdfcb5a1e1042f2debae1ca11405d5d2e508e50c5 (patch)
tree97096ea27ba5345de78bf20246d62f89d484a729 /source/fuzz/fuzzer_pass_add_dead_breaks.cpp
parent888aeef8a908f881d83ab70f0b5f42d4da4b050f (diff)
downloadSPIRV-Tools-dfcb5a1e1042f2debae1ca11405d5d2e508e50c5.tar.gz
Refactor fuzzer transformations (#2694)
Introduced abstract class for transformations, and refactored all transformations to inherit from this abstract class.
Diffstat (limited to 'source/fuzz/fuzzer_pass_add_dead_breaks.cpp')
-rw-r--r--source/fuzz/fuzzer_pass_add_dead_breaks.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/source/fuzz/fuzzer_pass_add_dead_breaks.cpp b/source/fuzz/fuzzer_pass_add_dead_breaks.cpp
index eef28d91..62e2a8b8 100644
--- a/source/fuzz/fuzzer_pass_add_dead_breaks.cpp
+++ b/source/fuzz/fuzzer_pass_add_dead_breaks.cpp
@@ -30,7 +30,7 @@ FuzzerPassAddDeadBreaks::~FuzzerPassAddDeadBreaks() = default;
void FuzzerPassAddDeadBreaks::Apply() {
// We first collect up lots of possibly-applicable transformations.
- std::vector<protobufs::TransformationAddDeadBreak> candidate_transformations;
+ std::vector<TransformationAddDeadBreak> candidate_transformations;
// We consider each function separately.
for (auto& function : *GetIRContext()->module()) {
// For a given function, we find all the merge blocks in that function.
@@ -51,13 +51,12 @@ void FuzzerPassAddDeadBreaks::Apply() {
// merge blocks. This will lead to interesting opportunities being
// missed.
std::vector<uint32_t> phi_ids;
- auto candidate_transformation =
- transformation::MakeTransformationAddDeadBreak(
- block.id(), merge_block_id,
- GetFuzzerContext()->GetRandomGenerator()->RandomBool(),
- std::move(phi_ids));
- if (transformation::IsApplicable(candidate_transformation,
- GetIRContext(), *GetFactManager())) {
+ auto candidate_transformation = TransformationAddDeadBreak(
+ block.id(), merge_block_id,
+ GetFuzzerContext()->GetRandomGenerator()->RandomBool(),
+ std::move(phi_ids));
+ if (candidate_transformation.IsApplicable(GetIRContext(),
+ *GetFactManager())) {
// Only consider a transformation as a candidate if it is applicable.
candidate_transformations.push_back(
std::move(candidate_transformation));
@@ -92,11 +91,9 @@ void FuzzerPassAddDeadBreaks::Apply() {
}
// If the transformation can be applied, apply it and add it to the
// sequence of transformations that have been applied.
- if (transformation::IsApplicable(transformation, GetIRContext(),
- *GetFactManager())) {
- transformation::Apply(transformation, GetIRContext(), GetFactManager());
- *GetTransformations()->add_transformation()->mutable_add_dead_break() =
- transformation;
+ if (transformation.IsApplicable(GetIRContext(), *GetFactManager())) {
+ transformation.Apply(GetIRContext(), GetFactManager());
+ *GetTransformations()->add_transformation() = transformation.ToMessage();
}
}
}