diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-24 16:50:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 16:50:14 +0000 |
commit | d3cf195ab46d7effe806990aa6b7a409bf8e46df (patch) | |
tree | eb33d22a749417ad62a3fc87c2dc8cfb3452632a /gcc/ctfc.cc | |
parent | 825a44b40ce6cfa76470e53d0746b1e64b99ee5b (diff) | |
parent | 2e77960b14527ff216fa188479de9142fbb9d34c (diff) | |
download | gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.zip gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.tar.gz gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.tar.bz2 |
Merge #1498
1498: Merge from GCC upstream r=philberty a=philberty
Lets see if it builds.
Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org>
Co-authored-by: Dimitrije Milošević <dimitrije.milosevic@syrmia.com>
Co-authored-by: Aldy Hernandez <aldyh@redhat.com>
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Roger Sayle <roger@nextmovesoftware.com>
Co-authored-by: Sam Feifer <sfeifer@redhat.com>
Co-authored-by: Andrew Stubbs <ams@codesourcery.com>
Co-authored-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
Co-authored-by: Immad Mir <mirimmad@outlook.com>
Diffstat (limited to 'gcc/ctfc.cc')
-rw-r--r-- | gcc/ctfc.cc | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/gcc/ctfc.cc b/gcc/ctfc.cc index 6fe44d2..9773358 100644 --- a/gcc/ctfc.cc +++ b/gcc/ctfc.cc @@ -179,6 +179,40 @@ ctf_dvd_lookup (const ctf_container_ref ctfc, dw_die_ref die) return NULL; } +/* Insert a dummy CTF variable into the list of variables to be ignored. */ + +static void +ctf_dvd_ignore_insert (ctf_container_ref ctfc, ctf_dvdef_ref dvd) +{ + bool existed = false; + ctf_dvdef_ref entry = dvd; + + ctf_dvdef_ref * item = ctfc->ctfc_ignore_vars->find_slot (entry, INSERT); + if (*item == NULL) + *item = dvd; + else + existed = true; + /* Duplicate variable records not expected to be inserted. */ + gcc_assert (!existed); +} + +/* Lookup the dummy CTF variable given the DWARF die for the non-defining + decl to be ignored. */ + +bool +ctf_dvd_ignore_lookup (const ctf_container_ref ctfc, dw_die_ref die) +{ + ctf_dvdef_t entry; + entry.dvd_key = die; + + ctf_dvdef_ref * slot = ctfc->ctfc_ignore_vars->find_slot (&entry, NO_INSERT); + + if (slot) + return true; + + return false; +} + /* Append member definition to the list. Member list is a singly-linked list with list start pointing to the head. */ @@ -666,9 +700,10 @@ ctf_add_member_offset (ctf_container_ref ctfc, dw_die_ref sou, int ctf_add_variable (ctf_container_ref ctfc, const char * name, ctf_id_t ref, - dw_die_ref die, unsigned int external_vis) + dw_die_ref die, unsigned int external_vis, + dw_die_ref die_var_decl) { - ctf_dvdef_ref dvd; + ctf_dvdef_ref dvd, dvd_ignore; gcc_assert (name); @@ -680,6 +715,24 @@ ctf_add_variable (ctf_container_ref ctfc, const char * name, ctf_id_t ref, dvd->dvd_name = ctf_add_string (ctfc, name, &(dvd->dvd_name_offset)); dvd->dvd_visibility = external_vis; dvd->dvd_type = ref; + + /* If DW_AT_specification attribute exists, keep track of it as this is + the non-defining declaration corresponding to the variable. We will + skip emitting CTF variable for such incomplete, non-defining + declarations. + There could be some non-defining declarations, however, for which a + defining declaration does not show up in the same CU. For such + cases, the compiler continues to emit CTF variable record as + usual. */ + if (die_var_decl) + { + dvd_ignore = ggc_cleared_alloc<ctf_dvdef_t> (); + dvd_ignore->dvd_key = die_var_decl; + /* It's alright to leave other fields as zero. No valid CTF + variable will be added for these DW_TAG_variable DIEs. */ + ctf_dvd_ignore_insert (ctfc, dvd_ignore); + } + ctf_dvd_insert (ctfc, dvd); if (strcmp (name, "")) @@ -724,7 +777,7 @@ ctf_add_function_arg (ctf_container_ref ctfc, dw_die_ref func, ctf_id_t ctf_add_function (ctf_container_ref ctfc, uint32_t flag, const char * name, const ctf_funcinfo_t * ctc, dw_die_ref die, - bool from_global_func) + bool from_global_func, int linkage) { ctf_dtdef_ref dtd; ctf_id_t type; @@ -738,6 +791,7 @@ ctf_add_function (ctf_container_ref ctfc, uint32_t flag, const char * name, type = ctf_add_generic (ctfc, flag, name, &dtd, die); dtd->from_global_func = from_global_func; + dtd->linkage = linkage; dtd->dtd_data.ctti_info = CTF_TYPE_INFO (CTF_K_FUNCTION, flag, vlen); /* Caller must make sure CTF types for ctc->ctc_return are already added. */ dtd->dtd_data.ctti_type = (uint32_t) ctc->ctc_return; @@ -900,6 +954,8 @@ new_ctf_container (void) = hash_table<ctfc_dtd_hasher>::create_ggc (100); tu_ctfc->ctfc_vars = hash_table<ctfc_dvd_hasher>::create_ggc (100); + tu_ctfc->ctfc_ignore_vars + = hash_table<ctfc_dvd_hasher>::create_ggc (10); return tu_ctfc; } @@ -952,6 +1008,9 @@ ctfc_delete_container (ctf_container_ref ctfc) ctfc->ctfc_vars->empty (); ctfc->ctfc_types = NULL; + ctfc->ctfc_ignore_vars->empty (); + ctfc->ctfc_ignore_vars = NULL; + ctfc_delete_strtab (&ctfc->ctfc_strtable); ctfc_delete_strtab (&ctfc->ctfc_aux_strtable); if (ctfc->ctfc_vars_list) |