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