History

sym_push2 optimized for the local_stack case.

A constant expression removed from the loop. If subroutine have 50000+ local variables, then currently compilation of such code takes obly 15 sec. Was 2 min. gcc-4.1.2 compiles such code in 7 sec. pcc -- 3.44 min. A test generator: #include <stdio.h> int main() { puts("#include <stdio.h>"); puts("int main()"); puts("{"); for (int i = 0; i < 50000; ++i) printf("int X%d = 1;\n", i); for (int i = 0; i < 50000; ++i) puts("scanf(\"%d\", &X0);"); puts("}"); return 0; }

seyko committed 10 years ago

Commit 07d896c1 parent 2bfedb11 file · +3 −3Browse files

Unified · Split

tccgen.c+3−3
@@ -167,9 +167,9 @@ ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c) · 166 unmodified lines
167{167{
168 Sym *s;168 Sym *s;
169 if (!tcc_state->no_type_redef_check) {169 if (!tcc_state->no_type_redef_check) {
170 if (ps == &local_stack) {170 if ((ps == &local_stack) && !(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) {
171 for (s = *ps; s && s != scope_stack_bottom; s = s->prev)171 for (s = *ps; s != scope_stack_bottom; s = s->prev)
172 if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM && s->v == v)172 if (s->v == v)
173 tcc_error("incompatible types for redefinition of '%s'",173 tcc_error("incompatible types for redefinition of '%s'",
174 get_tok_str(v, NULL));174 get_tok_str(v, NULL));
175 }175 }

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