public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Faust <david.faust@oracle.com>
To: gcc-patches@gcc.gnu.org
Cc: indu.bhagat@oracle.com
Subject: [PATCH 1/2] btf: be clear when record size/type is not used
Date: Tue, 30 May 2023 11:27:01 -0700	[thread overview]
Message-ID: <20230530182702.8020-1-david.faust@oracle.com> (raw)
In-Reply-To: <20230525163740.6062-1-david.faust@oracle.com>

[Changes from v1: split this change into own commit.]

All BTF type records have a 4-byte field used to encode a size or link
to another type, depending on the type kind. But BTF_KIND_ARRAY and
BTF_KIND_FWD do not use this field at all, and should write zero.

GCC already correctly writes zero in this field for these type kinds,
but the process is not straightforward and results in the -dA comment
claiming the field is a reference to another type. This patch makes
the behavior explicit and updates the assembler comment to state
clearly that the field is unused.

gcc/

	* btfout.cc (btf_asm_type): Add dedicated cases for BTF_KIND_ARRAY
	and BTF_KIND_FWD which do not use the size/type field at all.
---
 gcc/btfout.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index 497c1ca06e6..ae9855716eb 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -705,6 +705,12 @@ 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_ARRAY:
+    case BTF_KIND_FWD:
+      /* These types do not encode any information in the size/type field
+	 and should write 0.  */
+      dw2_asm_output_data (4, 0, "(unused)");
+      return;
     default:
       break;
     }
-- 
2.40.1


  parent reply	other threads:[~2023-05-30 18:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 16:37 [PATCH] btf: improve -dA comments for testsuite David Faust
2023-05-30  7:30 ` Indu Bhagat
2023-05-30 16:08   ` David Faust
2023-05-30 16:45     ` Indu Bhagat
2023-05-30 18:27 ` David Faust [this message]
2023-05-30 18:27   ` [PATCH 2/2] " David Faust
2023-05-31  6:13     ` Indu Bhagat
2023-06-02  8:32       ` Iain Sandoe
2023-06-02 16:07         ` Alex Coplan
2023-05-31  6:12   ` [PATCH 1/2] btf: be clear when record size/type is not used Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230530182702.8020-1-david.faust@oracle.com \
    --to=david.faust@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=indu.bhagat@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).