From 892927b7762271038bf47dcaf0f4e39dbb7fdf24 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Fri, 27 Feb 2015 14:15:02 +0000 Subject: [PATCH] re PR target/65032 (ICE in reload_combine_note_use, at postreload.c:1556 on i686-linux-gnu) 2015-02-27 Vladimir Makarov PR target/65032 * lra-remat.c (update_scratch_ops): New. (do_remat): Call it. * lra.c (lra_register_new_scratch_op): New. Take code from ... (remove_scratches): ... here. * lra-int.h (lra_register_new_scratch_op): New prototype. 2015-02-27 Vladimir Makarov PR target/65032 * g++.dg/pr65032.C: New. From-SVN: r221062 --- gcc/ChangeLog | 9 ++++ gcc/lra-int.h | 1 + gcc/lra-remat.c | 24 ++++++++++ gcc/lra.c | 29 ++++++++---- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/pr65032.C | 87 ++++++++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr65032.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bee990ba1c6..439b42820dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-02-27 Vladimir Makarov + + PR target/65032 + * lra-remat.c (update_scratch_ops): New. + (do_remat): Call it. + * lra.c (lra_register_new_scratch_op): New. Take code from ... + (remove_scratches): ... here. + * lra-int.h (lra_register_new_scratch_op): New prototype. + 2015-02-27 Marek Polacek PR c/65040 diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 972030992ba..735259123d6 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -321,6 +321,7 @@ extern void lra_create_copy (int, int, int); extern lra_copy_t lra_get_copy (int); extern bool lra_former_scratch_p (int); extern bool lra_former_scratch_operand_p (rtx_insn *, int); +extern void lra_register_new_scratch_op (rtx_insn *, int); extern int lra_new_regno_start; extern int lra_constraint_new_regno_start; diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c index fb0eb3c1f7b..ac827795713 100644 --- a/gcc/lra-remat.c +++ b/gcc/lra-remat.c @@ -1044,6 +1044,29 @@ get_hard_regs (struct lra_insn_reg *reg, int &nregs) return hard_regno; } +/* Make copy of and register scratch pseudos in rematerialized insn + REMAT_INSN. */ +static void +update_scratch_ops (rtx_insn *remat_insn) +{ + lra_insn_recog_data_t id = lra_get_insn_recog_data (remat_insn); + struct lra_static_insn_data *static_id = id->insn_static_data; + for (int i = 0; i < static_id->n_operands; i++) + { + rtx *loc = id->operand_loc[i]; + if (! REG_P (*loc)) + continue; + int regno = REGNO (*loc); + if (! lra_former_scratch_p (regno)) + continue; + *loc = lra_create_new_reg (GET_MODE (*loc), *loc, + lra_get_allocno_class (regno), + "scratch pseudo copy"); + lra_register_new_scratch_op (remat_insn, i); + } + +} + /* Insert rematerialization insns using the data-flow data calculated earlier. */ static bool @@ -1193,6 +1216,7 @@ do_remat (void) HOST_WIDE_INT sp_offset_change = cand_sp_offset - id->sp_offset; if (sp_offset_change != 0) change_sp_offset (remat_insn, sp_offset_change); + update_scratch_ops (remat_insn); lra_process_new_insns (insn, remat_insn, NULL, "Inserting rematerialization insn"); lra_set_insn_deleted (insn); diff --git a/gcc/lra.c b/gcc/lra.c index abe0c334b32..727a70e0630 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -1907,6 +1907,24 @@ lra_former_scratch_operand_p (rtx_insn *insn, int nop) INSN_UID (insn) * MAX_RECOG_OPERANDS + nop) != 0; } +/* Register operand NOP in INSN as a former scratch. It will be + changed to scratch back, if it is necessary, at the LRA end. */ +void +lra_register_new_scratch_op (rtx_insn *insn, int nop) +{ + lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); + rtx op = *id->operand_loc[nop]; + sloc_t loc = XNEW (struct sloc); + lra_assert (REG_P (op)); + loc->insn = insn; + loc->nop = nop; + scratches.safe_push (loc); + bitmap_set_bit (&scratch_bitmap, REGNO (op)); + bitmap_set_bit (&scratch_operand_bitmap, + INSN_UID (insn) * MAX_RECOG_OPERANDS + nop); + add_reg_note (insn, REG_UNUSED, op); +} + /* Change scratches onto pseudos and save their location. */ static void remove_scratches (void) @@ -1916,7 +1934,6 @@ remove_scratches (void) basic_block bb; rtx_insn *insn; rtx reg; - sloc_t loc; lra_insn_recog_data_t id; struct lra_static_insn_data *static_id; @@ -1938,15 +1955,7 @@ remove_scratches (void) *id->operand_loc[i] = reg = lra_create_new_reg (static_id->operand[i].mode, *id->operand_loc[i], ALL_REGS, NULL); - add_reg_note (insn, REG_UNUSED, reg); - lra_update_dup (id, i); - loc = XNEW (struct sloc); - loc->insn = insn; - loc->nop = i; - scratches.safe_push (loc); - bitmap_set_bit (&scratch_bitmap, REGNO (*id->operand_loc[i])); - bitmap_set_bit (&scratch_operand_bitmap, - INSN_UID (insn) * MAX_RECOG_OPERANDS + i); + lra_register_new_scratch_op (insn, i); if (lra_dump_file != NULL) fprintf (lra_dump_file, "Removing SCRATCH in insn #%u (nop %d)\n", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 11139f977e5..fae312eb7bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-27 Vladimir Makarov + + PR target/65032 + * g++.dg/pr65032.C: New. + 2015-02-27 Marek Polacek PR c/65040 diff --git a/gcc/testsuite/g++.dg/pr65032.C b/gcc/testsuite/g++.dg/pr65032.C new file mode 100644 index 00000000000..a62f50b49bf --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65032.C @@ -0,0 +1,87 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-Os -std=c++11 -fPIC -fstack-protector-strong -fomit-frame-pointer" } + +#pragma GCC visibility push(hidden) +#pragma GCC visibility push(default) +extern "C" { + typedef int int64_t __attribute__ ((__mode__ (__DI__))); +} +enum class nsresult; +#pragma GCC visibility pop +class A +{ + float mRawPtr; + + public: + A (float *); +}; +class B +{ + public: + B (int64_t, int, int); +}; +typedef struct +{ + int channels; +} vorbis_info; +template class C +{ + public: + typedef int size_type; + size_type erase (_Key &); +}; + +template class D +{ + public: + typedef _Key key_type; + typedef C _Rep_type; + _Rep_type _M_t; + typename _Rep_type::size_type + erase (key_type p1) + { + return _M_t.erase (p1); + } +}; + +class F +{ + public: + vorbis_info mInfo; + D mVorbisPacketSamples; + void ValidateVorbisPacketSamples (int *); + int64_t Time (int64_t); +}; +class G +{ + nsresult DecodeVorbis (int *); + F *mVorbisState; + int64_t mDecodedAudioFrames; +}; +int fn1 (float ***); +void fn2 (int); +void +F::ValidateVorbisPacketSamples (int *p1) +{ + mVorbisPacketSamples.erase (p1); +} + +nsresult +G::DecodeVorbis (int *p1) +{ + float **a; + int b; + long long c; + while ((b = fn1 (&a))) + { + mVorbisState->ValidateVorbisPacketSamples (p1); + A (new float); + for (; mVorbisState->mInfo.channels;) + { + } + int64_t d = mVorbisState->Time (c - b); + (B (d, b, mVorbisState->mInfo.channels)); + mDecodedAudioFrames -= b; + fn2 (b); + } +} -- 2.30.2