mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-27 01:21:25 +00:00
spirv-opt: Rename ControlDependenceAnalysis::DoesBlockExist to HasBlock (#4412)
Suggested by Jakub as 'DoesBlockExist' was confusing.
This commit is contained in:
parent
983ee2313c
commit
c6422cff33
@ -156,13 +156,11 @@ class ControlDependenceAnalysis {
|
||||
// Returns true if the block |id| exists in the control dependence graph.
|
||||
// This can be false even if the block exists in the function when it is part
|
||||
// of an infinite loop, since it is not part of the post-dominator tree.
|
||||
bool DoesBlockExist(uint32_t id) const {
|
||||
return forward_nodes_.count(id) > 0;
|
||||
}
|
||||
bool HasBlock(uint32_t id) const { return forward_nodes_.count(id) > 0; }
|
||||
|
||||
// Returns true if block |a| is dependent on block |b|.
|
||||
bool IsDependent(uint32_t a, uint32_t b) const {
|
||||
if (!DoesBlockExist(a)) return false;
|
||||
if (!HasBlock(a)) return false;
|
||||
// BBs tend to have more dependents (targets) than they are dependent on
|
||||
// (sources), so search sources.
|
||||
const ControlDependenceList& a_sources = GetDependenceSources(a);
|
||||
|
@ -122,16 +122,15 @@ TEST(ControlDependenceTest, DependenceSimpleCFG) {
|
||||
ControlDependenceAnalysis cdg;
|
||||
cdg.ComputeControlDependenceGraph(cfg, pdom);
|
||||
|
||||
// Test DoesBlockExist.
|
||||
// Test HasBlock.
|
||||
for (uint32_t id = 10; id <= 19; id++) {
|
||||
EXPECT_TRUE(cdg.DoesBlockExist(id));
|
||||
EXPECT_TRUE(cdg.HasBlock(id));
|
||||
}
|
||||
EXPECT_TRUE(
|
||||
cdg.DoesBlockExist(ControlDependenceAnalysis::kPseudoEntryBlock));
|
||||
EXPECT_TRUE(cdg.HasBlock(ControlDependenceAnalysis::kPseudoEntryBlock));
|
||||
// Check blocks before/after valid range.
|
||||
EXPECT_FALSE(cdg.DoesBlockExist(5));
|
||||
EXPECT_FALSE(cdg.DoesBlockExist(25));
|
||||
EXPECT_FALSE(cdg.DoesBlockExist(UINT32_MAX));
|
||||
EXPECT_FALSE(cdg.HasBlock(5));
|
||||
EXPECT_FALSE(cdg.HasBlock(25));
|
||||
EXPECT_FALSE(cdg.HasBlock(UINT32_MAX));
|
||||
|
||||
// Test ForEachBlockLabel.
|
||||
std::set<uint32_t> block_labels;
|
||||
|
Loading…
Reference in New Issue
Block a user