mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
remove !LBR constraints from merge passes
we have either converted candidates to castles already or we have converted them back in the hope of merging them with other holders
This commit is contained in:
parent
b259283d6b
commit
2a492273b5
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user