mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
tccgen: return: avoid jmp to retsym if possible
When 'return' is the last statement of the top-level block (very common and often recommended case) jump is not needed.
This commit is contained in:
parent
0a402f6e91
commit
71b6220963
6
tccgen.c
6
tccgen.c
@ -4922,7 +4922,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
|
|||||||
skip(')');
|
skip(')');
|
||||||
a = gvtst(1, 0);
|
a = gvtst(1, 0);
|
||||||
b = 0;
|
b = 0;
|
||||||
|
++local_scope;
|
||||||
block(&a, &b, case_sym, def_sym, case_reg, 0);
|
block(&a, &b, case_sym, def_sym, case_reg, 0);
|
||||||
|
--local_scope;
|
||||||
if(!nocode_wanted)
|
if(!nocode_wanted)
|
||||||
gjmp_addr(d);
|
gjmp_addr(d);
|
||||||
gsym(a);
|
gsym(a);
|
||||||
@ -5060,7 +5062,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
|
|||||||
vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
|
vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
|
||||||
}
|
}
|
||||||
skip(';');
|
skip(';');
|
||||||
rsym = gjmp(rsym); /* jmp */
|
/* jump unless last stmt in top-level block */
|
||||||
|
if (tok != '}' || local_scope != 1)
|
||||||
|
rsym = gjmp(rsym);
|
||||||
} else if (tok == TOK_BREAK) {
|
} else if (tok == TOK_BREAK) {
|
||||||
/* compute jump */
|
/* compute jump */
|
||||||
if (!bsym)
|
if (!bsym)
|
||||||
|
Loading…
Reference in New Issue
Block a user