optimize: do not merge unsupported statement expressions
Pablo Neira Ayuso
maintainerPATCH v2 1/1 optimize: do not merge unsupported statement expressions
Only value, range, prefix, set and list are supported at this stage.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v2: check for EXPR_SYMBOL instead of EXPR_VALUE, evaluation phase did not
happen yet.
src/optimize.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
src/optimize.c +20 -0
@@ -91,6 +91,22 @@ static bool __expr_cmp(const struct expr *expr_a, const struct expr *expr_b)return true; } +static bool stmt_expr_supported (const struct expr *expr) +{ +switch (expr->right->etype) { +case EXPR_SYMBOL : +case EXPR_RANGE : +case EXPR_PREFIX : +case EXPR_SET : +case EXPR_LIST : +return true; +default : +break ; + } + +return false; +} +static bool __stmt_type_eq (const struct stmt *stmt_a,const struct stmt *stmt_b) {struct expr *expr_a, *expr_b;
@@ -103,6 +119,10 @@ static bool __stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b) expr_a = stmt_a->expr; expr_b = stmt_b->expr; +if (!stmt_expr_supported (expr_a) || + !stmt_expr_supported (expr_b)) +return false; +return __expr_cmp (expr_a->left, expr_b->left);case STMT_COUNTER :case STMT_NOTRACK :
Signature · 1 line
2.30.2