diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-16 17:35:24 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-16 17:35:24 -0400 |
commit | e327fd94f3be22d9129b252102e73b5bfb3b3276 (patch) | |
tree | 4e2f178bd467fda1ffce236e40bb112db94dd133 /offsets.c | |
parent | 15e96a558baf007966f80d565f50f18cd2ecd75d (diff) |
Remove redundant loads
Do breadth first of the entire program when marking variables used/unused
Don't optimize away unused function parameters
Diffstat (limited to 'offsets.c')
-rw-r--r-- | offsets.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -59,18 +59,21 @@ assign_offsets (symbol_table_t *symbols, int offset, int *max) { ast_definition_t *definition = definitions->pdata[i]; - if (definition->common.type == AST_VARIABLE_DEFINITION && - definition->variable.used) + if (definition->common.type == AST_VARIABLE_DEFINITION) { - int size = ast_type_spec_get_size (definition->variable.type_spec); - - /* Align to size */ - if (offset % size != 0) - offset += (size - offset % size); - - definition->variable.offset = offset; - - offset += size; + ast_variable_definition_t *variable = &definition->variable; + + if (variable->used || variable->parameter) + { + int size = ast_type_spec_get_size (variable->type_spec); + + /* Align to size */ + if (offset % size != 0) + offset += (size - offset % size); + + variable->offset = offset; + offset += size; + } } } @@ -145,8 +148,7 @@ do_offsets (ast_t *ast, int offset, int *max) gboolean offsets (ast_t *ast) { - node_breadth_first (ast->program.enter, mark_used, NULL); - + program_breadth_first (&ast->program, mark_used, NULL); do_offsets (ast, 0, NULL); /* The offsets pass can never fail */ |