spirv-opt: Rename ControlDependenceAnalysis::DoesBlockExist to HasBlock (#4412)

Suggested by Jakub as 'DoesBlockExist' was confusing.
This commit is contained in:
dong-ja 2021-07-29 07:30:48 -05:00 committed by GitHub
parent 983ee2313c
commit c6422cff33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 11 deletions

View File

@ -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);

View File

@ -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;