Commit 64fe0a13 authored by Matthias Braun's avatar Matthias Braun
Browse files

fix a bunch of warnings reported by clang analyzer

parent 5c2b8118
......@@ -173,7 +173,7 @@ void gs_matrix_set(gs_matrix_t *m, int row, int col, double val)
cols = the_row->cols;
min = 0;
max = the_row->n_cols;
c = (max+min)/2;
c = max/2;
while (min < max) {
int idx = cols[c].col_idx;
if (idx < col)
......
......@@ -420,9 +420,8 @@ static void amd64_get_call_abi(ir_type *method_type, be_abi_call_t *abi)
tp = get_method_res_type(method_type, 0);
mode = get_type_mode(tp);
/* FIXME: No floating point yet */
/* be_abi_call_res_reg(abi, 0,
mode_is_float(mode) ? &amd64_fp_regs[REG_F0] : &amd64_registers[REG_R0], ABI_CONTEXT_BOTH); */
if (mode_is_float(mode))
panic("float not supported yet");
be_abi_call_res_reg(abi, 0,
&amd64_registers[REG_RAX], ABI_CONTEXT_BOTH);
......
......@@ -595,7 +595,6 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
for (i = 0; i < n_res; ++i) {
ir_node *proj = res_projs[i];
be_abi_call_arg_t *arg = get_call_arg(call, 1, i, 0);
long pn = i + pn_be_Call_first_res;
/* returns values on stack not supported yet */
assert(arg->in_reg);
......@@ -605,7 +604,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
unspeakable Proj_T from the Call. Therefore, all real argument
Proj numbers must be increased by pn_be_Call_first_res
*/
pn = i + pn_be_Call_first_res;
long pn = i + pn_be_Call_first_res;
if (proj == NULL) {
ir_type *res_type = get_method_res_type(call_tp, i);
......
......@@ -47,11 +47,10 @@ be_insn_t *be_scan_insn(const be_insn_env_t *env, ir_node *irn)
{
struct obstack *obst = env->obst;
be_operand_t o;
be_insn_t *insn;
int i, n;
int pre_colored = 0;
insn = OALLOCZ(obst, be_insn_t);
be_insn_t *insn = OALLOCZ(obst, be_insn_t);
insn->irn = irn;
insn->next_insn = sched_next(irn);
......
......@@ -404,7 +404,7 @@ static void congruence_def(ir_nodeset_t *live_nodes, const ir_node *node)
if (interferes)
continue;
node_idx = uf_union(congruence_classes, node_idx, op_idx);
uf_union(congruence_classes, node_idx, op_idx);
DB((dbg, LEVEL_3, "Merge %+F and %+F congruence classes\n",
node, op));
/* one should_be_same is enough... */
......
......@@ -248,11 +248,11 @@ static sched_timestep_t latency(trace_env_t *env, ir_node *pred, int pred_cycle,
if (is_Proj(curr))
return 0;
#if 0
/* predecessors Proj's must be skipped */
if (is_Proj(pred))
pred = get_Proj_pred(pred);
#if 0
if (env->selector->latency)
return env->selector->latency(env->selector_env, pred, pred_cycle, curr, curr_cycle);
#endif
......
......@@ -169,13 +169,11 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
* Register allocation is copied from the former phi
* arguments to the projs (new phi arguments).
*/
insert_after = perm;
foreach_set(arg_set, perm_proj_t, pp) {
ir_node *proj = new_r_Proj(perm, get_irn_mode(pp->arg), pp->pos);
pp->proj = proj;
assert(arch_get_irn_register(pp->arg));
arch_set_irn_register(proj, arch_get_irn_register(pp->arg));
insert_after = proj;
DBG((dbg, LEVEL_2, "Copy register assignment %s from %+F to %+F\n", arch_get_irn_register(pp->arg)->name, pp->arg, pp->proj));
}
......
......@@ -410,7 +410,7 @@ static void collect_memperm(be_verify_spillslots_env_t *env, ir_node *node, ir_n
}
spill.ent = spillent;
res = set_insert(spill_t, env->spills, &spill, sizeof(spill), hash);
(void)set_insert(spill_t, env->spills, &spill, sizeof(spill), hash);
int arity = be_get_MemPerm_entity_arity(memperm);
for (int i = 0; i < arity; ++i) {
......@@ -434,7 +434,7 @@ static void collect_memphi(be_verify_spillslots_env_t *env, ir_node *node, ir_no
}
spill.ent = ent;
res = set_insert(spill_t, env->spills, &spill, sizeof(spill), hash);
(void)set_insert(spill_t, env->spills, &spill, sizeof(spill), hash);
/* is 1 of the arguments a spill? */
int arity = get_irn_arity(node);
......@@ -495,6 +495,7 @@ static void check_spillslot_interference(be_verify_spillslots_env_t *env)
foreach_set(env->spills, spill_t, spill) {
spills[s++] = spill;
}
assert(s == spillcount);
for (int i = 0; i < spillcount; ++i) {
spill_t *sp1 = spills[i];
......
......@@ -1245,7 +1245,6 @@ static void introduce_prolog_epilog(ir_graph *irg)
ir_node *incsp;
curr_sp = new_r_Proj(push, mode_gp, pn_ia32_Push_stack);
mem = new_r_Proj(push, mode_M, pn_ia32_Push_M);
arch_set_irn_register(curr_sp, sp);
sched_add_after(start, push);
......@@ -1676,7 +1675,6 @@ static ir_node *ia32_create_trampoline_fkt(ir_node *block, ir_node *mem, ir_node
p = new_r_Add(block, p, one, mode);
st = new_r_Store(block, mem, p, callee, cons_none);
mem = new_r_Proj(st, mode_M, pn_Store_M);
p = new_r_Add(block, p, four, mode);
return mem;
}
......
......@@ -1039,7 +1039,6 @@ static int is_am_minus_one(const ir_node *node)
*/
static void peephole_ia32_Lea(ir_node *node)
{
ir_graph *irg;
ir_node *base;
ir_node *index;
const arch_register_t *base_reg;
......@@ -1052,8 +1051,6 @@ static void peephole_ia32_Lea(ir_node *node)
dbg_info *dbgi;
ir_node *block;
ir_node *res;
ir_node *noreg;
ir_node *nomem;
assert(is_ia32_Lea(node));
......@@ -1165,9 +1162,9 @@ make_add_immediate:
make_add:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
irg = get_irn_irg(node);
noreg = ia32_new_NoReg_gp(irg);
nomem = get_irg_no_mem(irg);
ir_graph *irg = get_irn_irg(node);
ir_node *noreg = ia32_new_NoReg_gp(irg);
ir_node *nomem = get_irg_no_mem(irg);
res = new_bd_ia32_Add(dbgi, block, noreg, noreg, nomem, op1, op2);
arch_set_irn_register(res, out_reg);
set_ia32_commutative(res);
......@@ -1176,9 +1173,6 @@ make_add:
make_shl:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
irg = get_irn_irg(node);
noreg = ia32_new_NoReg_gp(irg);
nomem = get_irg_no_mem(irg);
res = new_bd_ia32_Shl(dbgi, block, op1, op2);
arch_set_irn_register(res, out_reg);
goto exchange;
......
......@@ -1050,7 +1050,6 @@ static int sim_binop(x87_state *state, ir_node *n, const exchange_tmpl *tmpl)
*/
static int sim_unop(x87_state *state, ir_node *n, ir_op *op)
{
int op1_idx;
x87_simulator *sim = state->sim;
const arch_register_t *op1 = x87_get_irn_register(get_irn_n(n, 0));
const arch_register_t *out = x87_get_irn_register(n);
......@@ -1060,18 +1059,16 @@ static int sim_unop(x87_state *state, ir_node *n, ir_op *op)
DB((dbg, LEVEL_1, ">>> %+F -> %s\n", n, out->name));
DEBUG_ONLY(vfp_dump_live(live);)
op1_idx = x87_on_stack(state, arch_register_get_index(op1));
int op1_idx = x87_on_stack(state, arch_register_get_index(op1));
if (is_vfp_live(arch_register_get_index(op1), live)) {
/* push the operand here */
x87_create_fpush(state, n, op1_idx, 0);
op1_idx = 0;
}
else {
} else {
/* operand is dead, bring it to tos */
if (op1_idx != 0) {
x87_create_fxch(state, n, op1_idx);
op1_idx = 0;
}
}
......
......@@ -205,6 +205,8 @@ int ir_timer_enter_high_priority(void)
if (!std_sched_param_init) {
res = sched_getparam(pid, &std_sched_param);
if (res != 0)
return res;
std_sched_param_init = 1;
}
......
......@@ -281,14 +281,10 @@ static unsigned char *complement_condensed(mul_env *env, unsigned char *R, int r
*/
static ir_tarval *condensed_to_value(mul_env *env, unsigned char *R, int r)
{
ir_tarval *res, *tv;
int i, j;
j = 0;
tv = get_mode_one(env->mode);
res = NULL;
for (i = 0; i < r; ++i) {
j = R[i];
ir_tarval *tv = get_mode_one(env->mode);
ir_tarval *res = NULL;
for (int i = 0; i < r; ++i) {
int j = R[i];
if (j) {
ir_tarval *t = new_tarval_from_long(j, mode_Iu);
tv = tarval_shl(tv, t);
......
......@@ -229,7 +229,7 @@ static int firm_emit(lc_appendable_t *app,
}
if (occ->flag_plus)
strncat(buf, add, sizeof(buf)-1);
strncat(buf, add, sizeof(buf)-strlen(buf)-1);
return lc_arg_append(app, occ, buf, strlen(buf));
#undef A
......
......@@ -362,7 +362,7 @@ void mature_immBlock(ir_node *block)
We can call optimize_in_place_2(), as global cse has no effect on blocks.
*/
irn_verify_irg(block, irg);
block = optimize_in_place_2(block);
optimize_in_place_2(block);
}
ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value)
......
......@@ -2195,7 +2195,6 @@ static void dump_loops_standalone(FILE *F, ir_loop *loop)
(unsigned long) first,
(unsigned long) first,
(unsigned long) i-1);
loop_node_started = false;
}
}
......
......@@ -790,33 +790,26 @@ static void count_user(ir_node *irn, void *env)
*/
static void verify_edge_counter(ir_node *irn, void *env)
{
build_walker *w = (build_walker*)env;
bitset_t *bs;
int list_cnt;
int ref_cnt;
int edge_cnt;
const struct list_head *head;
const struct list_head *pos;
ir_graph *irg;
build_walker *w = (build_walker*)env;
if (IGNORE_NODE(irn))
return;
bs = (bitset_t*)get_irn_link(irn);
list_cnt = 0;
ref_cnt = 0;
edge_cnt = get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
head = &get_irn_edge_info(irn, EDGE_KIND_NORMAL)->outs_head;
bitset_t *bs = (bitset_t*)get_irn_link(irn);
int list_cnt = 0;
int edge_cnt = get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
const struct list_head *head
= &get_irn_edge_info(irn, EDGE_KIND_NORMAL)->outs_head;
/* We can iterate safely here, list heads have already been verified. */
const struct list_head *pos;
list_for_each(pos, head) {
++list_cnt;
}
/* check all nodes that reference us and count edges that point number
* of ins that actually point to us */
irg = get_irn_irg(irn);
ref_cnt = 0;
ir_graph *irg = get_irn_irg(irn);
int ref_cnt = 0;
bitset_foreach(bs, idx) {
int i, arity;
ir_node *src = get_idx_irn(irg, idx);
......
......@@ -1511,44 +1511,40 @@ static ir_tarval *do_eval(eval_func eval, ir_tarval *a, ir_tarval *b, ir_mode *m
*/
static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, eval_func eval, ir_mode *mode, int left)
{
ir_tarval *tv;
void **res;
ir_node *pred;
ir_graph *irg;
int i, n = get_irn_arity(phi);
NEW_ARR_A(void *, res, n);
int n = get_irn_arity(phi);
ir_tarval **tvs = ALLOCAN(ir_tarval*, n);
if (left) {
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
tv = get_Const_tarval(pred);
tv = do_eval(eval, other, tv, mode);
for (int i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(phi, i);
ir_tarval *tv = get_Const_tarval(pred);
tv = do_eval(eval, other, tv, mode);
if (tv == tarval_bad) {
/* folding failed, bad */
return NULL;
}
res[i] = tv;
tvs[i] = tv;
}
} else {
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
tv = get_Const_tarval(pred);
tv = do_eval(eval, tv, other, mode);
for (int i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(phi, i);
ir_tarval *tv = get_Const_tarval(pred);
tv = do_eval(eval, tv, other, mode);
if (tv == tarval_bad) {
/* folding failed, bad */
return 0;
}
res[i] = tv;
tvs[i] = tv;
}
}
irg = get_irn_irg(phi);
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
res[i] = new_r_Const(irg, (ir_tarval*)res[i]);
ir_graph *irg = get_irn_irg(phi);
ir_node **res = ALLOCAN(ir_node*, n);
for (int i = 0; i < n; ++i) {
res[i] = new_r_Const(irg, tvs[i]);
}
return new_r_Phi(get_nodes_block(phi), n, (ir_node **)res, mode);
ir_node *block = get_nodes_block(phi);
return new_r_Phi(block, n, res, mode);
}
/**
......@@ -1563,37 +1559,31 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, eval_func eva
*/
static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, eval_func eval, ir_mode *mode)
{
ir_tarval *tv_l, *tv_r, *tv;
void **res;
ir_node *pred;
ir_graph *irg;
int i, n;
if (get_nodes_block(a) != get_nodes_block(b))
return NULL;
n = get_irn_arity(a);
NEW_ARR_A(void *, res, n);
for (i = 0; i < n; ++i) {
pred = get_irn_n(a, i);
tv_l = get_Const_tarval(pred);
pred = get_irn_n(b, i);
tv_r = get_Const_tarval(pred);
tv = do_eval(eval, tv_l, tv_r, mode);
int n = get_irn_arity(a);
ir_tarval **tvs = ALLOCAN(ir_tarval*, n);
for (int i = 0; i < n; ++i) {
ir_node *pred_a = get_irn_n(a, i);
ir_tarval *tv_l = get_Const_tarval(pred_a);
ir_node *pred_b = get_irn_n(b, i);
ir_tarval *tv_r = get_Const_tarval(pred_b);
ir_tarval *tv = do_eval(eval, tv_l, tv_r, mode);
if (tv == tarval_bad) {
/* folding failed, bad */
return NULL;
}
res[i] = tv;
tvs[i] = tv;
}
irg = get_irn_irg(a);
for (i = 0; i < n; ++i) {
pred = get_irn_n(a, i);
res[i] = new_r_Const(irg, (ir_tarval*)res[i]);
ir_graph *irg = get_irn_irg(a);
ir_node **res = ALLOCAN(ir_node*, n);
for (int i = 0; i < n; ++i) {
res[i] = new_r_Const(irg, tvs[i]);
}
return new_r_Phi(get_nodes_block(a), n, (ir_node **)res, mode);
ir_node *block = get_nodes_block(a);
return new_r_Phi(block, n, res, mode);
}
/**
......@@ -1606,32 +1596,27 @@ static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, eval_func eval, ir
*/
static ir_node *apply_unop_on_phi(ir_node *phi, ir_tarval *(*eval)(ir_tarval *))
{
ir_tarval *tv;
void **res;
ir_node *pred;
ir_mode *mode;
ir_graph *irg;
int i, n = get_irn_arity(phi);
NEW_ARR_A(void *, res, n);
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
tv = get_Const_tarval(pred);
tv = eval(tv);
int n = get_irn_arity(phi);
ir_tarval **tvs = ALLOCAN(ir_tarval*, n);
for (int i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(phi, i);
ir_tarval *tv = get_Const_tarval(pred);
tv = eval(tv);
if (tv == tarval_bad) {
/* folding failed, bad */
return 0;
}
res[i] = tv;
tvs[i] = tv;
}
mode = get_irn_mode(phi);
irg = get_irn_irg(phi);
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
res[i] = new_r_Const(irg, (ir_tarval*)res[i]);
ir_graph *irg = get_irn_irg(phi);
ir_node **res = ALLOCAN(ir_node*, n);
for (int i = 0; i < n; ++i) {
res[i] = new_r_Const(irg, tvs[i]);
}
return new_r_Phi(get_nodes_block(phi), n, (ir_node **)res, mode);
ir_node *block = get_nodes_block(phi);
ir_mode *mode = get_irn_mode(phi);
return new_r_Phi(block, n, res, mode);
}
/**
......@@ -1643,30 +1628,26 @@ static ir_node *apply_unop_on_phi(ir_node *phi, ir_tarval *(*eval)(ir_tarval *))
*/
static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode)
{
ir_tarval *tv;
void **res;
ir_node *pred;
ir_graph *irg;
int i, n = get_irn_arity(phi);
NEW_ARR_A(void *, res, n);
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
tv = get_Const_tarval(pred);
tv = tarval_convert_to(tv, mode);
int n = get_irn_arity(phi);
ir_tarval **tvs = ALLOCAN(ir_tarval*, n);
for (int i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(phi, i);
ir_tarval *tv = get_Const_tarval(pred);
tv = tarval_convert_to(tv, mode);
if (tv == tarval_bad) {
/* folding failed, bad */
return 0;
}
res[i] = tv;
tvs[i] = tv;
}
irg = get_irn_irg(phi);
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
res[i] = new_r_Const(irg, (ir_tarval*)res[i]);
ir_graph *irg = get_irn_irg(phi);
ir_node **res = ALLOCAN(ir_node*, n);
for (int i = 0; i < n; ++i) {
res[i] = new_r_Const(irg, tvs[i]);
}
return new_r_Phi(get_nodes_block(phi), n, (ir_node **)res, mode);
ir_node *block = get_nodes_block(phi);
return new_r_Phi(block, n, res, mode);
}
/**
......
......@@ -125,7 +125,7 @@ void add_edge_costs(pbqp_t *pbqp, unsigned src_index, unsigned tgt_index,
}
if (edge == NULL) {
edge = alloc_edge(pbqp, src_index, tgt_index, costs);
alloc_edge(pbqp, src_index, tgt_index, costs);
} else {
pbqp_matrix_add(edge->costs, costs);
}
......
......@@ -699,14 +699,14 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *root,
{
const lc_opt_entry_t *grp = root;
size_t n = strlen(arg);
size_t n_prefix = opt_prefix ? strlen(opt_prefix) : 0;
size_t n_prefix = opt_prefix != NULL ? strlen(opt_prefix) : 0;
int error = 0;
int ret = 0;
lc_opt_err_info_t err;
const char *end, *eqsign;
if (n >= n_prefix && strncmp(opt_prefix, arg, n_prefix) == 0) {
if (n >= n_prefix && (n_prefix == 0 || strncmp(opt_prefix, arg, n_prefix) == 0)) {
arg = arg + n_prefix;
/* find the next delimiter (the -) and extract the string up to
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment