public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* patch to fix PR82353
@ 2017-10-11 19:51 Vladimir Makarov
  2017-10-11 21:17 ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Makarov @ 2017-10-11 19:51 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82353

LRA did not update hard reg liveness on bb borders for hard regs which 
are part of insn patterns like CFLAGS reg.  It was ok for inheritance in 
EBB which creates only moves and they usually have no embedded hard regs 
in the patterns.  But LRA rematerialization needs this.  So this patch 
implements such hard reg liveness updates.

The patch was successfully bootstrapped and tested on x86-64.

Committed as rev. 253656.



[-- Attachment #2: pr82353.patch --]
[-- Type: text/x-patch, Size: 5948 bytes --]

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 253655)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2017-10-11  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR sanitizer/82353
+	* lra.c (collect_non_operand_hard_regs): Don't ignore operator
+	locations.
+	* lra-lives.c (bb_killed_pseudos, bb_gen_pseudos): Move up.
+	(make_hard_regno_born, make_hard_regno_dead): Update
+	bb_killed_pseudos and bb_gen_pseudos.
+
 2017-10-11  Nathan Sidwell  <nathan@acm.org>
 
 	* incpath.h (enum incpath_kind): Name enum, prefix values.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 253655)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2017-10-11  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR sanitizer/82353
+	* gcc.target/i386/i386.exp (tests): Permit '.C' extension.
+	* gcc.target/i386/pr82353.C: New.
+
 2017-10-11  Uros Bizjak  <ubizjak@gmail.com>
 
 	* gcc.target/i386/387-ficom-1.c: New test.
Index: lra-lives.c
===================================================================
--- lra-lives.c	(revision 253253)
+++ lra-lives.c	(working copy)
@@ -220,6 +220,9 @@ lra_intersected_live_ranges_p (lra_live_
   return false;
 }
 
+/* The corresponding bitmaps of BB currently being processed.  */
+static bitmap bb_killed_pseudos, bb_gen_pseudos;
+
 /* The function processing birth of hard register REGNO.  It updates
    living hard regs, START_LIVING, and conflict hard regs for living
    pseudos.  Conflict hard regs for the pic pseudo is not updated if
@@ -243,6 +246,7 @@ make_hard_regno_born (int regno, bool ch
 	|| i != REGNO (pic_offset_table_rtx))
 #endif
       SET_HARD_REG_BIT (lra_reg_info[i].conflict_hard_regs, regno);
+  bitmap_set_bit (bb_gen_pseudos, regno);
 }
 
 /* Process the death of hard register REGNO.  This updates
@@ -255,6 +259,8 @@ make_hard_regno_dead (int regno)
     return;
   sparseset_set_bit (start_dying, regno);
   CLEAR_HARD_REG_BIT (hard_regs_live, regno);
+  bitmap_clear_bit (bb_gen_pseudos, regno);
+  bitmap_set_bit (bb_killed_pseudos, regno);
 }
 
 /* Mark pseudo REGNO as living at program point POINT, update conflicting
@@ -299,9 +305,6 @@ mark_pseudo_dead (int regno, int point)
     }
 }
 
-/* The corresponding bitmaps of BB currently being processed.  */
-static bitmap bb_killed_pseudos, bb_gen_pseudos;
-
 /* Mark register REGNO (pseudo or hard register) in MODE as live at
    program point POINT.  Update BB_GEN_PSEUDOS.
    Return TRUE if the liveness tracking sets were modified, or FALSE
Index: lra.c
===================================================================
--- lra.c	(revision 253253)
+++ lra.c	(working copy)
@@ -820,7 +820,8 @@ collect_non_operand_hard_regs (rtx *x, l
   const char *fmt = GET_RTX_FORMAT (code);
 
   for (i = 0; i < data->insn_static_data->n_operands; i++)
-    if (x == data->operand_loc[i])
+    if (! data->insn_static_data->operand[i].is_operator
+	&& x == data->operand_loc[i])
       /* It is an operand loc. Stop here.  */
       return list;
   for (i = 0; i < data->insn_static_data->n_dups; i++)
Index: testsuite/gcc.target/i386/i386.exp
===================================================================
--- testsuite/gcc.target/i386/i386.exp	(revision 253253)
+++ testsuite/gcc.target/i386/i386.exp	(working copy)
@@ -445,7 +445,7 @@ if [runtest_file_p $runtests $srcdir/$su
 }
 
 # Everything else.
-set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]]
 set tests [prune $tests $srcdir/$subdir/vect-args.c]
 
 # Main loop.
