mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
Don't rebuilt valid analyses. (#4733)
The function `BuildInvalideAnalyses` will be rebuilt for every analysis that has been requested, but it is not necessary. It also can cause problems because if the CFG needs to be rebuilt, so do the dominator trees. This change will make the functionality match the description of the function.
This commit is contained in:
parent
d1addc44b2
commit
0b8426346d
@ -41,6 +41,8 @@ namespace spvtools {
|
||||
namespace opt {
|
||||
|
||||
void IRContext::BuildInvalidAnalyses(IRContext::Analysis set) {
|
||||
set = Analysis(set & ~valid_analyses_);
|
||||
|
||||
if (set & kAnalysisDefUse) {
|
||||
BuildDefUseManager();
|
||||
}
|
||||
|
@ -867,8 +867,7 @@ inline IRContext::Analysis operator|(IRContext::Analysis lhs,
|
||||
|
||||
inline IRContext::Analysis& operator|=(IRContext::Analysis& lhs,
|
||||
IRContext::Analysis rhs) {
|
||||
lhs = static_cast<IRContext::Analysis>(static_cast<int>(lhs) |
|
||||
static_cast<int>(rhs));
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
@ -431,6 +431,7 @@ bool MergeReturnPass::BreakFromConstruct(
|
||||
std::list<BasicBlock*>* order, Instruction* break_merge_inst) {
|
||||
// Make sure the CFG is build here. If we don't then it becomes very hard
|
||||
// to know which new blocks need to be updated.
|
||||
context()->InvalidateAnalyses(IRContext::kAnalysisCFG);
|
||||
context()->BuildInvalidAnalyses(IRContext::kAnalysisCFG);
|
||||
|
||||
// When predicating, be aware of whether this block is a header block, a
|
||||
|
@ -90,6 +90,21 @@ TEST_F(IRContextTest, IndividualValidAfterBuild) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(IRContextTest, DontRebuildValidAnalysis) {
|
||||
std::unique_ptr<Module> module(new Module());
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
auto* oldCfg = localContext.cfg();
|
||||
auto* oldDefUse = localContext.get_def_use_mgr();
|
||||
localContext.BuildInvalidAnalyses(IRContext::kAnalysisCFG |
|
||||
IRContext::kAnalysisDefUse);
|
||||
auto* newCfg = localContext.cfg();
|
||||
auto* newDefUse = localContext.get_def_use_mgr();
|
||||
EXPECT_EQ(oldCfg, newCfg);
|
||||
EXPECT_EQ(oldDefUse, newDefUse);
|
||||
}
|
||||
|
||||
TEST_F(IRContextTest, AllValidAfterBuild) {
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
|
Loading…
Reference in New Issue
Block a user