Use flow_analyze_statement to get statement operands.

Getting the operands directly from the statement was missing the
destination operand of movep when movep's op_c was a constant pointer and
thus the flowvar wasn't being counted/created early enough. This led to a
segfault in the set code when attempting to add -1 to the set.
This commit is contained in:
Bill Currie 2012-12-20 19:02:55 +09:00
parent 5ec4598fce
commit 4d587eaa25

View file

@ -319,8 +319,9 @@ static void
flow_build_vars (function_t *func) flow_build_vars (function_t *func)
{ {
statement_t *s; statement_t *s;
operand_t *operands[4];
int num_vars = 0; int num_vars = 0;
int i; int i, j;
set_t *stuse; set_t *stuse;
set_t *stdef; set_t *stdef;
set_iter_t *var_i; set_iter_t *var_i;
@ -335,9 +336,9 @@ flow_build_vars (function_t *func)
// variables // variables
for (i = 0; i < func->num_statements; i++) { for (i = 0; i < func->num_statements; i++) {
s = func->statements[i]; s = func->statements[i];
num_vars += count_operand (s->opa); flow_analyze_statement (s, 0, 0, 0, operands);
num_vars += count_operand (s->opb); for (j = 0; j < 4; j++)
num_vars += count_operand (s->opc); num_vars += count_operand (operands[j]);
} }
if (!num_vars) if (!num_vars)
return; return;
@ -355,9 +356,9 @@ flow_build_vars (function_t *func)
// variables // variables
for (i = 0; i < func->num_statements; i++) { for (i = 0; i < func->num_statements; i++) {
s = func->statements[i]; s = func->statements[i];
add_operand (func, s->opa); flow_analyze_statement (s, 0, 0, 0, operands);
add_operand (func, s->opb); for (j = 0; j < 4; j++)
add_operand (func, s->opc); add_operand (func, operands[j]);
flow_analyze_statement (s, stuse, stdef, 0, 0); flow_analyze_statement (s, stuse, stdef, 0, 0);
for (var_i = set_first (stdef); var_i; var_i = set_next (var_i)) { for (var_i = set_first (stdef); var_i; var_i = set_next (var_i)) {