History

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.

Pavlas, Zdenek committed 10 years ago

Commit 71b62201 parent 0a402f61 file · +5 −1Browse files

Unified · Split

tccgen.c+5−1
@@ -4922,7 +4922,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 4921 unmodified lines
49224922 skip(')');
49234923 a = gvtst(1, 0);
49244924 b = 0;
4925+ ++local_scope;
49254926 block(&a, &b, case_sym, def_sym, case_reg, 0);
4927+ --local_scope;
49264928 if(!nocode_wanted)
49274929 gjmp_addr(d);
49284930 gsym(a);
@@ -5060,7 +5062,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 131 unmodified lines
50605062 vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
50615063 }
50625064 skip(';');
5063− rsym = gjmp(rsym); /* jmp */
5065+ /* jump unless last stmt in top-level block */
5066+ if (tok != '}' || local_scope != 1)
5067+ rsym = gjmp(rsym);
50645068 } else if (tok == TOK_BREAK) {
50655069 /* compute jump */
50665070 if (!bsym)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t