Index: testsuite/gcc.target/i386/pr82353.C
===================================================================
--- testsuite/gcc.target/i386/pr82353.C	(nonexistent)
+++ testsuite/gcc.target/i386/pr82353.C	(working copy)
@@ -0,0 +1,60 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=c++11 -fsanitize=undefined -fno-sanitize-recover=undefined -w -fdump-rtl-reload" } */
+
+extern unsigned long tf_2_var_1, tf_2_var_21;
+extern bool tf_2_var_2, tf_2_var_24, tf_2_var_6, tf_2_var_5;
+extern unsigned char tf_2_var_16, tf_2_var_31;
+extern short tf_2_var_69;
+extern unsigned tf_2_var_233;
+struct tf_2_struct_1 {
+  short member_1_0 : 27;
+  long member_1_1 : 10;
+};
+struct a {
+  int member_2_0 : 5;
+};
+struct tf_2_struct_3 {
+  static tf_2_struct_1 member_3_0;
+};
+struct tf_2_struct_4 {
+  static unsigned member_4_0;
+  a member_4_1;
+};
+struct tf_2_struct_5 {
+  tf_2_struct_1 member_5_2;
+  tf_2_struct_4 member_5_4;
+};
+struct tf_2_struct_6 {
+  tf_2_struct_5 member_6_2;
+  short member_6_4;
+} extern tf_2_struct_obj_2;
+extern tf_2_struct_3 tf_2_struct_obj_8;
+tf_2_struct_1 a;
+tf_2_struct_5 b;
+tf_2_struct_1 tf_2_struct_3::member_3_0;
+unsigned tf_2_struct_4::member_4_0;
+void tf_2_init() {
+  a.member_1_1 = tf_2_struct_obj_2.member_6_2.member_5_2.member_1_1 = 5;
+}
+void tf_2_foo() {
+  int c = tf_2_struct_obj_2.member_6_2.member_5_4.member_4_1.member_2_0 -
+          -~tf_2_struct_obj_2.member_6_4 * char(90284000534361);
+  tf_2_struct_obj_8.member_3_0.member_1_0 =
+      tf_2_var_24 >
+      tf_2_var_21 * a.member_1_0 * tf_2_var_2 - tf_2_var_5 % a.member_1_1;
+  if ((~(tf_2_var_31 * tf_2_var_6) &&
+       -~tf_2_struct_obj_2.member_6_4 * 90284000534361) %
+      ~tf_2_var_31 * tf_2_var_6)
+    b.member_5_2.member_1_0 << tf_2_var_16 << tf_2_var_1;
+  tf_2_var_233 = -~tf_2_struct_obj_2.member_6_4 * char(90284000534361);
+  int d(tf_2_struct_obj_2.member_6_4);
+  if (b.member_5_2.member_1_0)
+    b.member_5_2.member_1_1 = c;
+  bool e(~-~tf_2_struct_obj_2.member_6_4);
+  a.member_1_1 % e;
+  if (tf_2_var_5 / tf_2_struct_obj_2.member_6_2.member_5_2.member_1_1)
+    b.member_5_4.member_4_0 = tf_2_var_21 * a.member_1_0 * tf_2_var_2;
+  tf_2_var_69 = tf_2_var_6;
+}
+
+/* { dg-final { scan-rtl-dump-not "Inserting rematerialization insn" "reload" } } */

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: patch to fix PR82353
@ 2017-10-12 11:38 Uros Bizjak
  0 siblings, 0 replies; 11+ messages in thread
From: Uros Bizjak @ 2017-10-12 11:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: Vladimir Makarov, Jakub Jelinek

Hello!

> The following patch fixes
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82353
>
> LRA did not update hard reg liveness on bb borders for hard regs which are part of insn patterns
> like CFLAGS reg. It was ok for inheritance in EBB which creates only moves and they usually
> have no embedded hard regs in the patterns. But LRA rematerialization needs this. So this patch
> implements such hard reg liveness updates.
>
> The patch was successfully bootstrapped and tested on x86-64.
>
> Committed as rev. 253656.

It looks that this patch caused libgo build bootstrap failure on
x86_64-linux-gnu:

../../../git/gcc/libgo/go/cmd/go/internal/load/pkg.go:377:1: error:
this is the insn:
(insn 1134 2835 2611 195 (parallel [
            (set (reg:DI 492)
                (const_int 0 [0]))
            (set (reg/f:DI 1008 [orig:490 <retval> ] [490])
                (plus:DI (ashift:DI (reg:DI 492)
                        (const_int 3 [0x3]))
                    (reg/f:DI 1008 [orig:490 <retval> ] [490])))
            (set (reg/f:DI 1009 [880])
                (plus:DI (ashift:DI (reg:DI 492)
                        (const_int 3 [0x3]))
                    (reg/f:DI 1009 [880])))
            (set (mem:BLK (reg/f:DI 1008 [orig:490 <retval> ] [490])
[22 *_372+0 S1048 A64])
                (mem/c:BLK (reg/f:DI 1009 [880]) [22 GOTMP.492+0 S1048 A128]))
            (use (reg:DI 492))
        ]) "../../../git/gcc/libgo/go/cmd/go/internal/load/pkg.go":679
930 {*rep_movdi_rex64}
     (expr_list:REG_UNUSED (reg/f:DI 1009 [880])
        (expr_list:REG_UNUSED (reg/f:DI 1008 [orig:490 <retval> ] [490])
            (expr_list:REG_UNUSED (reg:DI 492)
                (expr_list:REG_EH_REGION (const_int 1 [0x1])
                    (nil))))))
