public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jose E. Marchesi <jemarch@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1937] btf: do not use the CHAR `encoding' bit for BTF
Date: Tue,  2 Aug 2022 17:26:14 +0000 (GMT)	[thread overview]
Message-ID: <20220802172614.00F213858296@sourceware.org> (raw)

https://gcc.gnu.org/g:5df04a7aa837a13b0e14d269c37bd3871d86bf08

commit r13-1937-g5df04a7aa837a13b0e14d269c37bd3871d86bf08
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date:   Fri Jul 22 12:40:50 2022 +0200

    btf: do not use the CHAR `encoding' bit for BTF
    
    Contrary to CTF and our previous expectations, as per [1], turns out
    that in BTF:
    
    1) The `encoding' field in integer types shall not be treated as a
       bitmap, but as an enumerated, i.e. these bits are exclusive to each
       other.
    
    2) The CHAR bit in `encoding' shall _not_ be set when emitting types
       for char nor `unsigned char'.
    
    Consequently this patch clears the CHAR bit before emitting the
    variable part of BTF integral types.  It also updates the testsuite
    accordingly, expanding it to check for BOOL bits.
    
    [1] https://lore.kernel.org/bpf/a73586ad-f2dc-0401-1eba-2004357b7edf@fb.com/T/#t
    
    gcc/ChangeLog:
    
            * btfout.cc (output_asm_btf_vlen_bytes): Do not use the CHAR
            encoding bit in BTF.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/debug/btf/btf-int-1.c: Do not check for char bits in
            bti_encoding and check for bool bits.

Diff:
---
 gcc/btfout.cc                              |  4 ++++
 gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c | 18 +++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index 594cba84910..997a33fa089 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -918,6 +918,10 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
       if (dtd->dtd_data.ctti_size < 1)
 	break;
 
+      /* In BTF the CHAR `encoding' seems to not be used, so clear it
+         here.  */
+      dtd->dtd_u.dtu_enc.cte_format &= ~BTF_INT_CHAR;
+
       encoding = BTF_INT_DATA (dtd->dtd_u.dtu_enc.cte_format,
 			       dtd->dtd_u.dtu_enc.cte_offset,
 			       dtd->dtd_u.dtu_enc.cte_bits);
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
index 2381decd6ff..87d9758e9cb 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
@@ -4,7 +4,8 @@
    | 0 | encoding | offset | 00 | bits |
    encoding:
      signed  1 << 24
-     char    2 << 24
+     char    2 << 24  (not used)
+     bool    4 << 24
 
    All offsets in this test should be 0.
    This test does _not_ check number of bits, as it may vary between targets.
@@ -13,13 +14,14 @@
 /* { dg-do compile } */
 /* { dg-options "-O0 -gbtf -dA" } */
 
-/* Check for 8 BTF_KIND_INT types.  */
-/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 8 } } */
+/* Check for 9 BTF_KIND_INT types.  */
+/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 9 } } */
 
-/* Check the signed/char flags, but not bit size. */
-/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 3 } } */
-/* { dg-final { scan-assembler-times "\[\t \]0x20000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
-/* { dg-final { scan-assembler-times "\[\t \]0x30000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
+/* Check the signed flags, but not bit size. */
+/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 4 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x..\[\t \]+\[^\n\]*bti_encoding" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x.\[\t \]+\[^\n\]*bti_encoding" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x40000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
 
 /* Check that there is a string entry for each type name.  */
 /* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
@@ -42,3 +44,5 @@ signed int f = -66;
 
 unsigned long int g = 77;
 signed long int h = 88;
+
+_Bool x = 1;


                 reply	other threads:[~2022-08-02 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220802172614.00F213858296@sourceware.org \
    --to=jemarch@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).