Coverage Report

Created: 2026-02-14 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/spirv-tools/source/opt/block_merge_pass.h
Line
Count
Source
1
// Copyright (c) 2017 The Khronos Group Inc.
2
// Copyright (c) 2017 Valve Corporation
3
// Copyright (c) 2017 LunarG Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
//     http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#ifndef SOURCE_OPT_BLOCK_MERGE_PASS_H_
18
#define SOURCE_OPT_BLOCK_MERGE_PASS_H_
19
20
#include <algorithm>
21
#include <map>
22
#include <queue>
23
#include <unordered_map>
24
#include <unordered_set>
25
#include <utility>
26
27
#include "source/opt/basic_block.h"
28
#include "source/opt/def_use_manager.h"
29
#include "source/opt/ir_context.h"
30
#include "source/opt/module.h"
31
#include "source/opt/pass.h"
32
33
namespace spvtools {
34
namespace opt {
35
36
// See optimizer.hpp for documentation.
37
class BlockMergePass : public Pass {
38
 public:
39
  BlockMergePass();
40
19.9k
  const char* name() const override { return "merge-blocks"; }
41
  Status Process() override;
42
43
6.55k
  IRContext::Analysis GetPreservedAnalyses() override {
44
6.55k
    return IRContext::kAnalysisDefUse |
45
6.55k
           IRContext::kAnalysisInstrToBlockMapping |
46
6.55k
           IRContext::kAnalysisDecorations | IRContext::kAnalysisCombinators |
47
6.55k
           IRContext::kAnalysisNameMap | IRContext::kAnalysisConstants |
48
6.55k
           IRContext::kAnalysisTypes;
49
6.55k
  }
50
51
 private:
52
53
  // Search |func| for blocks which have a single Branch to a block
54
  // with no other predecessors. Merge these blocks into a single block.
55
  bool MergeBlocks(Function* func);
56
57
};
58
59
}  // namespace opt
60
}  // namespace spvtools
61
62
#endif  // SOURCE_OPT_BLOCK_MERGE_PASS_H_