diff mbox

[PR,46351] Do not SRA types with aggregate bit-fields

Message ID 20101109172340.GA16780@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor Nov. 9, 2010, 5:23 p.m. UTC
Hi,

our current way of dealing with bit fields cannot possibly handle
aggregate ones, so this patch removes variables which contain them
from the SRA candidates.

Bootstrapped and tested on x86-64-linux.  The c94008d acats test
failed with it so I am going to re-test to figure out whether it is
one of those spurious acats failures or not.  OK if it passes?

Thanks,

Martin


2010-11-09  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/46351
	PR tree-optimization/46377
	* tree-sra.c (type_internals_preclude_sra_p): Disqualify types with
	aggregate bit-fields.

	* testsuite/gnat.dg/opt10.adb: New file.
	* testsuite/gnat.dg/opt10_pkg.ads: Likewise.
	* testsuite/gnat.dg/opt11.adb: Likewise.
	* testsuite/gnat.dg/opt11.ads: Likewise.

Comments

Eric Botcazou Nov. 9, 2010, 9:29 p.m. UTC | #1
> Bootstrapped and tested on x86-64-linux.  The c94008d acats test
> failed with it so I am going to re-test to figure out whether it is
> one of those spurious acats failures or not.  OK if it passes?

Thanks for looking into this.  If the c94008d failure is real but not directly 
related to your patch, go ahead, I'll take care of it.
Richard Biener Nov. 10, 2010, 10:44 a.m. UTC | #2
On Tue, Nov 9, 2010 at 6:23 PM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> our current way of dealing with bit fields cannot possibly handle
> aggregate ones, so this patch removes variables which contain them
> from the SRA candidates.
>
> Bootstrapped and tested on x86-64-linux.  The c94008d acats test
> failed with it so I am going to re-test to figure out whether it is
> one of those spurious acats failures or not.  OK if it passes?

Ok.

Thanks,
Richard.

