Skip to content

Commit

Permalink
opt: remove unused labels
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos committed Jan 7, 2021
1 parent 50ef9fa commit dbcc7a5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions asm_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ void finalize_labels(struct label_state_t * ctx) {
exit(1);
}

vector_foreach(int32_t *, it2, it->references)
**it2 = n;
++n;
if(vector_size(it->references) == 1) {
*(it->references[0]) = -1;
} else {
vector_foreach(int32_t *, it2, it->references)
**it2 = n;
++n;
}

free(it->name - 1);
vector_free(it->references);
Expand Down Expand Up @@ -358,7 +362,10 @@ void asm_gen(FILE * output, vector(struct node_t) data, int optlevel) {
N;N;N;
break;
case LBL:
N;S;S;numeral(output, it->data1.value);
if(it->data1.value != -1) {
N;S;S;numeral(output, it->data1.value);
}

break;
case COPY:
S;T;S;numeral(output, it->data1.value);
Expand Down

0 comments on commit dbcc7a5

Please sign in to comment.