From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7824) id 7876E3857B9A; Fri, 7 Oct 2022 18:34:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7876E3857B9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665167691; bh=n1FO3aQLfcrezwFaY24A/QVaNgx5euzANbZb6+Wwj5s=; h=From:To:Subject:Date:From; b=WTkVgbe1cuRAXfkz129duz6W5bpVShVqnkf1ueUpHmfkYlRQhO+hNvpLzNQTvwxCx DdJU3BGcxiJfBSOKHmD1R4WpjsPq8D6diaQyO43AAavnu3d4QBKQI2npU6a37Firll uaYnWZEd/f0nI79N8yIxaEB2DRi+1wao3rJcEiZM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: David Faust To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/dfaust/heads/btf-type-tag-new-rebase)] Output BTF DECL_TAG and TYPE_TAG types X-Act-Checkin: gcc X-Git-Author: David Faust X-Git-Refname: refs/users/dfaust/heads/btf-type-tag-new-rebase X-Git-Oldrev: 71950a45356a5c24449ea3fb15f3e335417c9ff1 X-Git-Newrev: 1affad2e1f5a2d7a9c5cbc970ca252140465273c Message-Id: <20221007183451.7876E3857B9A@sourceware.org> Date: Fri, 7 Oct 2022 18:34:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1affad2e1f5a2d7a9c5cbc970ca252140465273c commit 1affad2e1f5a2d7a9c5cbc970ca252140465273c Author: David Faust Date: Wed Mar 2 15:13:13 2022 -0800 Output BTF DECL_TAG and TYPE_TAG types This patch updates btfout.cc to be aware of the DECL_TAG and TYPE_TAG kinds and output them appropriately. gcc/ * btfout.cc (get_btf_kind): Handle TYPE_TAG and DECL_TAG kinds. (btf_calc_num_vbytes): Likewise. (btf_asm_type): Likewise. (output_asm_btf_vlen_bytes): Likewise. Diff: --- gcc/btfout.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 997a33fa089..573d00837ee 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -136,6 +136,8 @@ get_btf_kind (uint32_t ctf_kind) case CTF_K_VOLATILE: return BTF_KIND_VOLATILE; case CTF_K_CONST: return BTF_KIND_CONST; case CTF_K_RESTRICT: return BTF_KIND_RESTRICT; + case CTF_K_TYPE_TAG: return BTF_KIND_TYPE_TAG; + case CTF_K_DECL_TAG: return BTF_KIND_DECL_TAG; default:; } return BTF_KIND_UNKN; @@ -201,6 +203,7 @@ btf_calc_num_vbytes (ctf_dtdef_ref dtd) case BTF_KIND_CONST: case BTF_KIND_RESTRICT: case BTF_KIND_FUNC: + case BTF_KIND_TYPE_TAG: /* These kinds have no vlen data. */ break; @@ -238,6 +241,10 @@ btf_calc_num_vbytes (ctf_dtdef_ref dtd) vlen_bytes += vlen * sizeof (struct btf_var_secinfo); break; + case BTF_KIND_DECL_TAG: + vlen_bytes += sizeof (struct btf_decl_tag); + break; + default: break; } @@ -637,6 +644,22 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) dw2_asm_output_data (4, dtd->dtd_data.ctti_size, "btt_size: %uB", dtd->dtd_data.ctti_size); return; + case BTF_KIND_DECL_TAG: + { + /* A decl tag might refer to (be the child DIE of) a variable. Try to + lookup the parent DIE's CTF variable, and if it exists point to the + corresponding BTF variable. This is an odd construction - we have a + 'type' which refers to a variable, rather than the reverse. */ + dw_die_ref parent = dw_get_die_parent (dtd->dtd_key); + ctf_dvdef_ref dvd = ctf_dvd_lookup (ctfc, parent); + if (dvd) + { + unsigned int var_id = + *(btf_var_ids->get (dvd)) + num_types_added + 1; + dw2_asm_output_data (4, var_id, "btt_type"); + return; + } + } default: break; } @@ -957,6 +980,11 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd) at this point. */ gcc_unreachable (); + case BTF_KIND_DECL_TAG: + dw2_asm_output_data (4, dtd->dtd_u.dtu_btfnote.component_idx, + "decltag_compidx"); + break; + default: /* All other BTF type kinds have no variable length data. */ break;