Print this page
new smatch

*** 29,38 **** --- 29,40 ---- 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,864 **** 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()) return false; type = get_type(expr); __push_fake_cur_stree(); --- 856,866 ---- 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 (fast_math_only || low_on_memory()) return false; type = get_type(expr); __push_fake_cur_stree();
*** 945,956 **** 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)); --- 947,956 ----
*** 1006,1017 **** 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)) --- 1006,1015 ----
*** 1058,1069 **** } 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)) --- 1056,1065 ----
*** 1514,1523 **** --- 1510,1529 ---- 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,1781 **** sval_t tmp; if (!expr) return 0; if (get_value(expr, &tmp) && tmp.value) return 1; return 0; } int known_condition_false(struct expression *expr) { if (!expr) return 0; ! if (is_zero(expr)) return 1; return 0; } int implied_condition_true(struct expression *expr) { --- 1764,1801 ---- 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 (__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) {