* [PR63238] output alignment debug information
@ 2016-08-27 4:48 Alexandre Oliva
2016-09-24 0:22 ` Alexandre Oliva
0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2016-08-27 4:48 UTC (permalink / raw)
To: gcc-patches
Output DWARFv5+ DW_AT_alignment for non-default alignment of
variables, fields and types.
Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install?
for include/ChangeLog
PR debug/63238
* dwarf2.def (DW_AT_alignment): New.
for gcc/ChangeLog
PR debug/63238
* dwarf2out.c (clone_as_declaration): Drop DW_AT_alignment.
(add_alignment_attribute): New.
(base_type_die): Add alignment attribute.
(subrange_type_die): Likewise.
(modified_type_die): Likewise.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die: Likewise.
(gen_enumeration_type_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die): Likewise.
(gen_field_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_struct_or_union_type_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(base_type_cmp): Compare alignment attribute.
for gcc/testsuite/ChangeLog
PR debug/63238
* gcc.dg/debug/dwarf2/align-1.c: New.
* gcc.dg/debug/dwarf2/align-2.c: New.
* gcc.dg/debug/dwarf2/align-3.c: New.
* gcc.dg/debug/dwarf2/align-4.c: New.
* gcc.dg/debug/dwarf2/align-5.c: New.
* gcc.dg/debug/dwarf2/align-6.c: New.
* gcc.dg/debug/dwarf2/align-as-1.c: New.
* g++.dg/debug/dwarf2/align-1.C: New.
* g++.dg/debug/dwarf2/align-2.C: New.
* g++.dg/debug/dwarf2/align-3.C: New.
* g++.dg/debug/dwarf2/align-4.C: New.
* g++.dg/debug/dwarf2/align-5.C: New.
* g++.dg/debug/dwarf2/align-6.C: New.
---
gcc/dwarf2out.c | 76 ++++++++++++++++++++++--
gcc/testsuite/g++.dg/debug/dwarf2/align-1.C | 5 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-2.C | 6 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-3.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-4.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-5.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-6.C | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c | 5 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c | 6 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c | 5 ++
include/dwarf2.def | 1
15 files changed, 158 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index f40f759..f3928e0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3342,6 +3342,7 @@ static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree,
const struct loc_descr_context *);
static void add_subscript_info (dw_die_ref, tree, bool);
static void add_byte_size_attribute (dw_die_ref, tree);
+static void add_alignment_attribute (dw_die_ref, tree);
static inline void add_bit_offset_attribute (dw_die_ref, tree,
struct vlr_context *);
static void add_bit_size_attribute (dw_die_ref, tree);
@@ -7415,6 +7416,7 @@ clone_as_declaration (dw_die_ref die)
add_dwarf_attr (clone, a);
break;
case DW_AT_byte_size:
+ case DW_AT_alignment:
default:
break;
}
@@ -10941,6 +10943,8 @@ base_type_die (tree type, bool reverse)
add_AT_unsigned (base_type_result, DW_AT_endianity,
BYTES_BIG_ENDIAN ? DW_END_little : DW_END_big);
+ add_alignment_attribute (base_type_result, type);
+
if (fpt_used)
{
switch (fpt_info.scale_factor_kind)
@@ -11104,6 +11108,8 @@ subrange_type_die (tree type, tree low, tree high, tree bias,
add_AT_unsigned (subrange_die, DW_AT_byte_size, size_in_bytes);
}
+ add_alignment_attribute (subrange_die, type);
+
if (low)
add_bound_info (subrange_die, DW_AT_lower_bound, low, NULL);
if (high)
@@ -11421,6 +11427,7 @@ modified_type_die (tree type, int cv_quals, bool reverse,
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
+ add_alignment_attribute (mod_type_die, type);
item_type = TREE_TYPE (type);
addr_space_t as = TYPE_ADDR_SPACE (item_type);
@@ -18600,6 +18607,37 @@ add_byte_size_attribute (dw_die_ref die, tree tree_node)
add_AT_unsigned (die, DW_AT_byte_size, size);
}
+/* Add a DW_AT_alignment attribute to DIE with TREE_NODE's non-default
+ alignment. */
+
+static void
+add_alignment_attribute (dw_die_ref die, tree tree_node)
+{
+ if (dwarf_version < 5 && dwarf_strict)
+ return;
+
+ unsigned align;
+
+ if (DECL_P (tree_node))
+ {
+ if (!DECL_USER_ALIGN (tree_node))
+ return;
+
+ align = DECL_ALIGN_UNIT (tree_node);
+ }
+ else if (TYPE_P (tree_node))
+ {
+ if (!TYPE_USER_ALIGN (tree_node))
+ return;
+
+ align = TYPE_ALIGN_UNIT (tree_node);
+ }
+ else
+ gcc_unreachable ();
+
+ add_AT_unsigned (die, DW_AT_alignment, align);
+}
+
/* For a FIELD_DECL node which represents a bit-field, output an attribute
which specifies the distance in bits from the highest order bit of the
"containing object" for the bit-field to the highest order bit of the
@@ -19363,6 +19401,8 @@ gen_array_type_die (tree type, dw_die_ref context_die)
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
/* This routine generates DIE for array with hidden descriptor, details
@@ -19457,6 +19497,8 @@ gen_descr_array_type_die (tree type, struct array_descr_info *info,
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
#if 0
@@ -19561,6 +19603,7 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (dwarf_version >= 3 || !dwarf_strict)
{
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
@@ -19619,6 +19662,8 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
else
add_AT_flag (type_die, DW_AT_declaration, 1);
+ add_alignment_attribute (type_die, type);
+
add_pubtype (type, type_die);
return type_die;
@@ -20521,6 +20566,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
if (TREE_THIS_VOLATILE (decl) && (dwarf_version >= 5 || !dwarf_strict))
add_AT_flag (subr_die, DW_AT_noreturn, 1);
+ add_alignment_attribute (subr_die, decl);
+
add_accessibility_attribute (subr_die, decl);
}
@@ -21227,6 +21274,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
decl_quals (decl_or_origin), false,
context_die);
+ add_alignment_attribute (var_die, decl);
add_AT_flag (var_die, DW_AT_external, 1);
if (loc)
{
@@ -21354,6 +21402,8 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
if (DECL_ARTIFICIAL (decl))
add_AT_flag (var_die, DW_AT_artificial, 1);
+ add_alignment_attribute (var_die, decl);
+
add_accessibility_attribute (var_die, decl);
}
@@ -21703,6 +21753,8 @@ gen_field_die (tree decl, struct vlr_context *ctx, dw_die_ref context_die)
add_bit_offset_attribute (decl_die, decl, ctx);
}
+ add_alignment_attribute (decl_die, decl);
+
/* If we have a variant part offset, then we are supposed to process a member
of a QUAL_UNION_TYPE, which is how we represent variant parts in
trees. */
@@ -21777,6 +21829,7 @@ gen_ptr_to_mbr_type_die (tree type, dw_die_ref context_die,
lookup_type_die (class_type));
add_type_attribute (ptr_die, member_type, TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (ptr_die, type);
if (TREE_CODE (type) == OFFSET_TYPE)
{
@@ -22629,6 +22682,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
this type is expressed in terms of this type itself. */
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
{
add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
@@ -22686,6 +22740,7 @@ gen_subroutine_type_die (tree type, dw_die_ref context_die)
add_prototyped_attribute (subr_die, type);
add_type_attribute (subr_die, return_type, TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (subr_die, type);
gen_formal_types_die (type, subr_die);
if (get_AT (subr_die, DW_AT_name))
@@ -22733,7 +22788,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
add_abstract_origin_attribute (type_die, origin);
else
{
- tree type;
+ tree type = TREE_TYPE (decl);
+
+ if (type == error_mark_node)
+ return;
add_name_and_src_coords_attributes (type_die, decl);
if (DECL_ORIGINAL_TYPE (decl))
@@ -22748,11 +22806,6 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
}
else
{
- type = TREE_TYPE (decl);
-
- if (type == error_mark_node)
- return;
-
if (is_naming_typedef_decl (TYPE_NAME (type)))
{
/* Here, we are in the case of decl being a typedef naming
@@ -22791,6 +22844,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
created. */
equate_type_number_to_die (type, type_die);
+ type = TREE_TYPE (decl);
+
+ add_alignment_attribute (type_die, type);
+
add_accessibility_attribute (type_die, decl);
}
@@ -26369,6 +26426,7 @@ base_type_cmp (const void *x, const void *y)
dw_die_ref dy = *(const dw_die_ref *) y;
unsigned int byte_size1, byte_size2;
unsigned int encoding1, encoding2;
+ unsigned int align1, align2;
if (dx->die_mark > dy->die_mark)
return -1;
if (dx->die_mark < dy->die_mark)
@@ -26385,6 +26443,12 @@ base_type_cmp (const void *x, const void *y)
return 1;
if (encoding1 > encoding2)
return -1;
+ align1 = get_AT_unsigned (dx, DW_AT_alignment);
+ align2 = get_AT_unsigned (dy, DW_AT_alignment);
+ if (align1 < align2)
+ return 1;
+ if (align1 > align2)
+ return -1;
return 0;
}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
new file mode 100644
index 0000000..6923257
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int _Alignas(64) i;
diff --git a/include/dwarf2.def b/include/dwarf2.def
index 8546f7e..9268497 100644
--- a/include/dwarf2.def
+++ b/include/dwarf2.def
@@ -312,6 +312,7 @@ DW_AT (DW_AT_linkage_name, 0x6e)
DW_AT (DW_AT_reference, 0x77)
DW_AT (DW_AT_rvalue_reference, 0x78)
DW_AT (DW_AT_noreturn, 0x87)
+DW_AT (DW_AT_alignment, 0x88)
DW_AT (DW_AT_deleted, 0x8a)
DW_AT (DW_AT_defaulted, 0x8b)
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2016-08-27 4:48 [PR63238] output alignment debug information Alexandre Oliva
@ 2016-09-24 0:22 ` Alexandre Oliva
2016-10-19 10:15 ` Alexandre Oliva
0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2016-09-24 0:22 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, ccoutant
On Aug 27, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
> Output DWARFv5+ DW_AT_alignment for non-default alignment of
> variables, fields and types.
> Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install?
Ping?
https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01911.html
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2016-09-24 0:22 ` Alexandre Oliva
@ 2016-10-19 10:15 ` Alexandre Oliva
2017-01-27 6:37 ` Alexandre Oliva
0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2016-10-19 10:15 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, ccoutant
On Sep 23, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Aug 27, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
>> Output DWARFv5+ DW_AT_alignment for non-default alignment of
>> variables, fields and types.
>> Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install?
> Ping?
Ping? (conflicts resolved, patch refreshed and retested)
Output DWARFv5+ DW_AT_alignment for non-default alignment of
variables, fields and types.
for gcc/ChangeLog
PR debug/63238
* dwarf2out.c (clone_as_declaration): Drop DW_AT_alignment.
(add_alignment_attribute): New.
(base_type_die): Add alignment attribute.
(subrange_type_die): Likewise.
(modified_type_die): Likewise.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die: Likewise.
(gen_enumeration_type_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die): Likewise.
(gen_field_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_struct_or_union_type_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(base_type_cmp): Compare alignment attribute.
for gcc/testsuite/ChangeLog
PR debug/63238
* gcc.dg/debug/dwarf2/align-1.c: New.
* gcc.dg/debug/dwarf2/align-2.c: New.
* gcc.dg/debug/dwarf2/align-3.c: New.
* gcc.dg/debug/dwarf2/align-4.c: New.
* gcc.dg/debug/dwarf2/align-5.c: New.
* gcc.dg/debug/dwarf2/align-6.c: New.
* gcc.dg/debug/dwarf2/align-as-1.c: New.
* g++.dg/debug/dwarf2/align-1.C: New.
* g++.dg/debug/dwarf2/align-2.C: New.
* g++.dg/debug/dwarf2/align-3.C: New.
* g++.dg/debug/dwarf2/align-4.C: New.
* g++.dg/debug/dwarf2/align-5.C: New.
* g++.dg/debug/dwarf2/align-6.C: New.
---
gcc/dwarf2out.c | 76 ++++++++++++++++++++++--
gcc/testsuite/g++.dg/debug/dwarf2/align-1.C | 5 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-2.C | 6 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-3.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-4.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-5.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-6.C | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c | 5 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c | 6 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c | 5 ++
14 files changed, 157 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ba36310..afe7bfd 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3342,6 +3342,7 @@ static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree,
const struct loc_descr_context *);
static void add_subscript_info (dw_die_ref, tree, bool);
static void add_byte_size_attribute (dw_die_ref, tree);
+static void add_alignment_attribute (dw_die_ref, tree);
static inline void add_bit_offset_attribute (dw_die_ref, tree,
struct vlr_context *);
static void add_bit_size_attribute (dw_die_ref, tree);
@@ -7461,6 +7462,7 @@ clone_as_declaration (dw_die_ref die)
add_dwarf_attr (clone, a);
break;
case DW_AT_byte_size:
+ case DW_AT_alignment:
default:
break;
}
@@ -10986,6 +10988,8 @@ base_type_die (tree type, bool reverse)
add_AT_unsigned (base_type_result, DW_AT_endianity,
BYTES_BIG_ENDIAN ? DW_END_little : DW_END_big);
+ add_alignment_attribute (base_type_result, type);
+
if (fpt_used)
{
switch (fpt_info.scale_factor_kind)
@@ -11149,6 +11153,8 @@ subrange_type_die (tree type, tree low, tree high, tree bias,
add_AT_unsigned (subrange_die, DW_AT_byte_size, size_in_bytes);
}
+ add_alignment_attribute (subrange_die, type);
+
if (low)
add_bound_info (subrange_die, DW_AT_lower_bound, low, NULL);
if (high)
@@ -11466,6 +11472,7 @@ modified_type_die (tree type, int cv_quals, bool reverse,
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
+ add_alignment_attribute (mod_type_die, type);
item_type = TREE_TYPE (type);
addr_space_t as = TYPE_ADDR_SPACE (item_type);
@@ -18659,6 +18666,37 @@ add_byte_size_attribute (dw_die_ref die, tree tree_node)
add_AT_unsigned (die, DW_AT_byte_size, size);
}
+/* Add a DW_AT_alignment attribute to DIE with TREE_NODE's non-default
+ alignment. */
+
+static void
+add_alignment_attribute (dw_die_ref die, tree tree_node)
+{
+ if (dwarf_version < 5 && dwarf_strict)
+ return;
+
+ unsigned align;
+
+ if (DECL_P (tree_node))
+ {
+ if (!DECL_USER_ALIGN (tree_node))
+ return;
+
+ align = DECL_ALIGN_UNIT (tree_node);
+ }
+ else if (TYPE_P (tree_node))
+ {
+ if (!TYPE_USER_ALIGN (tree_node))
+ return;
+
+ align = TYPE_ALIGN_UNIT (tree_node);
+ }
+ else
+ gcc_unreachable ();
+
+ add_AT_unsigned (die, DW_AT_alignment, align);
+}
+
/* For a FIELD_DECL node which represents a bit-field, output an attribute
which specifies the distance in bits from the highest order bit of the
"containing object" for the bit-field to the highest order bit of the
@@ -19476,6 +19514,8 @@ gen_array_type_die (tree type, dw_die_ref context_die)
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
/* After all arguments are created, adjust any DW_TAG_string_type
@@ -19603,6 +19643,8 @@ gen_descr_array_type_die (tree type, struct array_descr_info *info,
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
#if 0
@@ -19707,6 +19749,7 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (dwarf_version >= 3 || !dwarf_strict)
{
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
@@ -19765,6 +19808,8 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
else
add_AT_flag (type_die, DW_AT_declaration, 1);
+ add_alignment_attribute (type_die, type);
+
add_pubtype (type, type_die);
return type_die;
@@ -20664,6 +20709,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
if (TREE_THIS_VOLATILE (decl) && (dwarf_version >= 5 || !dwarf_strict))
add_AT_flag (subr_die, DW_AT_noreturn, 1);
+ add_alignment_attribute (subr_die, decl);
+
add_accessibility_attribute (subr_die, decl);
}
@@ -21373,6 +21420,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
decl_quals (decl_or_origin), false,
context_die);
+ add_alignment_attribute (var_die, decl);
add_AT_flag (var_die, DW_AT_external, 1);
if (loc)
{
@@ -21500,6 +21548,8 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
if (DECL_ARTIFICIAL (decl))
add_AT_flag (var_die, DW_AT_artificial, 1);
+ add_alignment_attribute (var_die, decl);
+
add_accessibility_attribute (var_die, decl);
}
@@ -21849,6 +21899,8 @@ gen_field_die (tree decl, struct vlr_context *ctx, dw_die_ref context_die)
add_bit_offset_attribute (decl_die, decl, ctx);
}
+ add_alignment_attribute (decl_die, decl);
+
/* If we have a variant part offset, then we are supposed to process a member
of a QUAL_UNION_TYPE, which is how we represent variant parts in
trees. */
@@ -21923,6 +21975,7 @@ gen_ptr_to_mbr_type_die (tree type, dw_die_ref context_die,
lookup_type_die (class_type));
add_type_attribute (ptr_die, member_type, TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (ptr_die, type);
if (TREE_CODE (type) == OFFSET_TYPE)
{
@@ -22786,6 +22839,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
this type is expressed in terms of this type itself. */
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
{
add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
@@ -22843,6 +22897,7 @@ gen_subroutine_type_die (tree type, dw_die_ref context_die)
add_prototyped_attribute (subr_die, type);
add_type_attribute (subr_die, return_type, TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (subr_die, type);
gen_formal_types_die (type, subr_die);
if (get_AT (subr_die, DW_AT_name))
@@ -22890,7 +22945,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
add_abstract_origin_attribute (type_die, origin);
else
{
- tree type;
+ tree type = TREE_TYPE (decl);
+
+ if (type == error_mark_node)
+ return;
add_name_and_src_coords_attributes (type_die, decl);
if (DECL_ORIGINAL_TYPE (decl))
@@ -22905,11 +22963,6 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
}
else
{
- type = TREE_TYPE (decl);
-
- if (type == error_mark_node)
- return;
-
if (is_naming_typedef_decl (TYPE_NAME (type)))
{
/* Here, we are in the case of decl being a typedef naming
@@ -22948,6 +23001,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
created. */
equate_type_number_to_die (type, type_die);
+ type = TREE_TYPE (decl);
+
+ add_alignment_attribute (type_die, type);
+
add_accessibility_attribute (type_die, decl);
}
@@ -26589,6 +26646,7 @@ base_type_cmp (const void *x, const void *y)
dw_die_ref dy = *(const dw_die_ref *) y;
unsigned int byte_size1, byte_size2;
unsigned int encoding1, encoding2;
+ unsigned int align1, align2;
if (dx->die_mark > dy->die_mark)
return -1;
if (dx->die_mark < dy->die_mark)
@@ -26605,6 +26663,12 @@ base_type_cmp (const void *x, const void *y)
return 1;
if (encoding1 > encoding2)
return -1;
+ align1 = get_AT_unsigned (dx, DW_AT_alignment);
+ align2 = get_AT_unsigned (dy, DW_AT_alignment);
+ if (align1 < align2)
+ return 1;
+ if (align1 > align2)
+ return -1;
return 0;
}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
new file mode 100644
index 0000000..6923257
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int _Alignas(64) i;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2016-10-19 10:15 ` Alexandre Oliva
@ 2017-01-27 6:37 ` Alexandre Oliva
2017-01-29 18:55 ` Cary Coutant
2017-02-01 15:55 ` Jakub Jelinek
0 siblings, 2 replies; 8+ messages in thread
From: Alexandre Oliva @ 2017-01-27 6:37 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, ccoutant
On Oct 19, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Sep 23, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
>> On Aug 27, 2016, Alexandre Oliva <aoliva@redhat.com> wrote:
>>> Output DWARFv5+ DW_AT_alignment for non-default alignment of
>>> variables, fields and types.
>>> Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install?
>> Ping?
> Ping? (conflicts resolved, patch refreshed and retested)
Ping? (refreshed, not sure there were conflicts to resolve)
[PR63238] output alignment debug information
From: Alexandre Oliva <aoliva@redhat.com>
Output DWARFv5+ DW_AT_alignment for non-default alignment of
variables, fields and types.
for gcc/ChangeLog
PR debug/63238
* dwarf2out.c (clone_as_declaration): Drop DW_AT_alignment.
(add_alignment_attribute): New.
(base_type_die): Add alignment attribute.
(subrange_type_die): Likewise.
(modified_type_die): Likewise.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die: Likewise.
(gen_enumeration_type_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die): Likewise.
(gen_field_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_struct_or_union_type_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(base_type_cmp): Compare alignment attribute.
for gcc/testsuite/ChangeLog
PR debug/63238
* gcc.dg/debug/dwarf2/align-1.c: New.
* gcc.dg/debug/dwarf2/align-2.c: New.
* gcc.dg/debug/dwarf2/align-3.c: New.
* gcc.dg/debug/dwarf2/align-4.c: New.
* gcc.dg/debug/dwarf2/align-5.c: New.
* gcc.dg/debug/dwarf2/align-6.c: New.
* gcc.dg/debug/dwarf2/align-as-1.c: New.
* g++.dg/debug/dwarf2/align-1.C: New.
* g++.dg/debug/dwarf2/align-2.C: New.
* g++.dg/debug/dwarf2/align-3.C: New.
* g++.dg/debug/dwarf2/align-4.C: New.
* g++.dg/debug/dwarf2/align-5.C: New.
* g++.dg/debug/dwarf2/align-6.C: New.
---
gcc/dwarf2out.c | 76 ++++++++++++++++++++++--
gcc/testsuite/g++.dg/debug/dwarf2/align-1.C | 5 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-2.C | 6 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-3.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-4.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-5.C | 7 ++
gcc/testsuite/g++.dg/debug/dwarf2/align-6.C | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c | 5 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c | 6 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c | 7 ++
gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c | 9 +++
gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c | 5 ++
14 files changed, 157 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1b2c04c..f8fe4c1 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3510,6 +3510,7 @@ static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree,
struct loc_descr_context *);
static void add_subscript_info (dw_die_ref, tree, bool);
static void add_byte_size_attribute (dw_die_ref, tree);
+static void add_alignment_attribute (dw_die_ref, tree);
static inline void add_bit_offset_attribute (dw_die_ref, tree,
struct vlr_context *);
static void add_bit_size_attribute (dw_die_ref, tree);
@@ -7706,6 +7707,7 @@ clone_as_declaration (dw_die_ref die)
add_dwarf_attr (clone, a);
break;
case DW_AT_byte_size:
+ case DW_AT_alignment:
default:
break;
}
@@ -12106,6 +12108,8 @@ base_type_die (tree type, bool reverse)
add_AT_unsigned (base_type_result, DW_AT_endianity,
BYTES_BIG_ENDIAN ? DW_END_little : DW_END_big);
+ add_alignment_attribute (base_type_result, type);
+
if (fpt_used)
{
switch (fpt_info.scale_factor_kind)
@@ -12269,6 +12273,8 @@ subrange_type_die (tree type, tree low, tree high, tree bias,
add_AT_unsigned (subrange_die, DW_AT_byte_size, size_in_bytes);
}
+ add_alignment_attribute (subrange_die, type);
+
if (low)
add_bound_info (subrange_die, DW_AT_lower_bound, low, NULL);
if (high)
@@ -12586,6 +12592,7 @@ modified_type_die (tree type, int cv_quals, bool reverse,
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
+ add_alignment_attribute (mod_type_die, type);
item_type = TREE_TYPE (type);
addr_space_t as = TYPE_ADDR_SPACE (item_type);
@@ -19946,6 +19953,37 @@ add_byte_size_attribute (dw_die_ref die, tree tree_node)
add_AT_unsigned (die, DW_AT_byte_size, size);
}
+/* Add a DW_AT_alignment attribute to DIE with TREE_NODE's non-default
+ alignment. */
+
+static void
+add_alignment_attribute (dw_die_ref die, tree tree_node)
+{
+ if (dwarf_version < 5 && dwarf_strict)
+ return;
+
+ unsigned align;
+
+ if (DECL_P (tree_node))
+ {
+ if (!DECL_USER_ALIGN (tree_node))
+ return;
+
+ align = DECL_ALIGN_UNIT (tree_node);
+ }
+ else if (TYPE_P (tree_node))
+ {
+ if (!TYPE_USER_ALIGN (tree_node))
+ return;
+
+ align = TYPE_ALIGN_UNIT (tree_node);
+ }
+ else
+ gcc_unreachable ();
+
+ add_AT_unsigned (die, DW_AT_alignment, align);
+}
+
/* For a FIELD_DECL node which represents a bit-field, output an attribute
which specifies the distance in bits from the highest order bit of the
"containing object" for the bit-field to the highest order bit of the
@@ -20765,6 +20803,8 @@ gen_array_type_die (tree type, dw_die_ref context_die)
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
/* After all arguments are created, adjust any DW_TAG_string_type
@@ -20904,6 +20944,8 @@ gen_descr_array_type_die (tree type, struct array_descr_info *info,
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
+
+ add_alignment_attribute (array_die, type);
}
#if 0
@@ -21013,6 +21055,7 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (dwarf_version >= 3 || !dwarf_strict)
{
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
@@ -21071,6 +21114,8 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
else
add_AT_flag (type_die, DW_AT_declaration, 1);
+ add_alignment_attribute (type_die, type);
+
add_pubtype (type, type_die);
return type_die;
@@ -21971,6 +22016,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
if (TREE_THIS_VOLATILE (decl) && (dwarf_version >= 5 || !dwarf_strict))
add_AT_flag (subr_die, DW_AT_noreturn, 1);
+ add_alignment_attribute (subr_die, decl);
+
add_accessibility_attribute (subr_die, decl);
}
@@ -22695,6 +22742,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
decl_quals (decl_or_origin), false,
context_die);
+ add_alignment_attribute (var_die, decl);
add_AT_flag (var_die, DW_AT_external, 1);
if (loc)
{
@@ -22822,6 +22870,8 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
if (DECL_ARTIFICIAL (decl))
add_AT_flag (var_die, DW_AT_artificial, 1);
+ add_alignment_attribute (var_die, decl);
+
add_accessibility_attribute (var_die, decl);
}
@@ -23186,6 +23236,8 @@ gen_field_die (tree decl, struct vlr_context *ctx, dw_die_ref context_die)
add_bit_offset_attribute (decl_die, decl, ctx);
}
+ add_alignment_attribute (decl_die, decl);
+
/* If we have a variant part offset, then we are supposed to process a member
of a QUAL_UNION_TYPE, which is how we represent variant parts in
trees. */
@@ -23261,6 +23313,7 @@ gen_ptr_to_mbr_type_die (tree type, dw_die_ref context_die)
lookup_type_die (TYPE_OFFSET_BASETYPE (type)));
add_type_attribute (ptr_die, TREE_TYPE (type), TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (ptr_die, type);
if (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)
@@ -24139,6 +24192,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
this type is expressed in terms of this type itself. */
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
+ add_alignment_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
{
add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
@@ -24196,6 +24250,7 @@ gen_subroutine_type_die (tree type, dw_die_ref context_die)
add_prototyped_attribute (subr_die, type);
add_type_attribute (subr_die, return_type, TYPE_UNQUALIFIED, false,
context_die);
+ add_alignment_attribute (subr_die, type);
gen_formal_types_die (type, subr_die);
if (get_AT (subr_die, DW_AT_name))
@@ -24231,7 +24286,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
add_abstract_origin_attribute (type_die, origin);
else
{
- tree type;
+ tree type = TREE_TYPE (decl);
+
+ if (type == error_mark_node)
+ return;
add_name_and_src_coords_attributes (type_die, decl);
if (DECL_ORIGINAL_TYPE (decl))
@@ -24246,11 +24304,6 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
}
else
{
- type = TREE_TYPE (decl);
-
- if (type == error_mark_node)
- return;
-
if (is_naming_typedef_decl (TYPE_NAME (type)))
{
/* Here, we are in the case of decl being a typedef naming
@@ -24289,6 +24342,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
created. */
equate_type_number_to_die (type, type_die);
+ type = TREE_TYPE (decl);
+
+ add_alignment_attribute (type_die, type);
+
add_accessibility_attribute (type_die, decl);
}
@@ -27964,6 +28021,7 @@ base_type_cmp (const void *x, const void *y)
dw_die_ref dy = *(const dw_die_ref *) y;
unsigned int byte_size1, byte_size2;
unsigned int encoding1, encoding2;
+ unsigned int align1, align2;
if (dx->die_mark > dy->die_mark)
return -1;
if (dx->die_mark < dy->die_mark)
@@ -27980,6 +28038,12 @@ base_type_cmp (const void *x, const void *y)
return 1;
if (encoding1 > encoding2)
return -1;
+ align1 = get_AT_unsigned (dx, DW_AT_alignment);
+ align2 = get_AT_unsigned (dy, DW_AT_alignment);
+ if (align1 < align2)
+ return 1;
+ if (align1 > align2)
+ return -1;
return 0;
}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-1.C
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-2.C
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-3.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-4.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-5.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/align-6.C
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
new file mode 100644
index 0000000..58b7731
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int __attribute__((__aligned__(64))) i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
new file mode 100644
index 0000000..31eed4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
new file mode 100644
index 0000000..328ea0d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+typedef int int_t;
+typedef int_t __attribute__((__aligned__(64))) i_t;
+i_t i;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
new file mode 100644
index 0000000..31e9e81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int __attribute__((__aligned__(64))) i;
+} t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
new file mode 100644
index 0000000..2116646
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+} __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
new file mode 100644
index 0000000..e8fc43f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+struct tt {
+ int i;
+};
+
+struct tt __attribute__((__aligned__(64))) t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
new file mode 100644
index 0000000..6923257
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
+
+int _Alignas(64) i;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2017-01-27 6:37 ` Alexandre Oliva
@ 2017-01-29 18:55 ` Cary Coutant
2017-01-30 17:55 ` Alexandre Oliva
2017-02-01 15:55 ` Jakub Jelinek
1 sibling, 1 reply; 8+ messages in thread
From: Cary Coutant @ 2017-01-29 18:55 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: GCC Patches, Jason Merrill
> for gcc/ChangeLog
>
> PR debug/63238
> * dwarf2out.c (clone_as_declaration): Drop DW_AT_alignment.
> (add_alignment_attribute): New.
> (base_type_die): Add alignment attribute.
> (subrange_type_die): Likewise.
> (modified_type_die): Likewise.
> (gen_array_type_die): Likewise.
> (gen_descr_array_type_die: Likewise.
> (gen_enumeration_type_die): Likewise.
> (gen_subprogram_die): Likewise.
> (gen_variable_die): Likewise.
> (gen_field_die): Likewise.
> (gen_ptr_to_mbr_type_die): Likewise.
> (gen_struct_or_union_type_die): Likewise.
> (gen_subroutine_type_die): Likewise.
> (gen_typedef_die): Likewise.
> (base_type_cmp): Compare alignment attribute.
This is OK so far, but the DW_AT_alignment attribute also needs to be
added to the checksum computation in die_checksum and
die_checksum_ordered.
-cary
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2017-01-29 18:55 ` Cary Coutant
@ 2017-01-30 17:55 ` Alexandre Oliva
2017-03-17 3:13 ` Cary Coutant
0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2017-01-30 17:55 UTC (permalink / raw)
To: Cary Coutant; +Cc: GCC Patches, Jason Merrill
On Jan 29, 2017, Cary Coutant <ccoutant@gmail.com> wrote:
>> for gcc/ChangeLog
>>
>> PR debug/63238
> This is OK so far, but the DW_AT_alignment attribute also needs to be
> added to the checksum computation in die_checksum and
> die_checksum_ordered.
Thanks. I see what to do in die_checksum_ordered, but die_checksum? It
seems to handle attributes by value class, and AFAICT the classes that
DW_AT_alignment could use are already covered. What am I missing?
Here's a patch I'm about to start testing. Does it look ok?
[PR63238] include alignment debug information in DIE checksum
Add DW_AT_alignment to the DIE checksum.
for gcc/ChangeLog
PR debug/63238
* dwarf2out.c (struct checksum_attributes): Add at_alignment.
(collect_checksum_attributes): Set it.
(die_checksum_ordered): Use it.
---
gcc/dwarf2out.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index f8fe4c1..15b7a66 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -6600,6 +6600,7 @@ struct checksum_attributes
dw_attr_node *at_friend;
dw_attr_node *at_accessibility;
dw_attr_node *at_address_class;
+ dw_attr_node *at_alignment;
dw_attr_node *at_allocated;
dw_attr_node *at_artificial;
dw_attr_node *at_associated;
@@ -6673,6 +6674,9 @@ collect_checksum_attributes (struct checksum_attributes *attrs, dw_die_ref die)
case DW_AT_address_class:
attrs->at_address_class = a;
break;
+ case DW_AT_alignment:
+ attrs->at_alignment = a;
+ break;
case DW_AT_allocated:
attrs->at_allocated = a;
break;
@@ -6879,6 +6883,7 @@ die_checksum_ordered (dw_die_ref die, struct md5_ctx *ctx, int *mark)
CHECKSUM_ATTR (attrs.at_vtable_elem_location);
CHECKSUM_ATTR (attrs.at_type);
CHECKSUM_ATTR (attrs.at_friend);
+ CHECKSUM_ATTR (attrs.at_alignment);
/* Checksum the child DIEs. */
c = die->die_child;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2017-01-27 6:37 ` Alexandre Oliva
2017-01-29 18:55 ` Cary Coutant
@ 2017-02-01 15:55 ` Jakub Jelinek
1 sibling, 0 replies; 8+ messages in thread
From: Jakub Jelinek @ 2017-02-01 15:55 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-patches, jason, ccoutant
On Fri, Jan 27, 2017 at 04:24:58AM -0200, Alexandre Oliva wrote:
> Output DWARFv5+ DW_AT_alignment for non-default alignment of
> variables, fields and types.
The new tests all fail on targets that default to -gstrict-dwarf
because they have buggy or prehistoric linkers/debug info consumers
like Darwin.
Fixed thusly, tested on x86_64-linux vanilla and with common.opt
hack to turn -gstrict-dwarf and -fno-merge-debug-strings by default,
committed to trunk as obvious:
2017-02-01 Jakub Jelinek <jakub@redhat.com>
PR testsuite/79324
* gcc.dg/debug/dwarf2/align-1.c: Add -gno-strict-dwarf to dg-options.
* gcc.dg/debug/dwarf2/align-2.c: Likewise.
* gcc.dg/debug/dwarf2/align-3.c: Likewise.
* gcc.dg/debug/dwarf2/align-4.c: Likewise.
* gcc.dg/debug/dwarf2/align-5.c: Likewise.
* gcc.dg/debug/dwarf2/align-6.c: Likewise.
* gcc.dg/debug/dwarf2/align-as-1.c: Likewise.
* g++.dg/debug/dwarf2/align-1.C: Likewise.
* g++.dg/debug/dwarf2/align-2.C: Likewise.
* g++.dg/debug/dwarf2/align-3.C: Likewise.
* g++.dg/debug/dwarf2/align-4.C: Likewise.
* g++.dg/debug/dwarf2/align-5.C: Likewise.
* g++.dg/debug/dwarf2/align-6.C: Likewise.
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-1.c 2017-02-01 16:39:24.852112430 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
int __attribute__((__aligned__(64))) i;
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-2.c 2017-02-01 16:39:34.260991165 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
typedef int __attribute__((__aligned__(64))) i_t;
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-3.c 2017-02-01 16:39:37.841945013 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
typedef int int_t;
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-4.c 2017-02-01 16:39:41.889892842 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
struct tt {
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-5.c 2017-02-01 16:39:46.117838350 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
struct tt {
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-6.c 2017-02-01 16:39:50.884776913 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
struct tt {
--- gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/align-as-1.c 2017-02-01 16:39:55.554716725 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
int _Alignas(64) i;
--- gcc/testsuite/g++.dg/debug/dwarf2/align-1.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-1.C 2017-02-01 16:40:58.421906472 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
int __attribute__((__aligned__(64))) i;
--- gcc/testsuite/g++.dg/debug/dwarf2/align-2.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-2.C 2017-02-01 16:41:01.340868851 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
typedef int __attribute__((__aligned__(64))) i_t;
--- gcc/testsuite/g++.dg/debug/dwarf2/align-3.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-3.C 2017-02-01 16:41:04.379829684 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
typedef int int_t;
--- gcc/testsuite/g++.dg/debug/dwarf2/align-4.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-4.C 2017-02-01 16:41:07.323791741 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 2 { xfail { powerpc-ibm-aix* } } } }
struct tt {
--- gcc/testsuite/g++.dg/debug/dwarf2/align-5.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-5.C 2017-02-01 16:41:10.945745060 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
struct tt {
--- gcc/testsuite/g++.dg/debug/dwarf2/align-6.C.jj 2017-01-31 09:26:00.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/align-6.C 2017-02-01 16:41:14.330701434 +0100
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O -g -dA" }
+// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
struct tt {
Jakub
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR63238] output alignment debug information
2017-01-30 17:55 ` Alexandre Oliva
@ 2017-03-17 3:13 ` Cary Coutant
0 siblings, 0 replies; 8+ messages in thread
From: Cary Coutant @ 2017-03-17 3:13 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: GCC Patches, Jason Merrill
>> This is OK so far, but the DW_AT_alignment attribute also needs to be
>> added to the checksum computation in die_checksum and
>> die_checksum_ordered.
>
> Thanks. I see what to do in die_checksum_ordered, but die_checksum? It
> seems to handle attributes by value class, and AFAICT the classes that
> DW_AT_alignment could use are already covered. What am I missing?
>
> Here's a patch I'm about to start testing. Does it look ok?
Sorry, I read this while I wasn't in a position to reply, then totally
forgot about it. Yes, you're right about die_checksum, sorry. And, for
the record, it looks OK.
-cary
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-03-17 3:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27 4:48 [PR63238] output alignment debug information Alexandre Oliva
2016-09-24 0:22 ` Alexandre Oliva
2016-10-19 10:15 ` Alexandre Oliva
2017-01-27 6:37 ` Alexandre Oliva
2017-01-29 18:55 ` Cary Coutant
2017-01-30 17:55 ` Alexandre Oliva
2017-03-17 3:13 ` Cary Coutant
2017-02-01 15:55 ` Jakub Jelinek
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).