This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gcc-5-branch][PATCH] PR rtl-optimization/67029: gcc-5.2.0 unable to find a register to spill with O3 fsched-pressure fschedule-insns
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Sandiford <richard dot sandiford at arm dot com>, Richard Sandiford <rdsandiford at googlemail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 7 Aug 2015 12:38:26 -0700
- Subject: [gcc-5-branch][PATCH] PR rtl-optimization/67029: gcc-5.2.0 unable to find a register to spill with O3 fsched-pressure fschedule-insns
- Authentication-results: sourceware.org; auth=none
On Thu, Aug 6, 2015 at 11:19 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> "H.J. Lu" <hongjiu.lu@intel.com> writes:
>> Since ira_implicitly_set_insn_hard_regs may be called outside of
>> ira-lives.c, it can't use the local variable, preferred_alternatives.
>> This patch adds an alternative_mask argument to
>> ira_implicitly_set_insn_hard_regs.
>>
>> OK for master and 5 branch if there are no regressions on Linux/x86-64?
>
> Thanks for working on this. The patch looks good to me FWIW.
>
> I think this version is safer than the second one you posted. With that
> version we could end up with the same sort of bug, e.g. because a function
> passes false to extract_insn without realising that one of the functions
> that it calls later needs the preferred alternatives to be set.
> Or maybe (as with my patch) a function starts to use preferred_alternatives
> and one of its callers gets missed.
>
> Sorry for the breakage.
>
> Thanks,
> Richard
>
>> H.J.
>> ---
>> gcc/
>>
>> PR rtl-optimization/67029
>> * ira-color.c: Include "recog.h" before including "ira-int.h".
>> * target-globals.c: Likewise.
>> * ira-lives.c (ira_implicitly_set_insn_hard_regs): Add an
>> adds an alternative_mask argument and use it instead of
>> preferred_alternatives.
>> * ira.h (ira_implicitly_set_insn_hard_regs): Moved to ...
>> * ira-int.h (ira_implicitly_set_insn_hard_regs): Here.
>> * sched-deps.c: Include "ira-int.h" after including "ira.h".
>> (sched_analyze_insn): Update call to
>> ira_implicitly_set_insn_hard_regs.
>> * sel-sched.c: Include "ira-int.h" after including "ira.h".
>> (implicit_clobber_conflict_p): Update call to
>> ira_implicitly_set_insn_hard_regs.
>>
>> gcc/testsuite/
>>
>> PR rtl-optimization/67029
>> * gcc.dg/pr67029.c: New test.
Here is the backport for gcc-5-branch. OK for gcc-5-branch?
H.J.
From dbc649165f365ee38f31d4dfef8744ee609277e6 Mon Sep 17 00:00:00 2001
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 7 Aug 2015 16:18:09 +0000
Subject: [PATCH] Add alternative_mask to ira_implicitly_set_insn_hard_regs
Since ira_implicitly_set_insn_hard_regs may be called outside of
ira-lives.c, it can't use the local variable, preferred_alternatives.
This patch adds an alternative_mask argument to
ira_implicitly_set_insn_hard_regs.
Backport from trunk:
gcc/
PR rtl-optimization/67029
* ira-color.c: Include "recog.h" before including "ira-int.h".
* target-globals.c: Likewise.
* ira-lives.c (ira_implicitly_set_insn_hard_regs): Add an
adds an alternative_mask argument and use it instead of
preferred_alternatives.
* ira.h (ira_implicitly_set_insn_hard_regs): Moved to ...
* ira-int.h (ira_implicitly_set_insn_hard_regs): Here.
* sched-deps.c: Include "ira-int.h" after including "ira.h".
(sched_analyze_insn): Update call to
ira_implicitly_set_insn_hard_regs.
* sel-sched.c: Include "ira-int.h" after including "ira.h".
(implicit_clobber_conflict_p): Update call to
ira_implicitly_set_insn_hard_regs.
gcc/testsuite/
PR rtl-optimization/67029
* gcc.dg/pr67029.c: New test.
---
gcc/ChangeLog | 20 ++++++++++++++++++++
gcc/ira-color.c | 1 +
gcc/ira-int.h | 2 ++
gcc/ira-lives.c | 4 ++--
gcc/ira.h | 1 -
gcc/sched-deps.c | 4 +++-
gcc/sel-sched.c | 4 +++-
gcc/target-globals.c | 1 +
gcc/testsuite/ChangeLog | 8 ++++++++
gcc/testsuite/gcc.dg/pr67029.c | 14 ++++++++++++++
10 files changed, 54 insertions(+), 5 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr67029.c
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 207b798..30932d9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,23 @@
+2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ Backport from trunk:
+ 2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR rtl-optimization/67029
+ * ira-color.c: Include "recog.h" before including "ira-int.h".
+ * target-globals.c: Likewise.
+ * ira-lives.c (ira_implicitly_set_insn_hard_regs): Add an
+ adds an alternative_mask argument and use it instead of
+ preferred_alternatives.
+ * ira.h (ira_implicitly_set_insn_hard_regs): Moved to ...
+ * ira-int.h (ira_implicitly_set_insn_hard_regs): Here.
+ * sched-deps.c: Include "ira-int.h" after including "ira.h".
+ (sched_analyze_insn): Update call to
+ ira_implicitly_set_insn_hard_regs.
+ * sel-sched.c: Include "ira-int.h" after including "ira.h".
+ (implicit_clobber_conflict_p): Update call to
+ ira_implicitly_set_insn_hard_regs.
+
2015-08-07 Kirill Yukhin <kirill.yukhin@intel.com>
* config/i386/i386.md (define_attr "isa"): Addd avx512vl and
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index ff1fe8a..e104f00 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see
#include "reload.h"
#include "params.h"
#include "df.h"
+#include "recog.h"
#include "ira-int.h"
typedef struct allocno_hard_regs *allocno_hard_regs_t;
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index c2853dc..c1c545c 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -1045,6 +1045,8 @@ extern void ira_debug_live_ranges (void);
extern void ira_create_allocno_live_ranges (void);
extern void ira_compress_allocno_live_ranges (void);
extern void ira_finish_allocno_live_ranges (void);
+extern void ira_implicitly_set_insn_hard_regs (HARD_REG_SET *,
+ alternative_mask);
/* ira-conflicts.c */
extern void ira_debug_conflicts (bool);
diff --git a/gcc/ira-lives.c b/gcc/ira-lives.c
index b29f572..81d3208 100644
--- a/gcc/ira-lives.c
+++ b/gcc/ira-lives.c
@@ -837,7 +837,8 @@ single_reg_operand_class (int op_num)
might be used by insn reloads because the constraints are too
strict. */
void
-ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set)
+ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set,
+ alternative_mask preferred)
{
int i, c, regno = 0;
enum reg_class cl;
@@ -860,7 +861,6 @@ ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set)
mode = (GET_CODE (op) == SCRATCH
? GET_MODE (op) : PSEUDO_REGNO_MODE (regno));
cl = NO_REGS;
- alternative_mask preferred = preferred_alternatives;
for (; (c = *p); p += CONSTRAINT_LEN (c, p))
if (c == '#')
preferred &= ~ALTERNATIVE_BIT (0);
diff --git a/gcc/ira.h b/gcc/ira.h
index 1979780..dca99e8 100644
--- a/gcc/ira.h
+++ b/gcc/ira.h
@@ -190,7 +190,6 @@ extern void ira_init (void);
extern void ira_setup_eliminable_regset (void);
extern rtx ira_eliminate_regs (rtx, machine_mode);
extern void ira_set_pseudo_classes (bool, FILE *);
-extern void ira_implicitly_set_insn_hard_regs (HARD_REG_SET *);
extern void ira_expand_reg_equiv (void);
extern void ira_update_equiv_info_by_shuffle_insn (int, int, rtx_insn *);
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 5434831..459a468 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see
#include "params.h"
#include "cselib.h"
#include "ira.h"
+#include "ira-int.h"
#include "target.h"
#ifdef INSN_SCHEDULING
@@ -2907,7 +2908,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
extract_insn (insn);
preprocess_constraints (insn);
- ira_implicitly_set_insn_hard_regs (&temp);
+ alternative_mask prefrred = get_preferred_alternatives (insn);
+ ira_implicitly_set_insn_hard_regs (&temp, prefrred);
AND_COMPL_HARD_REG_SET (temp, ira_no_alloc_regs);
IOR_HARD_REG_SET (implicit_reg_pending_clobbers, temp);
}
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 988f9d5..0a322a8 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "rtlhooks-def.h"
#include "emit-rtl.h"
#include "ira.h"
+#include "ira-int.h"
#include "rtl-iter.h"
#ifdef INSN_SCHEDULING
@@ -2124,7 +2125,8 @@ implicit_clobber_conflict_p (insn_t through_insn, expr_t expr)
/* Calculate implicit clobbers. */
extract_insn (insn);
preprocess_constraints (insn);
- ira_implicitly_set_insn_hard_regs (&temp);
+ alternative_mask prefrred = get_preferred_alternatives (insn);
+ ira_implicitly_set_insn_hard_regs (&temp, prefrred);
AND_COMPL_HARD_REG_SET (temp, ira_no_alloc_regs);
/* If any implicit clobber registers intersect with regular ones in
diff --git a/gcc/target-globals.c b/gcc/target-globals.c
index 6983b5c..8b6f3ab 100644
--- a/gcc/target-globals.c
+++ b/gcc/target-globals.c
@@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see
#include "optabs.h"
#include "libfuncs.h"
#include "cfgloop.h"
+#include "recog.h"
#include "ira-int.h"
#include "builtins.h"
#include "gcse.h"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d862db0..4ed3602 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ Backport from trunk:
+ 2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR rtl-optimization/67029
+ * gcc.dg/pr67029.c: New test.
+
2015-08-07 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/66929
diff --git a/gcc/testsuite/gcc.dg/pr67029.c b/gcc/testsuite/gcc.dg/pr67029.c
new file mode 100644
index 0000000..f0023e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr67029.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { int128 && scheduling } } } */
+/* { dg-options "-O2 -fschedule-insns" } */
+/* { dg-additional-options "-fstack-protector" { target fstack_protector } } */
+
+extern void fn2 (char *);
+__int128 a, b;
+int
+fn1 (void)
+{
+ char e[32];
+ fn2 (e);
+ b = 9 * (a >> 1);
+ return 0;
+}
--
2.4.3