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.
|
// 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
|
// 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.
|
// of an infinite loop, since it is not part of the post-dominator tree.
|
||||||
bool DoesBlockExist(uint32_t id) const {
|
bool HasBlock(uint32_t id) const { return forward_nodes_.count(id) > 0; }
|
||||||
return forward_nodes_.count(id) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if block |a| is dependent on block |b|.
|
// Returns true if block |a| is dependent on block |b|.
|
||||||
bool IsDependent(uint32_t a, uint32_t b) const {
|
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
|
// BBs tend to have more dependents (targets) than they are dependent on
|
||||||
// (sources), so search sources.
|
// (sources), so search sources.
|
||||||
const ControlDependenceList& a_sources = GetDependenceSources(a);
|
const ControlDependenceList& a_sources = GetDependenceSources(a);
|
||||||
|
@ -122,16 +122,15 @@ TEST(ControlDependenceTest, DependenceSimpleCFG) {
|
|||||||
ControlDependenceAnalysis cdg;
|
ControlDependenceAnalysis cdg;
|
||||||
cdg.ComputeControlDependenceGraph(cfg, pdom);
|
cdg.ComputeControlDependenceGraph(cfg, pdom);
|
||||||
|
|
||||||
// Test DoesBlockExist.
|
// Test HasBlock.
|
||||||
for (uint32_t id = 10; id <= 19; id++) {
|
for (uint32_t id = 10; id <= 19; id++) {
|
||||||
EXPECT_TRUE(cdg.DoesBlockExist(id));
|
EXPECT_TRUE(cdg.HasBlock(id));
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(cdg.HasBlock(ControlDependenceAnalysis::kPseudoEntryBlock));
|
||||||
cdg.DoesBlockExist(ControlDependenceAnalysis::kPseudoEntryBlock));
|
|
||||||
// Check blocks before/after valid range.
|
// Check blocks before/after valid range.
|
||||||
EXPECT_FALSE(cdg.DoesBlockExist(5));
|
EXPECT_FALSE(cdg.HasBlock(5));
|
||||||
EXPECT_FALSE(cdg.DoesBlockExist(25));
|
EXPECT_FALSE(cdg.HasBlock(25));
|
||||||
EXPECT_FALSE(cdg.DoesBlockExist(UINT32_MAX));
|
EXPECT_FALSE(cdg.HasBlock(UINT32_MAX));
|
||||||
|
|
||||||
// Test ForEachBlockLabel.
|
// Test ForEachBlockLabel.
|
||||||
std::set<uint32_t> block_labels;
|
std::set<uint32_t> block_labels;
|
||||||
|
Loading…
Reference in New Issue
Block a user