Print this page
11972 resync smatch
@@ -29,10 +29,12 @@
static int get_absolute_rl_internal(struct expression *expr, struct range_list **rl, int *recurse_cnt);
static sval_t zero = {.type = &int_ctype, {.value = 0} };
static sval_t one = {.type = &int_ctype, {.value = 1} };
+static int fast_math_only;
+
struct range_list *rl_zero(void)
{
static struct range_list *zero_perm;
if (!zero_perm)
@@ -854,11 +856,11 @@
return get_rl_sval(cond_true, implied, recurse_cnt, res, res_sval);
if (implied_condition_false(expr->conditional))
return get_rl_sval(expr->cond_false, implied, recurse_cnt, res, res_sval);
/* this becomes a problem with deeply nested conditional statements */
- if (low_on_memory())
+ if (fast_math_only || low_on_memory())
return false;
type = get_type(expr);
__push_fake_cur_stree();
@@ -945,12 +947,10 @@
state = get_extra_state(expr);
if (!state || is_whole_rl(estate_rl(state))) {
state = get_real_absolute_state(expr);
if (state && state->data && !estate_is_whole(state))
return clone_rl(estate_rl(state));
- if (get_local_rl(expr, &rl) && !is_whole_rl(rl))
- return rl;
if (get_mtag_rl(expr, &rl))
return rl;
if (get_db_type_rl(expr, &rl) && !is_whole_rl(rl))
return rl;
return alloc_whole_rl(get_type(expr));
@@ -1006,12 +1006,10 @@
case RL_ABSOLUTE:
state = get_extra_state(expr);
if (!state) {
if (implied == RL_HARD)
return false;
- if (get_local_rl(expr, res))
- return true;
if (get_mtag_rl(expr, res))
return true;
if (get_db_type_rl(expr, res))
return true;
if (is_array(expr) && get_array_rl(expr, res))
@@ -1058,12 +1056,10 @@
} else if (estate_rl(abs_state)) {
*res = clone_rl(estate_rl(abs_state));
return true;
}
- if (get_local_rl(expr, res))
- return true;
if (get_mtag_rl(expr, res))
return true;
if (get_db_type_rl(expr, res))
return true;
if (is_array(expr) && get_array_rl(expr, res))
@@ -1514,10 +1510,20 @@
void clear_math_cache(void)
{
memset(cached_results, 0, sizeof(cached_results));
}
+void set_fast_math_only(void)
+{
+ fast_math_only++;
+}
+
+void clear_fast_math_only(void)
+{
+ fast_math_only--;
+}
+
/*
* Don't cache EXPR_VALUE because values are fast already.
*
*/
static bool get_value_literal(struct expression *expr, sval_t *res_sval)
@@ -1758,24 +1764,38 @@
sval_t tmp;
if (!expr)
return 0;
+ if (__inline_fn && get_param_num(expr) >= 0) {
+ if (get_implied_value(expr, &tmp) && tmp.value)
+ return 1;
+ return 0;
+ }
+
if (get_value(expr, &tmp) && tmp.value)
return 1;
return 0;
}
int known_condition_false(struct expression *expr)
{
+ sval_t tmp;
+
if (!expr)
return 0;
- if (is_zero(expr))
+ if (__inline_fn && get_param_num(expr) >= 0) {
+ if (get_implied_value(expr, &tmp) && tmp.value == 0)
return 1;
+ return 0;
+ }
+ if (expr_is_zero(expr))
+ return 1;
+
return 0;
}
int implied_condition_true(struct expression *expr)
{