> Thanks,
>
> Martin
>
>
> 2010-11-09  Martin Jambor  <mjambor@suse.cz>
>
>        PR tree-optimization/46351
>        PR tree-optimization/46377
>        * tree-sra.c (type_internals_preclude_sra_p): Disqualify types with
>        aggregate bit-fields.
>
>        * testsuite/gnat.dg/opt10.adb: New file.
>        * testsuite/gnat.dg/opt10_pkg.ads: Likewise.
>        * testsuite/gnat.dg/opt11.adb: Likewise.
>        * testsuite/gnat.dg/opt11.ads: Likewise.
>
>
> Index: mine/gcc/tree-sra.c
> ===================================================================
> --- mine.orig/gcc/tree-sra.c
> +++ mine/gcc/tree-sra.c
> @@ -653,7 +653,8 @@ type_internals_preclude_sra_p (tree type
>            if (TREE_THIS_VOLATILE (fld)
>                || !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld)
>                || !host_integerp (DECL_FIELD_OFFSET (fld), 1)
> -               || !host_integerp (DECL_SIZE (fld), 1))
> +               || !host_integerp (DECL_SIZE (fld), 1)
> +               || (DECL_BIT_FIELD (fld) && AGGREGATE_TYPE_P (ft)))
>              return true;
>
>            if (AGGREGATE_TYPE_P (ft)
> Index: mine/gcc/testsuite/gnat.dg/opt10.adb
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gnat.dg/opt10.adb
> @@ -0,0 +1,26 @@
> +-- { dg-do compile }
> +-- { dg-options "-O2 }
> +
> +with Opt10_Pkg; use Opt10_Pkg;
> +
> +procedure Opt10 is
> +
> +   procedure Compare_Rep_Data (MA, MB : Rep_Message) is
> +   begin
> +      if MA.Data /= MB.Data then
> +         raise Program_Error;
> +      end if;
> +   end;
> +
> +   procedure Check_Rep_For (Bit : Boolean) is
> +      MA, MB : Rep_Message;
> +   begin
> +      Safe_Assign (MA, Bit);
> +      Safe_Assign (MB, Bit);
> +      Compare_Rep_Data (MA, MB);
> +   end;
> +
> +begin
> +   Check_Rep_For (Bit => False);
> +end;
> +
> Index: mine/gcc/testsuite/gnat.dg/opt10_pkg.ads
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gnat.dg/opt10_pkg.ads
> @@ -0,0 +1,14 @@
> +package Opt10_Pkg is
> +
> +   type Rep_Message is record
> +      Bit : Boolean;
> +      Data : String (1 .. 4);
> +   end record;
> +   for Rep_Message use record
> +      Bit  at 0 range 0 .. 0;
> +      Data at 0 range 1 .. 32;
> +   end record;
> +
> +   procedure Safe_Assign (M : in out Rep_Message; Bit : Boolean);
> +
> +end;
> Index: mine/gcc/testsuite/gnat.dg/opt11.adb
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gnat.dg/opt11.adb
> @@ -0,0 +1,12 @@
> +-- { dg-compile }
> +-- { dg-options "-O" }
> +
> +package body Opt11 is
> +
> +   procedure Proc is
> +      R : Rec;
> +   begin
> +      R := (others => <>);
> +   end;
> +
> +end Opt11;
> Index: mine/gcc/testsuite/gnat.dg/opt11.ads
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gnat.dg/opt11.ads
> @@ -0,0 +1,17 @@
> +package Opt11 is
> +
> +   type String_Ptr is access constant String;
> +
> +   type Form_Type is (Qualified, Unqualified);
> +
> +   type Rec is record
> +      N1, N2, N3 : Natural;
> +      Fixed : String_Ptr;
> +      Form : Form_Type;
> +      Is_Local : Boolean := True;
> +   end record;
> +   pragma Pack (Rec);
> +
> +   procedure Proc;
> +
> +end Opt11;
>
>
Eric Botcazou Nov. 10, 2010, 1:50 p.m. UTC | #3
> 	* testsuite/gnat.dg/opt10.adb: New file.

I've fixed the typo in the dg-options line.
diff mbox

Patch

Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -653,7 +653,8 @@  type_internals_preclude_sra_p (tree type
 	    if (TREE_THIS_VOLATILE (fld)
 		|| !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld)
 		|| !host_integerp (DECL_FIELD_OFFSET (fld), 1)
-		|| !host_integerp (DECL_SIZE (fld), 1))
+		|| !host_integerp (DECL_SIZE (fld), 1)
+		|| (DECL_BIT_FIELD (fld) && AGGREGATE_TYPE_P (ft)))
 	      return true;
 
 	    if (AGGREGATE_TYPE_P (ft)
Index: mine/gcc/testsuite/gnat.dg/opt10.adb
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gnat.dg/opt10.adb
@@ -0,0 +1,26 @@ 
+-- { dg-do compile }
+-- { dg-options "-O2 }
+
+with Opt10_Pkg; use Opt10_Pkg;
+
+procedure Opt10 is
+
+   procedure Compare_Rep_Data (MA, MB : Rep_Message) is
+   begin
+      if MA.Data /= MB.Data then
+         raise Program_Error;
+      end if;
+   end;
+
+   procedure Check_Rep_For (Bit : Boolean) is
+      MA, MB : Rep_Message;
+   begin
+      Safe_Assign (MA, Bit);
+      Safe_Assign (MB, Bit);
+      Compare_Rep_Data (MA, MB);
+   end;
+
+begin
+   Check_Rep_For (Bit => False);
+end;
+
Index: mine/gcc/testsuite/gnat.dg/opt10_pkg.ads
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gnat.dg/opt10_pkg.ads
@@ -0,0 +1,14 @@ 
+package Opt10_Pkg is
+
+   type Rep_Message is record
+      Bit : Boolean;
+      Data : String (1 .. 4);
+   end record;
+   for Rep_Message use record
+      Bit  at 0 range 0 .. 0;
+      Data at 0 range 1 .. 32;
+   end record;
+
+   procedure Safe_Assign (M : in out Rep_Message; Bit : Boolean);
+
+end;
Index: mine/gcc/testsuite/gnat.dg/opt11.adb
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gnat.dg/opt11.adb
@@ -0,0 +1,12 @@ 
+-- { dg-compile }
+-- { dg-options "-O" }
+
+package body Opt11 is
+
+   procedure Proc is
+      R : Rec;
+   begin
+      R := (others => <>);
+   end;
+
+end Opt11;
Index: mine/gcc/testsuite/gnat.dg/opt11.ads
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gnat.dg/opt11.ads
@@ -0,0 +1,17 @@ 
+package Opt11 is
+
+   type String_Ptr is access constant String;
+
+   type Form_Type is (Qualified, Unqualified);
+
+   type Rec is record
+      N1, N2, N3 : Natural;
+      Fixed : String_Ptr;
+      Form : Form_Type;
+      Is_Local : Boolean := True;
+   end record;
+   pragma Pack (Rec);
+
+   procedure Proc;
+
+end Opt11;