]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
remove !LBR constraints from merge passes
authorAlex Coyte <a.coyte@intel.com>
Thu, 10 Aug 2017 03:43:20 +0000 (13:43 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 18 Sep 2017 03:22:56 +0000 (13:22 +1000)
we have either converted candidates to castles already or we have converted them
back in the hope of merging them with other holders

src/nfagraph/ng_lbr.cpp
src/nfagraph/ng_lbr.h
src/rose/rose_build_merge.cpp
unit/internal/lbr.cpp

index 9bf16efeada44e2a7e795a054126fd8b7c658b1b..d8ba503ce6daa201eece405470a0305c94ad7e8e 100644 (file)
@@ -346,24 +346,4 @@ bytecode_ptr<NFA> constructLBR(const NGHolder &g,
     return constructLBR(proto, triggers, cc, rm);
 }
 
-/** \brief True if graph \p g could be turned into an LBR engine. */
-bool isLBR(const NGHolder &g, const Grey &grey) {
-    if (!grey.allowLbr) {
-        return false;
-    }
-
-    PureRepeat repeat;
-    if (!isPureRepeat(g, repeat)) {
-        DEBUG_PRINTF("not pure bounded repeat\n");
-        return false;
-    }
-
-    if (repeat.reports.size() != 1) {
-        DEBUG_PRINTF("too many reports\n");
-        return false;
-    }
-
-    return true;
-}
-
 } // namespace ue2
index 1eec965355aa2e6a658a1a497e821479799d6ca0..c181dbb9e705c1bbe563aa1eb1bdebbcda9375a4 100644 (file)
@@ -66,9 +66,6 @@ constructLBR(const CastleProto &proto,
              const std::vector<std::vector<CharReach>> &triggers,
              const CompileContext &cc, const ReportManager &rm);
 
-/** \brief True if graph \p g could be turned into an LBR engine. */
-bool isLBR(const NGHolder &g, const Grey &grey);
-
 } // namespace ue2
 
 #endif // NG_LBR_H
index 0d73c101b7e8a09d0410e09dcee26da55c17422f..fb7b3a1f051952f5b1a1cc359310b7e93efbdb71 100644 (file)
@@ -101,10 +101,6 @@ static const size_t DFA_CHUNK_SIZE_MAX = 200;
 /** \brief Max DFA states in a merged DFA. */
 static const size_t DFA_MERGE_MAX_STATES = 8000;
 
-/** \brief An LBR must have at least this many vertices to be protected from
- * merging with other graphs. */
-static const size_t LARGE_LBR_MIN_VERTICES = 32;
-
 /** \brief In block mode, merge two prefixes even if they don't have identical
  * literal sets if they have fewer than this many states and the merged graph
  * is also small. */
@@ -122,14 +118,6 @@ size_t small_rose_threshold(const CompileContext &cc) {
                         : SMALL_ROSE_THRESHOLD_BLOCK;
 }
 
-static
-bool isLargeLBR(const NGHolder &g, const Grey &grey) {
-    if (num_vertices(g) < LARGE_LBR_MIN_VERTICES) {
-        return false;
-    }
-    return isLBR(g, grey);
-}
-
 namespace {
 struct DupeLeafKey {
     explicit DupeLeafKey(const RoseVertexProps &litv)
@@ -1889,6 +1877,12 @@ void dedupeLeftfixesVariableLag(RoseBuildImpl &tbi) {
             continue;
         }
 
+        if (leftfix.graph()) {
+            /* we should not have merged yet */
+            assert(!is_triggered(*leftfix.graph())
+                   || onlyOneTop(*leftfix.graph()));
+        }
+
         roseGrouping[DedupeLeftKey(tbi, v)].insert(leftfix, v);
     }
 
@@ -2275,11 +2269,6 @@ void mergeSmallLeftfixes(RoseBuildImpl &tbi) {
             continue;
         }
 
-        // Don't merge cases that will become LBRs or haigs.
-        if (isLargeLBR(h, tbi.cc.grey)) {
-            continue;
-        }
-
         // Small roses only.
         if (num_vertices(h) > small_rose_threshold(tbi.cc)) {
             continue;
@@ -2497,11 +2486,6 @@ void mergeAcyclicSuffixes(RoseBuildImpl &tbi) {
             continue;
         }
 
-        if (isLargeLBR(*h, tbi.cc.grey)) {
-            DEBUG_PRINTF("not considering LBR suffix for merge\n");
-            continue;
-        }
-
         suffixes.insert(g[v].suffix, v);
     }
 
@@ -2564,11 +2548,6 @@ void mergeSmallSuffixes(RoseBuildImpl &tbi) {
             continue;
         }
 
-        if (isLargeLBR(*h, tbi.cc.grey)) {
-            DEBUG_PRINTF("not considering LBR suffix for merge\n");
-            continue;
-        }
-
         suffixes.insert(g[v].suffix, v);
     }
 
index d32f7e8fa8f61df06414f5ce43070fbd891a9220..2c585ae5f9778cc1b0c788eb5dffc349d296ee50 100644 (file)
@@ -101,8 +101,6 @@ protected:
         ASSERT_TRUE(g != nullptr);
         clearReports(*g);
 
-        ASSERT_TRUE(isLBR(*g, grey));
-
         rm.setProgramOffset(0, MATCH_REPORT);
 
         /* LBR triggered by dot */