History

tccgen.c: cleanup debug support

from 3e731e3a78c0b1f9a299afee2665b11d3c4c25fe tccgen.c: - make 'struct default_debug' const - pass TCCState* as parameter to tcc_debug_xxx functions - always check tcc_state->do_debug before calling functions - factor out tcc_debug_extern_sym() - remove formats "%lld"/"%llu" (not reliable on windows) xxx-gen files: - set func_vt/var from caller

grischka committed 6 years ago

Commit 9c283491 parent 5bc17207 files · +85 −78Browse files

Unified · Split

7 files
  1. arm-gen.c +0 −2
  2. arm64-gen.c +0 −2
  3. c67-gen.c +0 −2
  4. i386-gen.c +0 −2
  5. riscv64-gen.c +1 −2
  6. tccgen.c +82 −63
  7. x86_64-gen.c +2 −5
arm-gen.c+0−2
@@ -1278,8 +1278,6 @@ void gfunc_prolog(Sym *func_sym) · 1277 unmodified lines
1278#endif1278#endif
1279 1279
1280 sym = func_type->ref;1280 sym = func_type->ref;
1281 func_vt = sym->type;
1282 func_var = (func_type->ref->f.func_type == FUNC_ELLIPSIS);
1283 1281
1284 n = nf = 0;1282 n = nf = 0;
1285 if ((func_vt.t & VT_BTYPE) == VT_STRUCT &&1283 if ((func_vt.t & VT_BTYPE) == VT_STRUCT &&
arm64-gen.c+0−2
@@ -1010,8 +1010,6 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 1009 unmodified lines
1010 CType **t;1010 CType **t;
1011 unsigned long *a;1011 unsigned long *a;
1012 1012
1013 // Why doesn't the caller (gen_function) set func_vt?
1014 func_vt = func_type->ref->type;
1015 func_vc = 144; // offset of where x8 is stored1013 func_vc = 144; // offset of where x8 is stored
1016 1014
1017 for (sym = func_type->ref; sym; sym = sym->next)1015 for (sym = func_type->ref; sym; sym = sym->next)
c67-gen.c+0−2
@@ -1952,8 +1952,6 @@ void gfunc_prolog(Sym *func_sym) · 1951 unmodified lines
1952 addr = 8;1952 addr = 8;
1953 /* if the function returns a structure, then add an1953 /* if the function returns a structure, then add an
1954 implicit pointer parameter */1954 implicit pointer parameter */
1955 func_vt = sym->type;
1956 func_var = (sym->f.func_type == FUNC_ELLIPSIS);
1957 if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {1955 if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
1958 func_vc = addr;1956 func_vc = addr;
1959 addr += 4;1957 addr += 4;
i386-gen.c+0−2
@@ -533,8 +533,6 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 532 unmodified lines
533 func_sub_sp_offset = ind;533 func_sub_sp_offset = ind;
534 /* if the function returns a structure, then add an534 /* if the function returns a structure, then add an
535 implicit pointer parameter */535 implicit pointer parameter */
536 func_vt = sym->type;
537 func_var = (sym->f.func_type == FUNC_ELLIPSIS);
538#ifdef TCC_TARGET_PE536#ifdef TCC_TARGET_PE
539 size = type_size(&func_vt,&align);537 size = type_size(&func_vt,&align);
540 if (((func_vt.t & VT_BTYPE) == VT_STRUCT)538 if (((func_vt.t & VT_BTYPE) == VT_STRUCT)
riscv64-gen.c+1−2
@@ -627,7 +627,6 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 626 unmodified lines
627 CType *type;627 CType *type;
628 628
629 sym = func_type->ref;629 sym = func_type->ref;
630 func_vt = sym->type;
631 loc = -16; // for ra and s0630 loc = -16; // for ra and s0
632 func_sub_sp_offset = ind;631 func_sub_sp_offset = ind;
633 ind += 5 * 4;632 ind += 5 * 4;
@@ -686,7 +685,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 52 unmodified lines
686 }685 }
687 func_va_list_ofs = addr;686 func_va_list_ofs = addr;
688 num_va_regs = 0;687 num_va_regs = 0;
689 if (func_type->ref->f.func_type == FUNC_ELLIPSIS) {688 if (func_var) {
690 for (; areg[0] < 8; areg[0]++) {689 for (; areg[0] < 8; areg[0]++) {
691 num_va_regs++;690 num_va_regs++;
692 ES(0x23, 3, 8, 10 + areg[0], -8 + num_va_regs * 8); // sd aX, loc(s0)691 ES(0x23, 3, 8, 10 + areg[0], -8 + num_va_regs * 8); // sd aX, loc(s0)
tccgen.c+82−63
@@ -122,7 +122,10 @@ static struct scope { · 121 unmodified lines
122 Sym *lstk, *llstk;122 Sym *lstk, *llstk;
123} *cur_scope, *loop_scope, *root_scope;123} *cur_scope, *loop_scope, *root_scope;
124 124
125static struct {125/********************************************************/
126/* stab debug support */
127
128static const struct {
126 int type;129 int type;
127 const char *name;130 const char *name;
128} default_debug[] = {131} default_debug[] = {
@@ -184,8 +187,6 @@ static struct debug_info { · 55 unmodified lines
184 struct debug_info *child, *next, *last, *parent;187 struct debug_info *child, *next, *last, *parent;
185} *debug_info, *debug_info_root;188} *debug_info, *debug_info_root;
186 189
187static CString debug_str;
188
189/********************************************************/190/********************************************************/
190#if 1191#if 1
191#define precedence_parser192#define precedence_parser
@@ -404,15 +405,19 @@ ST_FUNC void tcc_debug_start(TCCState *s1) · 212 unmodified lines
404 normalize_slashes(buf);405 normalize_slashes(buf);
405#endif406#endif
406 pstrcat(buf, sizeof(buf), "/");407 pstrcat(buf, sizeof(buf), "/");
407 debug_next_type = sizeof(default_debug) / sizeof(default_debug[0]);
408 put_stabs_r(s1, buf, N_SO, 0, 0,408 put_stabs_r(s1, buf, N_SO, 0, 0,
409 text_section->data_offset, text_section, section_sym);409 text_section->data_offset, text_section, section_sym);
410 put_stabs_r(s1, file->prev->filename, N_SO, 0, 0,410 put_stabs_r(s1, file->prev->filename, N_SO, 0, 0,
411 text_section->data_offset, text_section, section_sym);411 text_section->data_offset, text_section, section_sym);
412 for (i = 0; i < sizeof (default_debug) / sizeof (default_debug[0]); i++)412 for (i = 0; i < sizeof (default_debug) / sizeof (default_debug[0]); i++)
413 put_stabs(s1, default_debug[i].name, N_LSYM, 0, 0, 0);413 put_stabs(s1, default_debug[i].name, N_LSYM, 0, 0, 0);
414
414 new_file = last_line_num = 0;415 new_file = last_line_num = 0;
415 func_ind = -1;416 func_ind = -1;
417 debug_next_type = sizeof(default_debug) / sizeof(default_debug[0]);
418 debug_hash = NULL;
419 n_debug_hash = 0;
420
416 /* we're currently 'including' the <command line> */421 /* we're currently 'including' the <command line> */
417 tcc_debug_bincl(s1);422 tcc_debug_bincl(s1);
418 }423 }
@@ -424,7 +429,7 @@ ST_FUNC void tcc_debug_start(TCCState *s1) · 5 unmodified lines
424 SHN_ABS, file->filename);429 SHN_ABS, file->filename);
425}430}
426 431
427static void tcc_debug_stabs (const char *str, int type, unsigned long value,432static void tcc_debug_stabs (TCCState *s1, const char *str, int type, unsigned long value,
428 Section *sec, int sym_index)433 Section *sec, int sym_index)
429{434{
430 struct debug_sym *s;435 struct debug_sym *s;
@@ -442,15 +447,13 @@ static void tcc_debug_stabs (const char *str, int type, unsigned long value, · 11 unmodified lines
442 s->sym_index = sym_index;447 s->sym_index = sym_index;
443 }448 }
444 else if (sec)449 else if (sec)
445 put_stabs_r (tcc_state, str, type, 0, 0, value, sec, sym_index);450 put_stabs_r (s1, str, type, 0, 0, value, sec, sym_index);
446 else451 else
447 put_stabs (tcc_state, str, type, 0, 0, value);452 put_stabs (s1, str, type, 0, 0, value);
448}453}
449 454
450static void tcc_debug_stabn(int type, int value)455static void tcc_debug_stabn(int type, int value)
451{456{
452 if (!tcc_state->do_debug)
453 return;
454 if (type == N_LBRAC) {457 if (type == N_LBRAC) {
455 struct debug_info *info =458 struct debug_info *info =
456 (struct debug_info *) tcc_mallocz(sizeof (*info));459 (struct debug_info *) tcc_mallocz(sizeof (*info));
@@ -478,7 +481,7 @@ static void tcc_debug_stabn(int type, int value) · 21 unmodified lines
478 }481 }
479}482}
480 483
481static void tcc_get_debug_info(Sym *s, CString *result)484static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result)
482{485{
483 int type;486 int type;
484 int n = 0;487 int n = 0;
@@ -526,7 +529,7 @@ static void tcc_get_debug_info(Sym *s, CString *result) · 41 unmodified lines
526 cstr_printf (&str, "%s:",529 cstr_printf (&str, "%s:",
527 (t->v & ~SYM_FIELD) >= SYM_FIRST_ANOM530 (t->v & ~SYM_FIELD) >= SYM_FIRST_ANOM
528 ? "" : get_tok_str(t->v & ~SYM_FIELD, NULL));531 ? "" : get_tok_str(t->v & ~SYM_FIELD, NULL));
529 tcc_get_debug_info (t, &str);532 tcc_get_debug_info (s1, t, &str);
530 if (t->type.t & VT_BITFIELD) {533 if (t->type.t & VT_BITFIELD) {
531 pos = t->c * 8 + BIT_POS(t->type.t);534 pos = t->c * 8 + BIT_POS(t->type.t);
532 size = BIT_SIZE(t->type.t);535 size = BIT_SIZE(t->type.t);
@@ -538,7 +541,7 @@ static void tcc_get_debug_info(Sym *s, CString *result) · 5 unmodified lines
538 cstr_printf (&str, ",%d,%d;", pos, size);541 cstr_printf (&str, ",%d,%d;", pos, size);
539 }542 }
540 cstr_printf (&str, ";");543 cstr_printf (&str, ";");
541 tcc_debug_stabs(str.data, N_LSYM, 0, NULL, 0);544 tcc_debug_stabs(s1, str.data, N_LSYM, 0, NULL, 0);
542 cstr_free (&str);545 cstr_free (&str);
543 }546 }
544 }547 }
@@ -556,11 +559,11 @@ static void tcc_get_debug_info(Sym *s, CString *result) · 11 unmodified lines
556 cstr_printf (&str, "%s:",559 cstr_printf (&str, "%s:",
557 (t->v & ~SYM_FIELD) >= SYM_FIRST_ANOM560 (t->v & ~SYM_FIELD) >= SYM_FIRST_ANOM
558 ? "" : get_tok_str(t->v & ~SYM_FIELD, NULL));561 ? "" : get_tok_str(t->v & ~SYM_FIELD, NULL));
559 cstr_printf (&str, e->type.t & VT_UNSIGNED ? "%llu," : "%lld,",562 cstr_printf (&str, e->type.t & VT_UNSIGNED ? "%u," : "%d,",
560 t->enum_val);563 (int)t->enum_val);
561 }564 }
562 cstr_printf (&str, ";");565 cstr_printf (&str, ";");
563 tcc_debug_stabs(str.data, N_LSYM, 0, NULL, 0);566 tcc_debug_stabs(s1, str.data, N_LSYM, 0, NULL, 0);
564 cstr_free (&str);567 cstr_free (&str);
565 }568 }
566 else {569 else {
@@ -592,7 +595,7 @@ static void tcc_get_debug_info(Sym *s, CString *result) · 25 unmodified lines
592 cstr_printf (result, "%d", debug_type);595 cstr_printf (result, "%d", debug_type);
593}596}
594 597
595static void tcc_debug_finish (struct debug_info *cur)598static void tcc_debug_finish (TCCState *s1, struct debug_info *cur)
596{599{
597 while (cur) {600 while (cur) {
598 int i;601 int i;
@@ -602,33 +605,54 @@ static void tcc_debug_finish (struct debug_info *cur) · 3 unmodified lines
602 struct debug_sym *s = &cur->sym[i];605 struct debug_sym *s = &cur->sym[i];
603 606
604 if (s->sec)607 if (s->sec)
605 put_stabs_r(tcc_state, s->str, s->type, 0, 0, s->value,608 put_stabs_r(s1, s->str, s->type, 0, 0, s->value,
606 s->sec, s->sym_index);609 s->sec, s->sym_index);
607 else610 else
608 put_stabs(tcc_state, s->str, s->type, 0, 0, s->value);611 put_stabs(s1, s->str, s->type, 0, 0, s->value);
609 tcc_free (s->str);612 tcc_free (s->str);
610 }613 }
611 tcc_free (cur->sym);614 tcc_free (cur->sym);
612 put_stabn(tcc_state, N_LBRAC, 0, 0, cur->start);615 put_stabn(s1, N_LBRAC, 0, 0, cur->start);
613 tcc_debug_finish (cur->child);616 tcc_debug_finish (s1, cur->child);
614 put_stabn(tcc_state, N_RBRAC, 0, 0, cur->end);617 put_stabn(s1, N_RBRAC, 0, 0, cur->end);
615 tcc_free (cur);618 tcc_free (cur);
616 cur = next;619 cur = next;
617 }620 }
618}621}
619 622
620static void tcc_add_debug_info(int param, Sym *s, Sym *e)623static void tcc_add_debug_info(TCCState *s1, int param, Sym *s, Sym *e)
621{624{
622 if (!tcc_state->do_debug)625 CString debug_str;
623 return;626 cstr_new (&debug_str);
624 for (; s != e; s = s->prev) {627 for (; s != e; s = s->prev) {
625 if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL)628 if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL)
626 continue;629 continue;
627 cstr_reset (&debug_str);630 cstr_reset (&debug_str);
628 cstr_printf (&debug_str, "%s:%s", get_tok_str(s->v, NULL), param ? "p" : "");631 cstr_printf (&debug_str, "%s:%s", get_tok_str(s->v, NULL), param ? "p" : "");
629 tcc_get_debug_info(s, &debug_str);632 tcc_get_debug_info(s1, s, &debug_str);
630 tcc_debug_stabs(debug_str.data, param ? N_PSYM : N_LSYM, s->c, NULL, 0);633 tcc_debug_stabs(s1, debug_str.data, param ? N_PSYM : N_LSYM, s->c, NULL, 0);
631 }634 }
635 cstr_free (&debug_str);
636}
637
638static void tcc_debug_extern_sym(TCCState *s1, Sym *sym, int sh_num, int sym_bind)
639{
640 Section *s = s1->sections[sh_num];
641 CString str;
642
643 cstr_new (&str);
644 cstr_printf (&str, "%s:%c",
645 get_tok_str(sym->v, NULL),
646 sym_bind == STB_GLOBAL ? 'G' : local_scope ? 'V' : 'S'
647 );
648 tcc_get_debug_info(s1, sym, &str);
649 if (sym_bind == STB_GLOBAL)
650 tcc_debug_stabs(s1, str.data, N_GSYM, 0, NULL, 0);
651 else
652 tcc_debug_stabs(s1, str.data,
653 (sym->type.t & VT_STATIC) && data_section == s
654 ? N_STSYM : N_LCSYM, 0, s, sym->c);
655 cstr_free (&str);
632}656}
633 657
634/* put end of translation unit info */658/* put end of translation unit info */
@@ -639,8 +663,6 @@ ST_FUNC void tcc_debug_end(TCCState *s1) · 4 unmodified lines
639 put_stabs_r(s1, NULL, N_SO, 0, 0,663 put_stabs_r(s1, NULL, N_SO, 0, 0,
640 text_section->data_offset, text_section, section_sym);664 text_section->data_offset, text_section, section_sym);
641 tcc_free(debug_hash);665 tcc_free(debug_hash);
642 debug_hash = NULL;
643 n_debug_hash = 0;
644}666}
645 667
646static BufferedFile* put_new_file(TCCState *s1)668static BufferedFile* put_new_file(TCCState *s1)
@@ -677,14 +699,21 @@ ST_FUNC void tcc_debug_line(TCCState *s1) · 30 unmodified lines
677/* put function symbol */699/* put function symbol */
678ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym)700ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym)
679{701{
702 CString debug_str;
680 BufferedFile *f;703 BufferedFile *f;
681 if (!s1->do_debug || !(f = put_new_file(s1)))704 if (!s1->do_debug)
682 return;705 return;
706 debug_info_root = NULL;
707 debug_info = NULL;
683 tcc_debug_stabn(N_LBRAC, ind - func_ind);708 tcc_debug_stabn(N_LBRAC, ind - func_ind);
684 cstr_reset (&debug_str);709 if (!(f = put_new_file(s1)))
710 return;
711 cstr_new (&debug_str);
685 cstr_printf(&debug_str, "%s:%c", funcname, sym->type.t & VT_STATIC ? 'f' : 'F');712 cstr_printf(&debug_str, "%s:%c", funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
686 tcc_get_debug_info(sym->type.ref, &debug_str);713 tcc_get_debug_info(s1, sym->type.ref, &debug_str);
687 put_stabs_r(s1, debug_str.data, N_FUN, 0, f->line_num, 0, cur_text_section, sym->c);714 put_stabs_r(s1, debug_str.data, N_FUN, 0, f->line_num, 0, cur_text_section, sym->c);
715 cstr_free (&debug_str);
716
688 tcc_debug_line(s1);717 tcc_debug_line(s1);
689}718}
690 719
@@ -694,10 +723,7 @@ ST_FUNC void tcc_debug_funcend(TCCState *s1, int size) · 3 unmodified lines
694 if (!s1->do_debug)723 if (!s1->do_debug)
695 return;724 return;
696 tcc_debug_stabn(N_RBRAC, size);725 tcc_debug_stabn(N_RBRAC, size);
697 tcc_debug_finish (debug_info_root);726 tcc_debug_finish (s1, debug_info_root);
698 debug_info_root = NULL;
699 debug_info = NULL;
700 cstr_free (&debug_str);
701}727}
702 728
703/* put alternative filename */729/* put alternative filename */
@@ -926,25 +952,12 @@ ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, · 222 unmodified lines
926 name = get_tok_str(sym->asm_label, NULL);952 name = get_tok_str(sym->asm_label, NULL);
927 info = ELFW(ST_INFO)(sym_bind, sym_type);953 info = ELFW(ST_INFO)(sym_bind, sym_type);
928 sym->c = put_elf_sym(symtab_section, value, size, info, other, sh_num, name);954 sym->c = put_elf_sym(symtab_section, value, size, info, other, sh_num, name);
929 if (tcc_state->do_debug && sym_type != STT_FUNC && sym->v < SYM_FIRST_ANOM) {
930 CString str;
931 955
932 cstr_new (&str);956 if (tcc_state->do_debug
933 cstr_printf (&str, "%s:%c", get_tok_str(sym->v, NULL),957 && sym_type != STT_FUNC
934 debug_info ? 'V' : sym_bind == STB_GLOBAL ? 'G' : 'S');958 && sym->v < SYM_FIRST_ANOM)
935 tcc_get_debug_info(sym, &str);959 tcc_debug_extern_sym(tcc_state, sym, sh_num, sym_bind);
936 if (sym_bind == STB_GLOBAL)960
937 tcc_debug_stabs(str.data, N_GSYM, 0, NULL, 0);
938 else
939 tcc_debug_stabs(str.data,
940 (t & VT_STATIC) && data_section->sh_num == sh_num
941 ? N_STSYM : N_LCSYM, 0,
942 data_section->sh_num == sh_num ? data_section :
943 bss_section->sh_num == sh_num ? bss_section :
944 common_section->sh_num == sh_num ? common_section :
945 text_section, sym->c);
946 cstr_free (&str);
947 }
948 } else {961 } else {
949 esym = elfsym(sym);962 esym = elfsym(sym);
950 esym->st_value = value;963 esym->st_value = value;
@@ -1920,13 +1933,14 @@ static void add_local_bounds(Sym *s, Sym *e) · 969 unmodified lines
1920#endif1933#endif
1921 1934
1922/* Wrapper around sym_pop, that potentially also registers local bounds. */1935/* Wrapper around sym_pop, that potentially also registers local bounds. */
1923static void pop_local_syms(int param, Sym **ptop, Sym *b, int keep, int ellipsis)1936static void pop_local_syms(Sym **ptop, Sym *b, int keep, int ellipsis)
1924{1937{
1925#ifdef CONFIG_TCC_BCHECK1938#ifdef CONFIG_TCC_BCHECK
1926 if (!ellipsis && !keep && tcc_state->do_bounds_check)1939 if (tcc_state->do_bounds_check && !ellipsis && !keep)
1927 add_local_bounds(*ptop, b);1940 add_local_bounds(*ptop, b);
1928#endif1941#endif
1929 tcc_add_debug_info (param, *ptop, b);1942 if (tcc_state->do_debug)
1943 tcc_add_debug_info (tcc_state, !local_scope, *ptop, b);
1930 sym_pop(ptop, b, keep);1944 sym_pop(ptop, b, keep);
1931}1945}
1932 1946
@@ -6717,7 +6731,9 @@ void new_scope(struct scope *o) · 4784 unmodified lines
6717 o->llstk = local_label_stack;6731 o->llstk = local_label_stack;
6718 6732
6719 ++local_scope;6733 ++local_scope;
6720 tcc_debug_stabn(N_LBRAC, ind - func_ind);6734
6735 if (tcc_state->do_debug)
6736 tcc_debug_stabn(N_LBRAC, ind - func_ind);
6721}6737}
6722 6738
6723void prev_scope(struct scope *o, int is_expr)6739void prev_scope(struct scope *o, int is_expr)
@@ -6739,12 +6755,12 @@ void prev_scope(struct scope *o, int is_expr) · 15 unmodified lines
6739 tables, though. sym_pop will do that. */6755 tables, though. sym_pop will do that. */
6740 6756
6741 /* pop locally defined symbols */6757 /* pop locally defined symbols */
6742 pop_local_syms(0, &local_stack, o->lstk, is_expr, 0);6758 pop_local_syms(&local_stack, o->lstk, is_expr, 0);
6743
6744 tcc_debug_stabn(N_RBRAC, ind - func_ind);
6745
6746 cur_scope = o->prev;6759 cur_scope = o->prev;
6747 --local_scope;6760 --local_scope;
6761
6762 if (tcc_state->do_debug)
6763 tcc_debug_stabn(N_RBRAC, ind - func_ind);
6748}6764}
6749 6765
6750/* leave a scope via break/continue(/goto) */6766/* leave a scope via break/continue(/goto) */
@@ -7952,8 +7968,12 @@ static void gen_function(Sym *sym) · 1201 unmodified lines
7952 add_array (tcc_state, ".init_array", sym->c);7968 add_array (tcc_state, ".init_array", sym->c);
7953 if (sym->type.ref->f.func_dtor)7969 if (sym->type.ref->f.func_dtor)
7954 add_array (tcc_state, ".fini_array", sym->c);7970 add_array (tcc_state, ".fini_array", sym->c);
7971
7955 funcname = get_tok_str(sym->v, NULL);7972 funcname = get_tok_str(sym->v, NULL);
7956 func_ind = ind;7973 func_ind = ind;
7974 func_vt = sym->type.ref->type;
7975 func_var = sym->type.ref->f.func_type == FUNC_ELLIPSIS;
7976
7957 /* put debug symbol */7977 /* put debug symbol */
7958 tcc_debug_funcstart(tcc_state, sym);7978 tcc_debug_funcstart(tcc_state, sym);
7959 /* push a dummy symbol to enable local sym storage */7979 /* push a dummy symbol to enable local sym storage */
@@ -7967,8 +7987,7 @@ static void gen_function(Sym *sym) · 7 unmodified lines
7967 gsym(rsym);7987 gsym(rsym);
7968 nocode_wanted = 0;7988 nocode_wanted = 0;
7969 /* reset local stack */7989 /* reset local stack */
7970 pop_local_syms(1, &local_stack, NULL, 0,7990 pop_local_syms(&local_stack, NULL, 0, func_var);
7971 sym->type.ref->f.func_type == FUNC_ELLIPSIS);
7972 gfunc_epilog();7991 gfunc_epilog();
7973 cur_text_section->data_offset = ind;7992 cur_text_section->data_offset = ind;
7974 local_scope = 0;7993 local_scope = 0;
x86_64-gen.c+2−5
@@ -991,8 +991,6 @@ void gfunc_prolog(Sym *func_sym) · 990 unmodified lines
991 991
992 /* if the function returns a structure, then add an992 /* if the function returns a structure, then add an
993 implicit pointer parameter */993 implicit pointer parameter */
994 func_vt = sym->type;
995 func_var = (sym->f.func_type == FUNC_ELLIPSIS);
996 size = gfunc_arg_size(&func_vt);994 size = gfunc_arg_size(&func_vt);
997 if (!using_regs(size)) {995 if (!using_regs(size)) {
998 gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);996 gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
@@ -1032,7 +1030,7 @@ void gfunc_prolog(Sym *func_sym) · 33 unmodified lines
1032 }1030 }
1033 1031
1034 while (reg_param_index < REGN) {1032 while (reg_param_index < REGN) {
1035 if (func_type->ref->f.func_type == FUNC_ELLIPSIS) {1033 if (func_var) {
1036 gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);1034 gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
1037 addr += 8;1035 addr += 8;
1038 }1036 }
@@ -1491,7 +1489,7 @@ void gfunc_prolog(Sym *func_sym) · 452 unmodified lines
1491 func_sub_sp_offset = ind;1489 func_sub_sp_offset = ind;
1492 func_ret_sub = 0;1490 func_ret_sub = 0;
1493 1491
1494 if (sym->f.func_type == FUNC_ELLIPSIS) {1492 if (func_var) {
1495 int seen_reg_num, seen_sse_num, seen_stack_size;1493 int seen_reg_num, seen_sse_num, seen_stack_size;
1496 seen_reg_num = seen_sse_num = 0;1494 seen_reg_num = seen_sse_num = 0;
1497 /* frame pointer and return address */1495 /* frame pointer and return address */
@@ -1562,7 +1560,6 @@ void gfunc_prolog(Sym *func_sym) · 64 unmodified lines
1562 1560
1563 /* if the function returns a structure, then add an1561 /* if the function returns a structure, then add an
1564 implicit pointer parameter */1562 implicit pointer parameter */
1565 func_vt = sym->type;
1566 mode = classify_x86_64_arg(&func_vt, NULL, &size, &align, &reg_count);1563 mode = classify_x86_64_arg(&func_vt, NULL, &size, &align, &reg_count);
1567 if (mode == x86_64_mode_memory) {1564 if (mode == x86_64_mode_memory) {
1568 push_arg_reg(reg_param_index);1565 push_arg_reg(reg_param_index);

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