1 // Copyright (c) 2019 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "source/fuzz/fact_manager/dead_block_facts.h" 16 17 #include "source/fuzz/fuzzer_util.h" 18 19 namespace spvtools { 20 namespace fuzz { 21 namespace fact_manager { 22 DeadBlockFacts(opt::IRContext * ir_context)23DeadBlockFacts::DeadBlockFacts(opt::IRContext* ir_context) 24 : ir_context_(ir_context) {} 25 MaybeAddFact(const protobufs::FactBlockIsDead & fact)26bool DeadBlockFacts::MaybeAddFact(const protobufs::FactBlockIsDead& fact) { 27 if (!fuzzerutil::MaybeFindBlock(ir_context_, fact.block_id())) { 28 return false; 29 } 30 31 dead_block_ids_.insert(fact.block_id()); 32 return true; 33 } 34 BlockIsDead(uint32_t block_id) const35bool DeadBlockFacts::BlockIsDead(uint32_t block_id) const { 36 return dead_block_ids_.count(block_id) != 0; 37 } 38 GetDeadBlocks() const39const std::unordered_set<uint32_t>& DeadBlockFacts::GetDeadBlocks() const { 40 return dead_block_ids_; 41 } 42 43 } // namespace fact_manager 44 } // namespace fuzz 45 } // namespace spvtools 46