UE-3025: There is no need to prune tops from non-triggered graphs

This commit is contained in:
Alex Coyte 2016-09-15 11:22:29 +10:00 committed by Matthew Barr
parent 7d3eff8648
commit 648a3c4824
2 changed files with 11 additions and 0 deletions

View File

@ -512,6 +512,9 @@ u32 isImplementableNFA(const NGHolder &g, const ReportManager *rm,
if (!cc.grey.allowLimExNFA) { if (!cc.grey.allowLimExNFA) {
return false; return false;
} }
assert(!can_never_match(g));
// Quick check: we can always implement an NFA with less than NFA_MAX_STATES // Quick check: we can always implement an NFA with less than NFA_MAX_STATES
// states. Note that top masks can generate extra states, so we account for // states. Note that top masks can generate extra states, so we account for
// those here too. // those here too.

View File

@ -863,6 +863,12 @@ void pruneUnusedTops(CastleProto &castle, const RoseGraph &g,
static static
void pruneUnusedTops(NGHolder &h, const RoseGraph &g, void pruneUnusedTops(NGHolder &h, const RoseGraph &g,
const set<RoseVertex> &verts) { const set<RoseVertex> &verts) {
if (!is_triggered(h)) {
DEBUG_PRINTF("not triggered, no tops\n");
return;
}
assert(isCorrectlyTopped(h));
DEBUG_PRINTF("prunning unused tops\n");
ue2::flat_set<u32> used_tops; ue2::flat_set<u32> used_tops;
for (auto v : verts) { for (auto v : verts) {
assert(g[v].left.graph.get() == &h); assert(g[v].left.graph.get() == &h);
@ -2023,6 +2029,7 @@ void aliasRoles(RoseBuildImpl &build, bool mergeRoses) {
const CompileContext &cc = build.cc; const CompileContext &cc = build.cc;
RoseGraph &g = build.g; RoseGraph &g = build.g;
assert(!hasOrphanedTops(build)); assert(!hasOrphanedTops(build));
assert(canImplementGraphs(build));
if (!cc.grey.roseRoleAliasing || !cc.grey.roseGraphReduction) { if (!cc.grey.roseRoleAliasing || !cc.grey.roseGraphReduction) {
return; return;
@ -2057,6 +2064,7 @@ void aliasRoles(RoseBuildImpl &build, bool mergeRoses) {
DEBUG_PRINTF("killed %zu vertices\n", dead.size()); DEBUG_PRINTF("killed %zu vertices\n", dead.size());
build.removeVertices(dead); build.removeVertices(dead);
assert(!hasOrphanedTops(build)); assert(!hasOrphanedTops(build));
assert(canImplementGraphs(build));
} }
} // namespace ue2 } // namespace ue2