• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SOURCE_FUZZ_FACT_MANAGER_LIVESAFE_FUNCTION_FACTS_H_
16 #define SOURCE_FUZZ_FACT_MANAGER_LIVESAFE_FUNCTION_FACTS_H_
17 
18 #include <unordered_set>
19 
20 #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
21 #include "source/opt/ir_context.h"
22 
23 namespace spvtools {
24 namespace fuzz {
25 namespace fact_manager {
26 
27 // The purpose of this class is to group the fields and data used to represent
28 // facts about livesafe functions.
29 class LivesafeFunctionFacts {
30  public:
31   explicit LivesafeFunctionFacts(opt::IRContext* ir_context);
32 
33   // See method in FactManager which delegates to this method. Returns true if
34   // |fact.function_id()| is a result id of some non-entry-point function in
35   // |ir_context_|. Returns false otherwise.
36   bool MaybeAddFact(const protobufs::FactFunctionIsLivesafe& fact);
37 
38   // See method in FactManager which delegates to this method.
39   bool FunctionIsLivesafe(uint32_t function_id) const;
40 
41  private:
42   std::unordered_set<uint32_t> livesafe_function_ids_;
43   opt::IRContext* ir_context_;
44 };
45 
46 }  // namespace fact_manager
47 }  // namespace fuzz
48 }  // namespace spvtools
49 
50 #endif  // SOURCE_FUZZ_FACT_MANAGER_LIVESAFE_FUNCTION_FACTS_H_
51