* [Ada] Fix ICE in SRA pass at -O
@ 2008-06-27 9:20 Eric Botcazou
2008-06-27 10:08 ` Eric Botcazou
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2008-06-27 9:20 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 813 bytes --]
The ICE is a fallout of the changes made to support super-alignment of
standalone objects, which may break type consistency for constructors,
uncovered on IRIX(!) albeit generic. The fix is to work harder when
converting a constructor to a packable version of its type. However the
general fix would be quadratic in the number of elements of the constructor
and this doesn't seem worthwhile, so the attached fix assumes a simple layout
for constructors and punts otherwise.
2008-06-27 Eric Botcazou <ebotcazou@adacore.com>
* utils.c (convert) <CONSTRUCTOR>: When converting it to a packable
version of its type, attempt to first convert its elements.
2008-06-27 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/aggr9.ad[sb]: New test.
* gnat.dg/aggr9_pkg.ads: New helper.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 1984 bytes --]
Index: utils.c
===================================================================
--- utils.c (revision 137079)
+++ utils.c (working copy)
@@ -3579,17 +3579,47 @@ convert (tree type, tree expr)
case CONSTRUCTOR:
/* If we are converting a CONSTRUCTOR to a mere variant type, just make
- a new one in the proper type. Likewise for a conversion between
- original and packable version. */
- if (code == ecode
- && (gnat_types_compatible_p (type, etype)
- || (code == RECORD_TYPE
- && TYPE_NAME (type) == TYPE_NAME (etype))))
+ a new one in the proper type. */
+ if (code == ecode && gnat_types_compatible_p (type, etype))
{
expr = copy_node (expr);
TREE_TYPE (expr) = type;
return expr;
}
+
+ /* Likewise for a conversion between original and packable version, but
+ we have to work harder in order to preserve type consistency. */
+ if (code == ecode
+ && code == RECORD_TYPE
+ && TYPE_NAME (type) == TYPE_NAME (etype))
+ {
+ VEC(constructor_elt,gc) *e = CONSTRUCTOR_ELTS (expr);
+ unsigned HOST_WIDE_INT len = VEC_length (constructor_elt, e);
+ VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, len);
+ tree efield = TYPE_FIELDS (etype), field = TYPE_FIELDS (type);
+ unsigned HOST_WIDE_INT idx;
+ tree index, value;
+
+ FOR_EACH_CONSTRUCTOR_ELT(e, idx, index, value)
+ {
+ constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL);
+ /* We expect only simple constructors. Otherwise, punt. */
+ if (!(index == efield || index == DECL_ORIGINAL_FIELD (efield)))
+ break;
+ elt->index = field;
+ elt->value = convert (TREE_TYPE (field), value);
+ efield = TREE_CHAIN (efield);
+ field = TREE_CHAIN (field);
+ }
+
+ if (idx == len)
+ {
+ expr = copy_node (expr);
+ TREE_TYPE (expr) = type;
+ CONSTRUCTOR_ELTS (expr) = v;
+ return expr;
+ }
+ }
break;
case UNCONSTRAINED_ARRAY_REF:
[-- Attachment #3: aggr9.adb --]
[-- Type: text/x-adasrc, Size: 162 bytes --]
-- { dg-do compile }
-- { dg-options "-O" }
package body Aggr9 is
procedure Proc (X : R1) is
M : R2 := (F => X);
begin
Send (M);
end;
end Aggr9;
[-- Attachment #4: aggr9.ads --]
[-- Type: text/x-adasrc, Size: 89 bytes --]
with Aggr9_Pkg; use Aggr9_Pkg;
package Aggr9 is
procedure Proc (X : R1);
end Aggr9;
[-- Attachment #5: aggr9_pkg.ads --]
[-- Type: text/x-adasrc, Size: 231 bytes --]
package Aggr9_Pkg is
type Byte is range 0 .. 255;
type R1 is
record
A,B : Byte;
end record;
type R2 is
record
F : R1;
end record;
procedure Send (M : R2);
end Aggr9_Pkg;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Ada] Fix ICE in SRA pass at -O
2008-06-27 9:20 [Ada] Fix ICE in SRA pass at -O Eric Botcazou
@ 2008-06-27 10:08 ` Eric Botcazou
0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2008-06-27 10:08 UTC (permalink / raw)
To: gcc-patches
> 2008-06-27 Eric Botcazou <ebotcazou@adacore.com>
>
> * utils.c (convert) <CONSTRUCTOR>: When converting it to a packable
> version of its type, attempt to first convert its elements.
I forgot "Tested on i586-suse-linux and applied on the mainline."
--
Eric Botcazou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-27 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27 9:20 [Ada] Fix ICE in SRA pass at -O Eric Botcazou
2008-06-27 10:08 ` Eric Botcazou
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).