From: Justin Viiret Date: Thu, 25 Aug 2016 05:12:28 +0000 (+1000) Subject: rose: tighten up requirements for catch up X-Git-Tag: v4.4.0^2~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4fa6cd4dd9c4de6af83cec502fb64ea46f0fa27;p=thirdparty%2Fvectorscan.git rose: tighten up requirements for catch up We only need to catch up when there is an actual anchored table, not merely when there are successors of anchored_root in the Rose graph. --- diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index b8baa9c1..ed9b5bbb 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -554,33 +554,30 @@ u32 countRosePrefixes(const vector &roses) { * \brief True if this Rose engine needs to run a catch up whenever a report is * generated. * - * This is only the case if there are no anchored literals, suffixes, outfixes - * etc. + * Catch up is necessary if there are output-exposed engines (suffixes, + * outfixes) or an anchored table (anchored literals, acyclic DFAs). */ static -bool needsCatchup(const RoseBuildImpl &build) { +bool needsCatchup(const RoseBuildImpl &build, + const vector &anchored_dfas) { if (!build.outfixes.empty()) { DEBUG_PRINTF("has outfixes\n"); return true; } - - const RoseGraph &g = build.g; - - if (!isLeafNode(build.anchored_root, g)) { - DEBUG_PRINTF("has anchored vertices\n"); + if (!anchored_dfas.empty()) { + DEBUG_PRINTF("has anchored dfas\n"); return true; } + const RoseGraph &g = build.g; + for (auto v : vertices_range(g)) { if (build.root == v) { continue; } - if (build.anchored_root == v) { - assert(isLeafNode(v, g)); continue; } - if (g[v].suffix) { DEBUG_PRINTF("vertex %zu has suffix\n", g[v].idx); return true; @@ -5286,7 +5283,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { build_context bc; bc.floatingMinLiteralMatchOffset = findMinFloatingLiteralMatch(*this, anchored_dfas); - bc.needs_catchup = needsCatchup(*this); + bc.needs_catchup = needsCatchup(*this, anchored_dfas); recordResources(bc.resources, *this); if (!anchored_dfas.empty()) { bc.resources.has_anchored = true;