]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose: tighten up requirements for catch up
authorJustin Viiret <justin.viiret@intel.com>
Thu, 25 Aug 2016 05:12:28 +0000 (15:12 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 28 Oct 2016 03:44:20 +0000 (14:44 +1100)
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.

src/rose/rose_build_bytecode.cpp

index b8baa9c15d1772a1dce8954909a1150e2a5e7ac2..ed9b5bbbbed7338685c2e35934d244d7161fdb9f 100644 (file)
@@ -554,33 +554,30 @@ u32 countRosePrefixes(const vector<LeftNfaInfo> &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<raw_dfa> &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<RoseEngine> 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;