during RTL pass: reload
../../../git/gcc/libgo/go/cmd/go/internal/load/pkg.go:377:1: internal
compiler error: in assign_by_spills, at lra-assigns.c:1468
0x6b2709 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../git/gcc/gcc/rtl-error.c:108
0xbe87fa assign_by_spills
        ../../git/gcc/gcc/lra-assigns.c:1468
0xbe94a6 lra_assign()
        ../../git/gcc/gcc/lra-assigns.c:1662
0xbe48d4 lra(_IO_FILE*)
        ../../git/gcc/gcc/lra.c:2450
0xb9ec51 do_reload
        ../../git/gcc/gcc/ira.c:5440
0xb9ec51 execute
        ../../git/gcc/gcc/ira.c:5624
Please submit a full bug report,

Uros.

^ permalink raw reply	[flat|nested] 11+ messages in thread
* patch to fix PR82353
@ 2017-10-16 20:39 Vladimir Makarov
  2017-12-13 12:35 ` Tom de Vries
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Makarov @ 2017-10-16 20:39 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

This is another version of the patch to fix

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82353

The patch was successfully bootstrapped on x86-64 with Go and Ada.

Committed as rev. 253796.



[-- Attachment #2: pr82353-2.patch --]
[-- Type: text/x-patch, Size: 2766 bytes --]

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 253795)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2017-10-16  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR sanitizer/82353
+	* lra.c (collect_non_operand_hard_regs): Don't ignore operator
+	locations.
+	* lra-lives.c (bb_killed_pseudos, bb_gen_pseudos): Move up.
+	(make_hard_regno_born, make_hard_regno_dead): Update
+	bb_killed_pseudos and bb_gen_pseudos for fixed regs.
+
 2017-10-16  Jeff Law  <law@redhat.com>
 
 	* tree-ssa-dse.c (live_bytes_read): Fix thinko.
Index: lra.c
===================================================================
--- lra.c	(revision 253685)
+++ lra.c	(working copy)
@@ -820,7 +820,8 @@ collect_non_operand_hard_regs (rtx *x, l
   const char *fmt = GET_RTX_FORMAT (code);
 
   for (i = 0; i < data->insn_static_data->n_operands; i++)
-    if (x == data->operand_loc[i])
+    if (! data->insn_static_data->operand[i].is_operator
+	&& x == data->operand_loc[i])
       /* It is an operand loc. Stop here.  */
       return list;
   for (i = 0; i < data->insn_static_data->n_dups; i++)
Index: lra-lives.c
===================================================================
--- lra-lives.c	(revision 253685)
+++ lra-lives.c	(working copy)
@@ -220,6 +220,9 @@ lra_intersected_live_ranges_p (lra_live_
   return false;
 }
 
+/* The corresponding bitmaps of BB currently being processed.  */
+static bitmap bb_killed_pseudos, bb_gen_pseudos;
+
 /* The function processing birth of hard register REGNO.  It updates
    living hard regs, START_LIVING, and conflict hard regs for living
    pseudos.  Conflict hard regs for the pic pseudo is not updated if
@@ -243,6 +246,8 @@ make_hard_regno_born (int regno, bool ch
 	|| i != REGNO (pic_offset_table_rtx))
 #endif
       SET_HARD_REG_BIT (lra_reg_info[i].conflict_hard_regs, regno);
+  if (fixed_regs[regno])
+    bitmap_set_bit (bb_gen_pseudos, regno);
 }
 
 /* Process the death of hard register REGNO.  This updates
@@ -255,6 +260,11 @@ make_hard_regno_dead (int regno)
     return;
   sparseset_set_bit (start_dying, regno);
   CLEAR_HARD_REG_BIT (hard_regs_live, regno);
+  if (fixed_regs[regno])
+    {
+      bitmap_clear_bit (bb_gen_pseudos, regno);
+      bitmap_set_bit (bb_killed_pseudos, regno);
+    }
 }
 
 /* Mark pseudo REGNO as living at program point POINT, update conflicting
@@ -299,9 +309,6 @@ mark_pseudo_dead (int regno, int point)
     }
 }
 
-/* The corresponding bitmaps of BB currently being processed.  */
-static bitmap bb_killed_pseudos, bb_gen_pseudos;
-
 /* Mark register REGNO (pseudo or hard register) in MODE as live at
    program point POINT.  Update BB_GEN_PSEUDOS.
    Return TRUE if the liveness tracking sets were modified, or FALSE

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-12-14 17:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11 19:51 patch to fix PR82353 Vladimir Makarov
2017-10-11 21:17 ` Jakub Jelinek
2017-10-11 22:54   ` Vladimir Makarov
2017-10-12 17:05     ` Jakub Jelinek
2017-10-12 17:11       ` Vladimir Makarov
2017-10-12 17:34         ` Jakub Jelinek
2017-10-13 18:49       ` Jeff Law
2017-10-12 11:38 Uros Bizjak
2017-10-16 20:39 Vladimir Makarov
2017-12-13 12:35 ` Tom de Vries
2017-12-14 17:01   ` Vladimir Makarov

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).