diff options
author | Cupertino Miranda <cupertino.miranda@oracle.com> | 2023-11-10 14:02:30 +0000 |
---|---|---|
committer | Cupertino Miranda <cupertino.miranda@oracle.com> | 2023-11-28 12:56:22 +0000 |
commit | 099b15e2bdb78c21ad3f9001af77072413f4e159 (patch) | |
tree | 74157c775c175eac3aed309a16a613f75000e864 /gcc/testsuite | |
parent | faf5b148588bd7fbb60ec669aefa704044037cdc (diff) | |
download | gcc-099b15e2bdb78c21ad3f9001af77072413f4e159.zip gcc-099b15e2bdb78c21ad3f9001af77072413f4e159.tar.gz gcc-099b15e2bdb78c21ad3f9001af77072413f4e159.tar.bz2 |
Fixed problem with BTF defining smaller enums.
This patch fixes a BTF, which would become invalid when having
smaller then 4 byte definitions of enums.
For example, when using the __attribute__((mode(byte))) in the enum
definition.
Two problems were identified:
- it would incorrectly create an entry for enum64 when the size of the
enum was different then 4.
- it would allocate less then 4 bytes for the value entry in BTF, in
case the type was smaller.
BTF generated was validated against clang.
gcc/ChangeLog:
* btfout.cc (btf_calc_num_vbytes): Fixed logic for enum64.
(btf_asm_enum_const): Corrected logic for enum64 and smaller
than 4 bytes values.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-enum-small.c: Added test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.dg/debug/btf/btf-enum-small.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-enum-small.c b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-small.c new file mode 100644 index 0000000..eb8a1bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-small.c @@ -0,0 +1,28 @@ +/* Test BTF generation for small enums. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -gbtf -dA" } */ + +/* { dg-final { scan-assembler-not "bte_value_lo32" } } */ +/* { dg-final { scan-assembler-not "bte_value_hi32" } } */ +/* { dg-final { scan-assembler-times "\[\t \]0x6000002\[\t \]+\[^\n\]*btt_info" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'eSMALL' idx=0" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'eSMALLY' idx=1" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"eSMALL.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"eSMALLY.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ +/* { dg-final { scan-assembler-times "bte_value" 2 } } */ + +enum smalled_enum +{ + eSMALL, + eSMALLY, +} __attribute__((mode(byte))); + +struct root_struct { + enum smalled_enum esmall; +}; + +enum smalled_enum +foo(struct root_struct *root) { + return root->esmall; +} |