mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
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; }
This commit is contained in:
parent
2bfedb1867
commit
07d896c8e5
6
tccgen.c
6
tccgen.c
@ -167,9 +167,9 @@ ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c)
|
||||
{
|
||||
Sym *s;
|
||||
if (!tcc_state->no_type_redef_check) {
|
||||
if (ps == &local_stack) {
|
||||
for (s = *ps; s && s != scope_stack_bottom; s = s->prev)
|
||||
if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM && s->v == v)
|
||||
if ((ps == &local_stack) && !(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) {
|
||||
for (s = *ps; s != scope_stack_bottom; s = s->prev)
|
||||
if (s->v == v)
|
||||
tcc_error("incompatible types for redefinition of '%s'",
|
||||
get_tok_str(v, NULL));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user