Coverage Report

Created: 2025-11-19 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/shaderc/third_party/spirv-tools/source/opt/graph.cpp
Line
Count
Source
1
// Copyright (c) 2022-2025 Arm Ltd.
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/opt/graph.h"
16
17
namespace spvtools {
18
namespace opt {
19
20
0
Graph* Graph::Clone(IRContext* ctx) const {
21
0
  Graph* clone = new Graph(std::unique_ptr<Instruction>(DefInst().Clone(ctx)));
22
23
0
  clone->inputs_.reserve(inputs_.size());
24
0
  for (const auto& i : inputs()) {
25
0
    clone->AddInput(std::unique_ptr<Instruction>(i->Clone(ctx)));
26
0
  }
27
28
0
  clone->insts_.reserve(insts_.size());
29
0
  for (const auto& i : instructions()) {
30
0
    clone->AddInstruction(std::unique_ptr<Instruction>(i->Clone(ctx)));
31
0
  }
32
33
0
  clone->outputs_.reserve(outputs_.size());
34
0
  for (const auto& i : outputs()) {
35
0
    clone->AddOutput(std::unique_ptr<Instruction>(i->Clone(ctx)));
36
0
  }
37
38
0
  clone->SetGraphEnd(std::unique_ptr<Instruction>(EndInst()->Clone(ctx)));
39
40
0
  return clone;
41
0
}
42
43
void Graph::ForEachInst(const std::function<void(Instruction*)>& f,
44
                        bool run_on_debug_line_insts,
45
0
                        bool run_on_non_semantic_insts) {
46
0
  (void)run_on_debug_line_insts;
47
0
  (void)run_on_non_semantic_insts;
48
49
0
  f(def_inst_.get());
50
51
0
  for (auto& inst : inputs_) {
52
0
    f(inst.get());
53
0
  }
54
55
0
  for (auto& inst : insts_) {
56
0
    f(inst.get());
57
0
  }
58
59
0
  for (auto& inst : outputs_) {
60
0
    f(inst.get());
61
0
  }
62
63
0
  f(end_inst_.get());
64
0
}
65
66
void Graph::ForEachInst(const std::function<void(const Instruction*)>& f,
67
                        bool run_on_debug_line_insts,
68
0
                        bool run_on_non_semantic_insts) const {
69
0
  (void)run_on_debug_line_insts;
70
0
  (void)run_on_non_semantic_insts;
71
72
0
  f(def_inst_.get());
73
74
0
  for (auto& inst : inputs_) {
75
0
    f(inst.get());
76
0
  }
77
78
0
  for (auto& inst : insts_) {
79
0
    f(inst.get());
80
0
  }
81
82
0
  for (auto& inst : outputs_) {
83
0
    f(inst.get());
84
0
  }
85
86
0
  f(end_inst_.get());
87
0
}
88
89
}  // namespace opt
90
}  // namespace spvtools