]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug/102507: ICE in btf_finalize when compiling with -gbtf
authorIndu Bhagat <indu.bhagat@oracle.com>
Wed, 29 Sep 2021 20:25:39 +0000 (13:25 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 29 Sep 2021 20:27:19 +0000 (13:27 -0700)
Fix the free up of btf_var_ids hash_map in btf_finalize ().

gcc/ChangeLog:

PR debug/102507
* btfout.c (GTY): Add GTY (()) albeit for cosmetic only purpose.
(btf_finalize): Empty the hash_map btf_var_ids.

gcc/btfout.c

index cdc6c6378c099264968d9ce97bd81fd3dff77468..a78781575602240d39c59539786bb0840b6c7275 100644 (file)
@@ -70,7 +70,7 @@ static char btf_info_section_label[MAX_BTF_LABEL_BYTES];
    converted to BTF_KIND_VAR type records. Strictly accounts for the index
    from the start of the variable type entries, does not include the number
    of types emitted prior to the variable records.  */
-static hash_map <ctf_dvdef_ref, unsigned int> *btf_var_ids;
+static GTY (()) hash_map <ctf_dvdef_ref, unsigned> *btf_var_ids;
 
 /* Mapping of type IDs from original CTF ID to BTF ID. Types do not map
    1-to-1 from CTF to BTF. To avoid polluting the CTF container when updating
@@ -1119,12 +1119,12 @@ btf_finalize (void)
 
   funcs = NULL;
 
+  btf_var_ids->empty ();
+  btf_var_ids = NULL;
+
   free (btf_id_map);
   btf_id_map = NULL;
 
-  ggc_free (btf_var_ids);
-  btf_var_ids = NULL;
-
   ctf_container_ref tu_ctfc = ctf_get_tu_ctfc ();
   ctfc_delete_container (tu_ctfc);
   tu_ctfc = NULL;