From 648a3c48247ad9ba1ec0386843a9813a47436050 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Thu, 15 Sep 2016 11:22:29 +1000 Subject: [PATCH] UE-3025: There is no need to prune tops from non-triggered graphs --- src/nfagraph/ng_limex.cpp | 3 +++ src/rose/rose_build_role_aliasing.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/nfagraph/ng_limex.cpp b/src/nfagraph/ng_limex.cpp index b9f3434b..c6e4c24e 100644 --- a/src/nfagraph/ng_limex.cpp +++ b/src/nfagraph/ng_limex.cpp @@ -512,6 +512,9 @@ u32 isImplementableNFA(const NGHolder &g, const ReportManager *rm, if (!cc.grey.allowLimExNFA) { return false; } + + assert(!can_never_match(g)); + // 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 // those here too. diff --git a/src/rose/rose_build_role_aliasing.cpp b/src/rose/rose_build_role_aliasing.cpp index 66e44b3e..6a0c767d 100644 --- a/src/rose/rose_build_role_aliasing.cpp +++ b/src/rose/rose_build_role_aliasing.cpp @@ -863,6 +863,12 @@ void pruneUnusedTops(CastleProto &castle, const RoseGraph &g, static void pruneUnusedTops(NGHolder &h, const RoseGraph &g, const set &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 used_tops; for (auto v : verts) { assert(g[v].left.graph.get() == &h); @@ -2023,6 +2029,7 @@ void aliasRoles(RoseBuildImpl &build, bool mergeRoses) { const CompileContext &cc = build.cc; RoseGraph &g = build.g; assert(!hasOrphanedTops(build)); + assert(canImplementGraphs(build)); if (!cc.grey.roseRoleAliasing || !cc.grey.roseGraphReduction) { return; @@ -2057,6 +2064,7 @@ void aliasRoles(RoseBuildImpl &build, bool mergeRoses) { DEBUG_PRINTF("killed %zu vertices\n", dead.size()); build.removeVertices(dead); assert(!hasOrphanedTops(build)); + assert(canImplementGraphs(build)); } } // namespace ue2