This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix wrong type merging in LTO compiler
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 May 2010 17:52:04 +0200
- Subject: [patch] Fix wrong type merging in LTO compiler
Hi,
this problem is responsible for the remaining gnat.dg failures with -flto on
x86-64 (but probably shows up more frequently on strict-alignment platforms):
the LTO compiler wrongly merges record types with different alignments.
Tested on x86_64-suse-linux, OK for mainline?
2010-05-26 Eric Botcazou <ebotcazou@adacore.com>
* gimple.c (gimple_types_compatible_p) <RECORD_TYPE>: Return false if
the types have different alignment.
2010-05-26 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/lto10.adb:New test.
* gnat.dg/lto10_pkg.ads: New helper.
--
Eric Botcazou
Index: gimple.c
===================================================================
--- gimple.c (revision 159855)
+++ gimple.c (working copy)
@@ -3585,6 +3585,10 @@ gimple_types_compatible_p (tree t1, tree
{
tree f1, f2;
+ /* Can't be the same type if they have different alignment. */
+ if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2))
+ goto different_types;
+
/* If one type requires structural equality checks and the
other doesn't, do not merge the types. */
if (TYPE_STRUCTURAL_EQUALITY_P (t1)
-- { dg-do run }
-- { dg-options "-flto" { target lto } }
with Lto10_Pkg; use Lto10_Pkg;
procedure Lto10 is
A : Integer := Minus_One;
Pos : Position;
begin
Pos := Pix.Pos;
if A /= Minus_One then
raise Program_Error;
end if;
end;
package Lto10_Pkg is
type U16 is mod 2 ** 16;
type Position is record
X, Y, Z : U16;
end record;
for Position'Size use 48;
type Pixel is record
Pos : Position;
end record;
pragma Pack (Pixel);
Minus_One : Integer := -1;
Pix : Pixel := (Pos => (X => 0, Y => 0, Z => 0));
end Lto10_Pkg;