# DP: updates from the 4.8 branch upto 20140606 (r211339). last_updated() { cat > ${dir}LAST_UPDATED < __res, bool __ignore_failure = false) { - bool __set = __ignore_failure; + bool __set = false; // all calls to this function are serialized, // side-effects of invoking __res only happen once call_once(_M_once, &_State_base::_M_do_set, this, ref(__res), ref(__set)); - if (!__set) + if (__set) + _M_cond.notify_all(); + else if (!__ignore_failure) __throw_future_error(int(future_errc::promise_already_satisfied)); } @@ -471,7 +473,6 @@ lock_guard __lock(_M_mutex); _M_result.swap(__res); } - _M_cond.notify_all(); __set = true; } @@ -983,22 +984,25 @@ void set_value(const _Res& __r) { + auto __future = _M_future; auto __setter = _State::__setter(this, __r); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } void set_value(_Res&& __r) { + auto __future = _M_future; auto __setter = _State::__setter(this, std::move(__r)); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } void set_exception(exception_ptr __p) { + auto __future = _M_future; auto __setter = _State::__setter(__p, this); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } }; @@ -1081,15 +1085,17 @@ void set_value(_Res& __r) { + auto __future = _M_future; auto __setter = _State::__setter(this, __r); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } void set_exception(exception_ptr __p) { + auto __future = _M_future; auto __setter = _State::__setter(__p, this); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } }; @@ -1166,8 +1172,9 @@ void set_exception(exception_ptr __p) { + auto __future = _M_future; auto __setter = _State::__setter(__p, this); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } }; @@ -1193,8 +1200,9 @@ inline void promise::set_value() { + auto __future = _M_future; auto __setter = _State::__setter(this); - _M_future->_M_set_result(std::move(__setter)); + __future->_M_set_result(std::move(__setter)); } Index: libstdc++-v3/include/bits/stl_tree.h =================================================================== --- a/src/libstdc++-v3/include/bits/stl_tree.h (.../tags/gcc_4_8_3_release) +++ b/src/libstdc++-v3/include/bits/stl_tree.h (.../branches/gcc-4_8-branch) @@ -510,11 +510,11 @@ _Link_type _M_end() - { return static_cast<_Link_type>(&this->_M_impl._M_header); } + { return reinterpret_cast<_Link_type>(&this->_M_impl._M_header); } _Const_Link_type _M_end() const - { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); } + { return reinterpret_cast<_Const_Link_type>(&this->_M_impl._M_header); } static const_reference _S_value(_Const_Link_type __x) Index: libstdc++-v3/include/tr2/bool_set =================================================================== --- a/src/libstdc++-v3/include/tr2/bool_set (.../tags/gcc_4_8_3_release) +++ b/src/libstdc++-v3/include/tr2/bool_set (.../branches/gcc-4_8-branch) @@ -44,7 +44,7 @@ * bool_set * * See N2136, Bool_set: multi-valued logic - * by Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion. + * by HervĂ© Brönnimann, Guillaume Melquiond, Sylvain Pion. * * The implicit conversion to bool is slippery! I may use the new * explicit conversion. This has been specialized in the language Index: libstdc++-v3/ChangeLog =================================================================== --- a/src/libstdc++-v3/ChangeLog (.../tags/gcc_4_8_3_release) +++ b/src/libstdc++-v3/ChangeLog (.../branches/gcc-4_8-branch) @@ -1,3 +1,27 @@ +2014-06-03 Jonathan Wakely + + Backport from mainline + 2014-04-15 Jonathan Wakely + + PR libstdc++/60734 + * include/bits/stl_tree.h (_Rb_tree::_M_end): Fix invalid cast. + + Backport from mainline + 2014-05-16 Jonathan Wakely + + PR libstdc++/60966 + * include/std/future (__future_base::_State_baseV2::_M_set_result): + Signal condition variable after call_once returns. + (__future_base::_State_baseV2::_M_do_set): Do not signal here. + (promise::set_value, promise::set_exception): Increment the reference + count on the shared state until the function returns. + * testsuite/30_threads/promise/60966.cc: New. + +2014-05-29 Jonathan Wakely + + * include/tr2/bool_set: Use UTF-8 for accented characters. + * scripts/run_doxygen: Handle Doxygen 1.8.x change. + 2014-05-22 Release Manager * GCC 4.8.3 released. Index: libstdc++-v3/testsuite/30_threads/promise/60966.cc =================================================================== --- a/src/libstdc++-v3/testsuite/30_threads/promise/60966.cc (.../tags/gcc_4_8_3_release) +++ b/src/libstdc++-v3/testsuite/30_threads/promise/60966.cc (.../branches/gcc-4_8-branch) @@ -0,0 +1,67 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// libstdc++/60966 +// This test hangs if std::promise::~promise() destroys the +// shared state before std::promise::set_value() finishes using it. + +#include +#include +#include + +const int THREADS = 10; + +void run_task(std::promise* pr) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + pr->set_value(); +} + +int main() +{ + std::vector*> tasks(THREADS); + std::vector threads(THREADS); + std::vector> futures(THREADS); + + for (int i = 0; i < THREADS; ++i) + { + std::promise* task = new std::promise; + tasks[i] = task; + futures[i] = task->get_future(); + threads[i] = std::thread(run_task, task); + } + + for (int i = 0; i < THREADS; ++i) + { + // the temporary future releases the state as soon as wait() returns + std::future(std::move(futures[i])).wait(); + // state is ready, should now be safe to delete promise, so it + // releases the shared state too + delete tasks[i]; + } + + for (auto& t : threads) + t.join(); +} Index: gcc/DATESTAMP =================================================================== --- a/src/gcc/DATESTAMP (.../tags/gcc_4_8_3_release) +++ b/src/gcc/DATESTAMP (.../branches/gcc-4_8-branch) @@ -1 +1 @@ -20140522 +20140607 Index: gcc/ipa-cp.c =================================================================== --- a/src/gcc/ipa-cp.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/ipa-cp.c (.../branches/gcc-4_8-branch) @@ -447,6 +447,8 @@ else if (!opt_for_fn (node->symbol.decl, optimize) || !opt_for_fn (node->symbol.decl, flag_ipa_cp)) reason = "non-optimized function"; + else if (node->tm_clone) + reason = "transactional memory clone"; if (reason && dump_file && !node->alias && !node->thunk.thunk_p) fprintf (dump_file, "Function %s/%i is not versionable, reason: %s.\n", Index: gcc/ChangeLog =================================================================== --- a/src/gcc/ChangeLog (.../tags/gcc_4_8_3_release) +++ b/src/gcc/ChangeLog (.../branches/gcc-4_8-branch) @@ -1,3 +1,114 @@ +2014-06-06 Michael Meissner + + Back port from trunk + 2014-06-06 Michael Meissner + + PR target/61431 + * config/rs6000/vsx.md (VSX_LE): Split VSX_D into 2 separate + iterators, VSX_D that handles 64-bit types, and VSX_LE that + handles swapping the two 64-bit double words on little endian + systems. Include V1TImode and optionally TImode in VSX_LE so that + these types are properly swapped. Change all of the insns and + splits that do the 64-bit swaps to use VSX_LE. + (vsx_le_perm_load_): Likewise. + (vsx_le_perm_store_): Likewise. + (splitters for little endian memory operations): Likewise. + (vsx_xxpermdi2_le_): Likewise. + (vsx_lxvd2x2_le_): Likewise. + (vsx_stxvd2x2_le_): Likewise. + +2014-06-05 Martin Jambor + + PR ipa/61393 + * ipa-cp.c (determine_versionability): Pretend that tm_clones are + not versionable. + +2014-06-04 Richard Biener + + PR tree-optimization/61383 + * tree-ssa-ifcombine.c (bb_no_side_effects_p): Make sure + stmts can't trap. + +2014-06-03 Andrey Belevantsev + + Backport from mainline + 2014-05-14 Andrey Belevantsev + + PR rtl-optimization/60866 + * sel-sched-ir (sel_init_new_insn): New parameter old_seqno. + Default it to -1. Pass it down to init_simplejump_data. + (init_simplejump_data): New parameter old_seqno. Pass it down + to get_seqno_for_a_jump. + (get_seqno_for_a_jump): New parameter old_seqno. Use it for + initializing new jump seqno as a last resort. Add comment. + (sel_redirect_edge_and_branch): Save old seqno of the conditional + jump and pass it down to sel_init_new_insn. + (sel_redirect_edge_and_branch_force): Likewise. + +2014-06-03 Andrey Belevantsev + + Backport from mainline + 2014-05-14 Andrey Belevantsev + + PR rtl-optimization/60901 + * config/i386/i386.c (ix86_dependencies_evaluation_hook): Check that + bb predecessor belongs to the same scheduling region. Adjust comment. + +2014-06-03 Uros Bizjak + + Backport from mainline + 2014-06-02 Uros Bizjak + + PR target/61239 + * config/i386/i386.c (ix86_expand_vec_perm) [case V32QImode]: Use + GEN_INT (-128) instead of GEN_INT (128) to set MSB of QImode constant. + +2014-05-28 Guozhi Wei + + PR target/61202 + * config/aarch64/arm_neon.h (vqdmulh_n_s16): Change the last operand's + constraint. + (vqdmulhq_n_s16): Likewise. + +2014-05-28 Eric Botcazou + + Backport from mainline + 2014-05-27 Eric Botcazou + + * double-int.c (div_and_round_double) : Use the proper + predicate to detect a negative quotient. + +2014-05-28 Georg-Johann Lay + + PR target/61044 + * doc/extend.texi (Local Labels): Note that label differences are + not supported for AVR. + +2014-05-26 Michael Tautschnig + + PR target/61249 + * doc/extend.texi (X86 Built-in Functions): Fix parameter lists of + __builtin_ia32_vfrczs[sd] and __builtin_ia32_mpsadbw256. + +2014-05-23 Alan Modra + + PR target/61231 + * config/rs6000/rs6000.c (mem_operand_gpr): Handle SImode. + * config/rs6000/rs6000.md (extendsidi2_lfiwax, extendsidi2_nocell): + Use "Y" constraint rather than "m". + +2014-05-22 Peter Bergner + + Backport from mainline + 2014-05-22 Peter Bergner + + * config/rs6000/htm.md (ttest): Use correct shift value to get CR0. + +2014-05-22 Richard Earnshaw + + PR target/61208 + * arm.md (arm_cmpdi_unsigned): Fix length calculation for Thumb2. + 2014-05-22 Release Manager * GCC 4.8.3 released. Index: gcc/testsuite/gcc.target/powerpc/htm-ttest.c =================================================================== --- a/src/gcc/testsuite/gcc.target/powerpc/htm-ttest.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gcc.target/powerpc/htm-ttest.c (.../branches/gcc-4_8-branch) @@ -0,0 +1,14 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_htm_ok } */ +/* { dg-options "-O2 -mhtm" } */ + +/* { dg-final { scan-assembler "rlwinm r?\[0-9\]+,r?\[0-9\]+,3,30,31" { target { ilp32 } } } } */ +/* { dg-final { scan-assembler "rldicl r?\[0-9\]+,r?\[0-9\]+,35,62" { target { lp64 } } } } */ + +#include +long +ttest (void) +{ + return _HTM_STATE(__builtin_ttest()); +} Index: gcc/testsuite/gcc.target/i386/pr60901.c =================================================================== --- a/src/gcc/testsuite/gcc.target/i386/pr60901.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gcc.target/i386/pr60901.c (.../branches/gcc-4_8-branch) @@ -0,0 +1,17 @@ +/* { dg-options "-O -fselective-scheduling -fschedule-insns -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fno-tree-dominator-opts" } */ + +extern int n; +extern void bar (void); +extern int baz (int); + +void +foo (void) +{ + int i, j; + for (j = 0; j < n; j++) + { + for (i = 1; i < j; i++) + bar (); + baz (0); + } +} Index: gcc/testsuite/gnat.dg/overflow_fixed.adb =================================================================== --- a/src/gcc/testsuite/gnat.dg/overflow_fixed.adb (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gnat.dg/overflow_fixed.adb (.../branches/gcc-4_8-branch) @@ -0,0 +1,19 @@ +-- { dg-do run } +-- { dg-options "-gnato -O" } + +procedure Overflow_Fixed is + + type Unsigned_8_Bit is mod 2**8; + + procedure Fixed_To_Eight (Value : Duration) is + Item : Unsigned_8_Bit; + begin + Item := Unsigned_8_Bit(Value); + raise Program_Error; + exception + when Constraint_Error => null; -- expected case + end; + +begin + Fixed_To_Eight (-0.5); +end; Index: gcc/testsuite/gnat.dg/aliasing1.adb =================================================================== --- a/src/gcc/testsuite/gnat.dg/aliasing1.adb (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gnat.dg/aliasing1.adb (.../branches/gcc-4_8-branch) @@ -18,5 +18,5 @@ end Aliasing1; --- { dg-final { scan-tree-dump-not "__gnat_rcheck" "optimized" } } +-- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } } -- { dg-final { cleanup-tree-dump "optimized" } } Index: gcc/testsuite/gcc.dg/pr60866.c =================================================================== --- a/src/gcc/testsuite/gcc.dg/pr60866.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gcc.dg/pr60866.c (.../branches/gcc-4_8-branch) @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-O -fselective-scheduling -fno-if-conversion -fschedule-insns" } */ + +int n; + +void +foo (int w, int **dnroot, int **dn) +{ + int *child; + int *xchild = xchild; + for (; w < n; w++) + if (!dnroot) + { + dnroot = dn; + for (child = *dn; child; child = xchild) + ; + } +} Index: gcc/testsuite/gcc.dg/torture/pr61383-1.c =================================================================== --- a/src/gcc/testsuite/gcc.dg/torture/pr61383-1.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/gcc.dg/torture/pr61383-1.c (.../branches/gcc-4_8-branch) @@ -0,0 +1,35 @@ +/* { dg-do run } */ + +int a, b = 1, c, d, e, f, g; + +int +fn1 () +{ + int h; + for (;;) + { + g = b; + g = g ? 0 : 1 % g; + e = a + 1; + for (; d < 1; d = e) + { + if (f == 0) + h = 0; + else + h = 1 % f; + if (f < 1) + c = 0; + else if (h) + break; + } + if (b) + return 0; + } +} + +int +main () +{ + fn1 (); + return 0; +} Index: gcc/testsuite/ChangeLog =================================================================== --- a/src/gcc/testsuite/ChangeLog (.../tags/gcc_4_8_3_release) +++ b/src/gcc/testsuite/ChangeLog (.../branches/gcc-4_8-branch) @@ -1,3 +1,42 @@ +2014-06-04 Richard Biener + + PR tree-optimization/61383 + * gcc.dg/torture/pr61383-1.c: New testcase. + +2014-06-03 Andrey Belevantsev + + Backport from mainline + 2014-05-14 Andrey Belevantsev + + PR rtl-optimization/60866 + * gcc.dg/pr60866.c: New test. + +2014-06-03 Andrey Belevantsev + + Backport from mainline + 2014-05-14 Andrey Belevantsev + + PR rtl-optimization/60901 + * gcc.target/i386/pr60901.c: New test. + +2014-05-28 Eric Botcazou + + Backport from mainline + 2014-05-27 Eric Botcazou + + * gnat.dg/overflow_fixed.adb: New test. + +2014-05-27 Eric Botcazou + + * gnat.dg/aliasing1.adb (dg-final): Robustify pattern matching. + +2014-05-22 Peter Bergner + + Backport from mainline + 2014-05-22 Peter Bergner + + * gcc.target/powerpc/htm-ttest.c: New test. + 2014-05-22 Release Manager * GCC 4.8.3 released. Index: gcc/double-int.c =================================================================== --- a/src/gcc/double-int.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/double-int.c (.../branches/gcc-4_8-branch) @@ -616,7 +616,7 @@ == (unsigned HOST_WIDE_INT) htwice) && (labs_den <= ltwice))) { - if (*hquo < 0) + if (quo_neg) /* quo = quo - 1; */ add_double (*lquo, *hquo, (HOST_WIDE_INT) -1, (HOST_WIDE_INT) -1, lquo, hquo); Index: gcc/tree-ssa-ifcombine.c =================================================================== --- a/src/gcc/tree-ssa-ifcombine.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/tree-ssa-ifcombine.c (.../branches/gcc-4_8-branch) @@ -105,7 +105,11 @@ { gimple stmt = gsi_stmt (gsi); + if (is_gimple_debug (stmt)) + continue; + if (gimple_has_side_effects (stmt) + || gimple_could_trap_p (stmt) || gimple_vuse (stmt)) return false; } Index: gcc/sel-sched-ir.c =================================================================== --- a/src/gcc/sel-sched-ir.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/sel-sched-ir.c (.../branches/gcc-4_8-branch) @@ -162,7 +162,7 @@ static void free_av_set (basic_block); static void invalidate_av_set (basic_block); static void extend_insn_data (void); -static void sel_init_new_insn (insn_t, int); +static void sel_init_new_insn (insn_t, int, int = -1); static void finish_insns (void); /* Various list functions. */ @@ -4011,9 +4011,10 @@ return seqno; } -/* Compute seqno for INSN by its preds or succs. */ +/* Compute seqno for INSN by its preds or succs. Use OLD_SEQNO to compute + seqno in corner cases. */ static int -get_seqno_for_a_jump (insn_t insn) +get_seqno_for_a_jump (insn_t insn, int old_seqno) { int seqno; @@ -4069,8 +4070,16 @@ if (seqno < 0) seqno = get_seqno_by_succs (insn); + if (seqno < 0) + { + /* The only case where this could be here legally is that the only + unscheduled insn was a conditional jump that got removed and turned + into this unconditional one. Initialize from the old seqno + of that jump passed down to here. */ + seqno = old_seqno; + } + gcc_assert (seqno >= 0); - return seqno; } @@ -4250,22 +4259,24 @@ } /* This is used to initialize spurious jumps generated by - sel_redirect_edge (). */ + sel_redirect_edge (). OLD_SEQNO is used for initializing seqnos + in corner cases within get_seqno_for_a_jump. */ static void -init_simplejump_data (insn_t insn) +init_simplejump_data (insn_t insn, int old_seqno) { init_expr (INSN_EXPR (insn), vinsn_create (insn, false), 0, REG_BR_PROB_BASE, 0, 0, 0, 0, 0, 0, vNULL, true, false, false, false, true); - INSN_SEQNO (insn) = get_seqno_for_a_jump (insn); + INSN_SEQNO (insn) = get_seqno_for_a_jump (insn, old_seqno); init_first_time_insn_data (insn); } /* Perform deferred initialization of insns. This is used to process - a new jump that may be created by redirect_edge. */ -void -sel_init_new_insn (insn_t insn, int flags) + a new jump that may be created by redirect_edge. OLD_SEQNO is used + for initializing simplejumps in init_simplejump_data. */ +static void +sel_init_new_insn (insn_t insn, int flags, int old_seqno) { /* We create data structures for bb when the first insn is emitted in it. */ if (INSN_P (insn) @@ -4292,7 +4303,7 @@ if (flags & INSN_INIT_TODO_SIMPLEJUMP) { extend_insn_data (); - init_simplejump_data (insn); + init_simplejump_data (insn, old_seqno); } gcc_assert (CONTAINING_RGN (BLOCK_NUM (insn)) @@ -5578,8 +5589,7 @@ } /* A wrapper for redirect_edge_and_branch_force, which also initializes - data structures for possibly created bb and insns. Returns the newly - added bb or NULL, when a bb was not needed. */ + data structures for possibly created bb and insns. */ void sel_redirect_edge_and_branch_force (edge e, basic_block to) { @@ -5586,6 +5596,7 @@ basic_block jump_bb, src, orig_dest = e->dest; int prev_max_uid; rtx jump; + int old_seqno = -1; /* This function is now used only for bookkeeping code creation, where we'll never get the single pred of orig_dest block and thus will not @@ -5594,8 +5605,13 @@ && !single_pred_p (orig_dest)); src = e->src; prev_max_uid = get_max_uid (); + /* Compute and pass old_seqno down to sel_init_new_insn only for the case + when the conditional jump being redirected may become unconditional. */ + if (any_condjump_p (BB_END (src)) + && INSN_SEQNO (BB_END (src)) >= 0) + old_seqno = INSN_SEQNO (BB_END (src)); + jump_bb = redirect_edge_and_branch_force (e, to); - if (jump_bb != NULL) sel_add_bb (jump_bb); @@ -5607,7 +5623,8 @@ jump = find_new_jump (src, jump_bb, prev_max_uid); if (jump) - sel_init_new_insn (jump, INSN_INIT_TODO_LUID | INSN_INIT_TODO_SIMPLEJUMP); + sel_init_new_insn (jump, INSN_INIT_TODO_LUID | INSN_INIT_TODO_SIMPLEJUMP, + old_seqno); set_immediate_dominator (CDI_DOMINATORS, to, recompute_dominator (CDI_DOMINATORS, to)); set_immediate_dominator (CDI_DOMINATORS, orig_dest, @@ -5626,6 +5643,7 @@ edge redirected; bool recompute_toporder_p = false; bool maybe_unreachable = single_pred_p (orig_dest); + int old_seqno = -1; latch_edge_p = (pipelining_p && current_loop_nest @@ -5634,6 +5652,12 @@ src = e->src; prev_max_uid = get_max_uid (); + /* Compute and pass old_seqno down to sel_init_new_insn only for the case + when the conditional jump being redirected may become unconditional. */ + if (any_condjump_p (BB_END (src)) + && INSN_SEQNO (BB_END (src)) >= 0) + old_seqno = INSN_SEQNO (BB_END (src)); + redirected = redirect_edge_and_branch (e, to); gcc_assert (redirected && !last_added_blocks.exists ()); @@ -5654,7 +5678,7 @@ jump = find_new_jump (src, NULL, prev_max_uid); if (jump) - sel_init_new_insn (jump, INSN_INIT_TODO_LUID | INSN_INIT_TODO_SIMPLEJUMP); + sel_init_new_insn (jump, INSN_INIT_TODO_LUID | INSN_INIT_TODO_SIMPLEJUMP, old_seqno); /* Only update dominator info when we don't have unreachable blocks. Otherwise we'll update in maybe_tidy_empty_bb. */ Index: gcc/fortran/ChangeLog =================================================================== --- a/src/gcc/fortran/ChangeLog (.../tags/gcc_4_8_3_release) +++ b/src/gcc/fortran/ChangeLog (.../branches/gcc-4_8-branch) @@ -1,3 +1,10 @@ +2014-05-26 Janne Blomqvist + + Backport from mainline + PR libfortran/61310 + * intrinsics.texi (CTIME): Remove mention of locale-dependent + behavior. + 2014-05-22 Release Manager * GCC 4.8.3 released. Index: gcc/config/i386/i386.c =================================================================== --- a/src/gcc/config/i386/i386.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/i386/i386.c (.../branches/gcc-4_8-branch) @@ -20505,7 +20505,7 @@ t1 = gen_reg_rtx (V32QImode); t2 = gen_reg_rtx (V32QImode); t3 = gen_reg_rtx (V32QImode); - vt2 = GEN_INT (128); + vt2 = GEN_INT (-128); for (i = 0; i < 32; i++) vec[i] = vt2; vt = gen_rtx_CONST_VECTOR (V32QImode, gen_rtvec_v (32, vec)); @@ -24640,13 +24640,17 @@ { edge e; edge_iterator ei; - /* Assume that region is SCC, i.e. all immediate predecessors - of non-head block are in the same region. */ + + /* Regions are SCCs with the exception of selective + scheduling with pipelining of outer blocks enabled. + So also check that immediate predecessors of a non-head + block are in the same region. */ FOR_EACH_EDGE (e, ei, bb->preds) { /* Avoid creating of loop-carried dependencies through - using topological odering in region. */ - if (BLOCK_TO_BB (bb->index) > BLOCK_TO_BB (e->src->index)) + using topological ordering in the region. */ + if (rgn == CONTAINING_RGN (e->src->index) + && BLOCK_TO_BB (bb->index) > BLOCK_TO_BB (e->src->index)) add_dependee_for_func_arg (first_arg, e->src); } } Index: gcc/config/aarch64/arm_neon.h =================================================================== --- a/src/gcc/config/aarch64/arm_neon.h (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/aarch64/arm_neon.h (.../branches/gcc-4_8-branch) @@ -13815,7 +13815,7 @@ int16x4_t result; __asm__ ("sqdmulh %0.4h,%1.4h,%2.h[0]" : "=w"(result) - : "w"(a), "w"(b) + : "w"(a), "x"(b) : /* No clobbers */); return result; } @@ -13837,7 +13837,7 @@ int16x8_t result; __asm__ ("sqdmulh %0.8h,%1.8h,%2.h[0]" : "=w"(result) - : "w"(a), "w"(b) + : "w"(a), "x"(b) : /* No clobbers */); return result; } Index: gcc/config/rs6000/htm.md =================================================================== --- a/src/gcc/config/rs6000/htm.md (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/rs6000/htm.md (.../branches/gcc-4_8-branch) @@ -179,7 +179,7 @@ (const_int 0)] UNSPECV_HTM_TABORTWCI)) (set (subreg:CC (match_dup 2) 0) (match_dup 1)) - (set (match_dup 3) (lshiftrt:SI (match_dup 2) (const_int 24))) + (set (match_dup 3) (lshiftrt:SI (match_dup 2) (const_int 28))) (parallel [(set (match_operand:SI 0 "int_reg_operand" "") (and:SI (match_dup 3) (const_int 15))) (clobber (scratch:CC))])] Index: gcc/config/rs6000/rs6000.c =================================================================== --- a/src/gcc/config/rs6000/rs6000.c (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/rs6000/rs6000.c (.../branches/gcc-4_8-branch) @@ -6109,7 +6109,8 @@ return false; extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD; - gcc_assert (extra >= 0); + if (extra < 0) + extra = 0; if (GET_CODE (addr) == LO_SUM) /* For lo_sum addresses, we must allow any offset except one that Index: gcc/config/rs6000/vsx.md =================================================================== --- a/src/gcc/config/rs6000/vsx.md (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/rs6000/vsx.md (.../branches/gcc-4_8-branch) @@ -24,6 +24,13 @@ ;; Iterator for the 2 64-bit vector types (define_mode_iterator VSX_D [V2DF V2DI]) +;; Iterator for the 2 64-bit vector types + 128-bit types that are loaded with +;; lxvd2x to properly handle swapping words on little endian +(define_mode_iterator VSX_LE [V2DF + V2DI + V1TI + (TI "VECTOR_MEM_VSX_P (TImode)")]) + ;; Iterator for the 2 32-bit vector types (define_mode_iterator VSX_W [V4SF V4SI]) @@ -228,8 +235,8 @@ ;; The patterns for LE permuted loads and stores come before the general ;; VSX moves so they match first. (define_insn_and_split "*vsx_le_perm_load_" - [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa") - (match_operand:VSX_D 1 "memory_operand" "Z"))] + [(set (match_operand:VSX_LE 0 "vsx_register_operand" "=wa") + (match_operand:VSX_LE 1 "memory_operand" "Z"))] "!BYTES_BIG_ENDIAN && TARGET_VSX" "#" "!BYTES_BIG_ENDIAN && TARGET_VSX" @@ -342,8 +349,8 @@ (set_attr "length" "8")]) (define_insn "*vsx_le_perm_store_" - [(set (match_operand:VSX_D 0 "memory_operand" "=Z") - (match_operand:VSX_D 1 "vsx_register_operand" "+wa"))] + [(set (match_operand:VSX_LE 0 "memory_operand" "=Z") + (match_operand:VSX_LE 1 "vsx_register_operand" "+wa"))] "!BYTES_BIG_ENDIAN && TARGET_VSX" "#" [(set_attr "type" "vecstore") @@ -350,8 +357,8 @@ (set_attr "length" "12")]) (define_split - [(set (match_operand:VSX_D 0 "memory_operand" "") - (match_operand:VSX_D 1 "vsx_register_operand" ""))] + [(set (match_operand:VSX_LE 0 "memory_operand" "") + (match_operand:VSX_LE 1 "vsx_register_operand" ""))] "!BYTES_BIG_ENDIAN && TARGET_VSX && !reload_completed" [(set (match_dup 2) (vec_select: @@ -369,8 +376,8 @@ ;; The post-reload split requires that we re-permute the source ;; register in case it is still live. (define_split - [(set (match_operand:VSX_D 0 "memory_operand" "") - (match_operand:VSX_D 1 "vsx_register_operand" ""))] + [(set (match_operand:VSX_LE 0 "memory_operand" "") + (match_operand:VSX_LE 1 "vsx_register_operand" ""))] "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed" [(set (match_dup 1) (vec_select: @@ -1352,9 +1359,9 @@ ;; xxpermdi for little endian loads and stores. We need several of ;; these since the form of the PARALLEL differs by mode. (define_insn "*vsx_xxpermdi2_le_" - [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa") - (vec_select:VSX_D - (match_operand:VSX_D 1 "vsx_register_operand" "wa") + [(set (match_operand:VSX_LE 0 "vsx_register_operand" "=wa") + (vec_select:VSX_LE + (match_operand:VSX_LE 1 "vsx_register_operand" "wa") (parallel [(const_int 1) (const_int 0)])))] "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (mode)" "xxpermdi %x0,%x1,%x1,2" @@ -1401,9 +1408,9 @@ ;; lxvd2x for little endian loads. We need several of ;; these since the form of the PARALLEL differs by mode. (define_insn "*vsx_lxvd2x2_le_" - [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa") - (vec_select:VSX_D - (match_operand:VSX_D 1 "memory_operand" "Z") + [(set (match_operand:VSX_LE 0 "vsx_register_operand" "=wa") + (vec_select:VSX_LE + (match_operand:VSX_LE 1 "memory_operand" "Z") (parallel [(const_int 1) (const_int 0)])))] "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (mode)" "lxvd2x %x0,%y1" @@ -1450,9 +1457,9 @@ ;; stxvd2x for little endian stores. We need several of ;; these since the form of the PARALLEL differs by mode. (define_insn "*vsx_stxvd2x2_le_" - [(set (match_operand:VSX_D 0 "memory_operand" "=Z") - (vec_select:VSX_D - (match_operand:VSX_D 1 "vsx_register_operand" "wa") + [(set (match_operand:VSX_LE 0 "memory_operand" "=Z") + (vec_select:VSX_LE + (match_operand:VSX_LE 1 "vsx_register_operand" "wa") (parallel [(const_int 1) (const_int 0)])))] "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (mode)" "stxvd2x %x1,%y0" Index: gcc/config/rs6000/rs6000.md =================================================================== --- a/src/gcc/config/rs6000/rs6000.md (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/rs6000/rs6000.md (.../branches/gcc-4_8-branch) @@ -737,7 +737,7 @@ (define_insn "*extendsidi2_lfiwax" [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,??wm,!wl,!wu") - (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r,r,Z,Z")))] + (sign_extend:DI (match_operand:SI 1 "lwa_operand" "Y,r,r,Z,Z")))] "TARGET_POWERPC64 && TARGET_LFIWAX" "@ lwa%U1%X1 %0,%1 @@ -760,7 +760,7 @@ (define_insn "*extendsidi2_nocell" [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r") - (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))] + (sign_extend:DI (match_operand:SI 1 "lwa_operand" "Y,r")))] "TARGET_POWERPC64 && rs6000_gen_cell_microcode && !TARGET_LFIWAX" "@ lwa%U1%X1 %0,%1 Index: gcc/config/arm/arm.md =================================================================== --- a/src/gcc/config/arm/arm.md (.../tags/gcc_4_8_3_release) +++ b/src/gcc/config/arm/arm.md (.../branches/gcc-4_8-branch) @@ -7630,12 +7630,13 @@ (define_insn "*arm_cmpdi_unsigned" [(set (reg:CC_CZ CC_REGNUM) - (compare:CC_CZ (match_operand:DI 0 "s_register_operand" "r") - (match_operand:DI 1 "arm_di_operand" "rDi")))] + (compare:CC_CZ (match_operand:DI 0 "s_register_operand" "r,r") + (match_operand:DI 1 "arm_di_operand" "rDi,rDi")))] "TARGET_32BIT" "cmp\\t%R0, %R1\;it eq\;cmpeq\\t%Q0, %Q1" [(set_attr "conds" "set") - (set_attr "length" "8")] + (set_attr "arch" "a,t2") + (set_attr "length" "8,10")] ) (define_insn "*arm_cmpdi_zero" Index: libgfortran/intrinsics/ctime.c =================================================================== --- a/src/libgfortran/intrinsics/ctime.c (.../tags/gcc_4_8_3_release) +++ b/src/libgfortran/intrinsics/ctime.c (.../branches/gcc-4_8-branch) @@ -31,31 +31,53 @@ #include -/* strftime-like function that fills a C string with %c format which - is identical to ctime in the default locale. As ctime and ctime_r - are poorly specified and their usage not recommended, the - implementation instead uses strftime. */ +/* Maximum space a ctime-like string might need. A "normal" ctime + string is 26 bytes, and in our case 24 bytes as we don't include + the trailing newline and null. However, the longest possible year + number is -2,147,481,748 (1900 - 2,147,483,648, since tm_year is a + 32-bit signed integer) so an extra 7 bytes are needed. */ +#define CTIME_BUFSZ 31 -static size_t -strctime (char *s, size_t max, const time_t *timep) + +/* Thread-safe ctime-like function that fills a Fortran + string. ctime_r is a portability headache and marked as obsolescent + in POSIX 2008, which recommends strftime in its place. However, + strftime(..., "%c",...) doesn't produce ctime-like output on + MinGW, so do it manually with snprintf. */ + +static int +gf_ctime (char *s, size_t max, const time_t timev) { struct tm ltm; int failed; + char buf[CTIME_BUFSZ + 1]; /* Some targets provide a localtime_r based on a draft of the POSIX standard where the return type is int rather than the standardized struct tm*. */ - __builtin_choose_expr (__builtin_classify_type (localtime_r (timep, <m)) + __builtin_choose_expr (__builtin_classify_type (localtime_r (&timev, <m)) == 5, - failed = localtime_r (timep, <m) == NULL, - failed = localtime_r (timep, <m) != 0); + failed = localtime_r (&timev, <m) == NULL, + failed = localtime_r (&timev, <m) != 0); if (failed) - return 0; - return strftime (s, max, "%c", <m); + goto blank; + int n = snprintf (buf, sizeof (buf), + "%3.3s %3.3s%3d %.2d:%.2d:%.2d %d", + "SunMonTueWedThuFriSat" + ltm.tm_wday * 3, + "JanFebMarAprMayJunJulAugSepOctNovDec" + ltm.tm_mon * 3, + ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec, + 1900 + ltm.tm_year); + if (n < 0) + goto blank; + if ((size_t) n <= max) + { + cf_strcpy (s, max, buf); + return n; + } + blank: + memset (s, ' ', max); + return 0; } -/* In the default locale, the date and time representation fits in 26 - bytes. However, other locales might need more space. */ -#define CSZ 100 extern void fdate (char **, gfc_charlen_type *); export_proto(fdate); @@ -64,8 +86,8 @@ fdate (char ** date, gfc_charlen_type * date_len) { time_t now = time(NULL); - *date = xmalloc (CSZ); - *date_len = strctime (*date, CSZ, &now); + *date = xmalloc (CTIME_BUFSZ); + *date_len = gf_ctime (*date, CTIME_BUFSZ, now); } @@ -76,10 +98,7 @@ fdate_sub (char * date, gfc_charlen_type date_len) { time_t now = time(NULL); - char *s = xmalloc (date_len + 1); - size_t n = strctime (s, date_len + 1, &now); - fstrcpy (date, date_len, s, n); - free (s); + gf_ctime (date, date_len, now); } @@ -91,8 +110,8 @@ PREFIX(ctime) (char ** date, gfc_charlen_type * date_len, GFC_INTEGER_8 t) { time_t now = t; - *date = xmalloc (CSZ); - *date_len = strctime (*date, CSZ, &now); + *date = xmalloc (CTIME_BUFSZ); + *date_len = gf_ctime (*date, CTIME_BUFSZ, now); } @@ -103,8 +122,5 @@ ctime_sub (GFC_INTEGER_8 * t, char * date, gfc_charlen_type date_len) { time_t now = *t; - char *s = xmalloc (date_len + 1); - size_t n = strctime (s, date_len + 1, &now); - fstrcpy (date, date_len, s, n); - free (s); + gf_ctime (date, date_len, now); } Index: libgfortran/ChangeLog =================================================================== --- a/src/libgfortran/ChangeLog (.../tags/gcc_4_8_3_release) +++ b/src/libgfortran/ChangeLog (.../branches/gcc-4_8-branch) @@ -1,3 +1,21 @@ +2014-05-26 Janne Blomqvist + + Backport from mainline + PR libfortran/61310 + * intrinsics/ctime.c (strctime): Rename to gf_ctime, use snprintf + instead of strftime. + (fdate): Use gf_ctime. + (fdate_sub): Likewise. + (ctime): Likewise. + (ctime_sub): Likewise. + +2014-05-25 Janne Blomqvist + + Backport from trunk. + PR libfortran/61187 + * io/unix.c (raw_close): Check if s->fd is -1. + (fd_to_stream): Check return value of fstat(), handle error. + 2014-05-22 Release Manager * GCC 4.8.3 released. Index: libgfortran/io/unix.c =================================================================== --- a/src/libgfortran/io/unix.c (.../tags/gcc_4_8_3_release) +++ b/src/libgfortran/io/unix.c (.../branches/gcc-4_8-branch) @@ -407,7 +407,9 @@ { int retval; - if (s->fd != STDOUT_FILENO + if (s->fd == -1) + retval = -1; + else if (s->fd != STDOUT_FILENO && s->fd != STDERR_FILENO && s->fd != STDIN_FILENO) retval = close (s->fd); @@ -983,7 +985,15 @@ /* Get the current length of the file. */ - fstat (fd, &statbuf); + if (fstat (fd, &statbuf) == -1) + { + s->st_dev = s->st_ino = -1; + s->file_length = 0; + if (errno == EBADF) + s->fd = -1; + raw_init (s); + return (stream *) s; + } s->st_dev = statbuf.st_dev; s->st_ino = statbuf.st_ino;