This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix pessimization
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 Nov 2008 13:36:21 +0100
- Subject: [Ada] Fix pessimization
The compiler now generates a superfluous aggregate copy in some cases, a
fallout of the recent alignment promotion work.
Fixed thusly, tested on i586-suse-linux, applied on the mainline.
2008-11-15 ?Eric Botcazou ?<ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Force constants
initialized to a static constant to be statically allocated even if
they are of a padding type, provided the original type also has
constant size.
--
Eric Botcazou
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 141880)
+++ gcc-interface/decl.c (working copy)
@@ -1281,12 +1281,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
/* If this is constant initialized to a static constant and the
object has an aggregate type, force it to be statically
- allocated. */
- if (const_flag && gnu_expr && TREE_CONSTANT (gnu_expr)
+ allocated. This will avoid an initialization copy. */
+ if (!static_p && const_flag
+ && gnu_expr && TREE_CONSTANT (gnu_expr)
+ && AGGREGATE_TYPE_P (gnu_type)
&& host_integerp (TYPE_SIZE_UNIT (gnu_type), 1)
- && (AGGREGATE_TYPE_P (gnu_type)
- && !(TREE_CODE (gnu_type) == RECORD_TYPE
- && TYPE_IS_PADDING_P (gnu_type))))
+ && !(TREE_CODE (gnu_type) == RECORD_TYPE
+ && TYPE_IS_PADDING_P (gnu_type)
+ && !host_integerp (TYPE_SIZE_UNIT
+ (TREE_TYPE (TYPE_FIELDS (gnu_type))), 1)))
static_p = true;
gnu_decl = create_var_decl (gnu_entity_id, gnu_ext_name, gnu_type,