aboutsummaryrefslogtreecommitdiff
path: root/gcc/ctfc.h
diff options
context:
space:
mode:
authorIndu Bhagat <indu.bhagat@oracle.com>2022-04-14 10:01:22 -0700
committerIndu Bhagat <indu.bhagat@oracle.com>2022-04-14 10:03:52 -0700
commitd0b00e74bf59c73b79471bbe9de19373b8661e20 (patch)
tree44897017cd9f804e3d804144c0526bfcc5a24e28 /gcc/ctfc.h
parent613a6fca75156aadc2e79d78a23e547d39762c1e (diff)
downloadgcc-d0b00e74bf59c73b79471bbe9de19373b8661e20.zip
gcc-d0b00e74bf59c73b79471bbe9de19373b8661e20.tar.gz
gcc-d0b00e74bf59c73b79471bbe9de19373b8661e20.tar.bz2
CTF for extern variable fix [PR105089]
The CTF format cannot differentiate between a non-defining extern variable declaration vs. a defining variable declaration (unlike DWARF). So, the correct behaviour wrt the compiler generating CTF for such extern variables (i.e., when both the defining and non-defining decl are present in the same CU) is to simply emit the CTF variable correspoding to the defining declaration. To carry out the above, following changes are introduced via the patch: 1. The CTF container (ctfc.h) now keeps track of the non-defining declarations (by noting the DWARF attribute DW_AT_specification) in a new ctfc_ignore_vars hashtable. Such book-keeping is necessary because the CTF container should not rely on the order of DWARF DIEs presented to it at generation time. 2. At the time of ctf_add_variable (), the DW_AT_specification DIE if present is added in the ctfc_ignore_vars hashtable. The CTF variable generation for the defining declaration continues as normal. 3. If the ctf_add_variable () is asked to generate CTF variable for a DIE present in the ctfc_ignore_vars, it skips generating CTF for it. 4. Recall that CTF variables are pre-processed before emission. Till now, the only pre-processing that was being done was to sort them in order of their names. Now an additional step is added: If the CTF variable which corresponds to the non-defining declaration is indeed present in the ctfc_vars hashtable (because the corresponding DWARF DIE was encountered first by the CTF generation engine), skip that CTF variable from output. An important side effect of such a workflow above is that CTF for the C type of the non-defining decl will remain in the CTF dictionary (and will be emitted in the output section as well). This type can be pruned by the link-time de-duplicator as usual, if deemed unused. 2022-04-14 Indu Bhagat <indu.bhagat@oracle.com> gcc/ChangeLog: PR debug/105089 * ctfc.cc (ctf_dvd_ignore_insert): New function. (ctf_dvd_ignore_lookup): Likewise. (ctf_add_variable): Keep track of non-defining decl DIEs. (new_ctf_container): Initialize the new hash-table. (ctfc_delete_container): Empty hash-table. * ctfc.h (struct ctf_container): Add new hash-table. (ctf_dvd_ignore_lookup): New declaration. (ctf_add_variable): Add additional argument. * ctfout.cc (ctf_dvd_preprocess_cb): Skip adding CTF variable record for non-defining decl for which a defining decl exists in the same TU. (ctf_preprocess): Defer updating the number of global objts until here. (output_ctf_header): Use ctfc_vars_list_count as some CTF variables may not make it to the final output. (output_ctf_vars): Likewise. * dwarf2ctf.cc (gen_ctf_variable): Skip generating CTF variable if this is known to be a non-defining decl DIE.
Diffstat (limited to 'gcc/ctfc.h')
-rw-r--r--gcc/ctfc.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/ctfc.h b/gcc/ctfc.h
index 4ce756c..001e544 100644
--- a/gcc/ctfc.h
+++ b/gcc/ctfc.h
@@ -274,6 +274,8 @@ typedef struct GTY (()) ctf_container
hash_table <ctfc_dtd_hasher> * GTY (()) ctfc_types;
/* CTF variables. */
hash_table <ctfc_dvd_hasher> * GTY (()) ctfc_vars;
+ /* CTF variables to be ignored. */
+ hash_table <ctfc_dvd_hasher> * GTY (()) ctfc_ignore_vars;
/* CTF string table. */
ctf_strtable_t ctfc_strtable;
@@ -394,6 +396,8 @@ extern ctf_dtdef_ref ctf_dtd_lookup (const ctf_container_ref ctfc,
dw_die_ref die);
extern ctf_dvdef_ref ctf_dvd_lookup (const ctf_container_ref ctfc,
dw_die_ref die);
+extern bool ctf_dvd_ignore_lookup (const ctf_container_ref ctfc,
+ dw_die_ref die);
extern const char * ctf_add_string (ctf_container_ref, const char *,
uint32_t *, int);
@@ -430,7 +434,7 @@ extern int ctf_add_member_offset (ctf_container_ref, dw_die_ref, const char *,
extern int ctf_add_function_arg (ctf_container_ref, dw_die_ref,
const char *, ctf_id_t);
extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t,
- dw_die_ref, unsigned int);
+ dw_die_ref, unsigned int, dw_die_ref);
extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree);
extern ctf_id_t get_btf_id (ctf_id_t);