When a function call is removed, it may become a leaf function. But if
argument may be passed on stack, we need to align the stack frame when
there is no tail call.
Tested on Linux/i686 and Linux/x86-64.
gcc/
Backport from mainline
PR target/83330
* config/i386/i386.c (ix86_function_arg_advance): Set
outgoing_args_on_stack to true if there are outgoing arguments
on stack.
(ix86_function_arg): Likewise.
(ix86_compute_frame_layout): Align stack frame if argument is
passed on stack.
* config/i386/i386.h (machine_function): Add
outgoing_args_on_stack.
gcc/testsuite/
Backport from mainline
PR target/83330
* gcc.target/i386/pr83330.c: New test.
From-SVN: r256703
When there is no need to make a copy of ix86_frame, we can use reference
of struct ix86_frame to avoid copy.
Backport from mainline
* config/i386/i386.c (ix86_expand_prologue): Use reference of
struct ix86_frame.
(ix86_expand_epilogue): Likewise.
From-SVN: r256695
When there is no need to make a copy of ix86_frame, we can use reference
of struct ix86_frame to avoid copy.
Backport from mainline
* config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
of struct ix86_frame.
(ix86_initial_elimination_offset): Likewise.
(ix86_expand_split_stack_prologue): Likewise.
From-SVN: r256692
Make ix86_frame available to i386 code generation. This is needed to
backport the patch set of -mindirect-branch= to mitigate variant #2 of
the speculative execution vulnerabilities on x86 processors identified
by CVE-2017-5715, aka Spectre.
Backport from mainline
* config/i386/i386.c (ix86_frame): Moved to ...
* config/i386/i386.h (ix86_frame): Here.
(machine_function): Add frame.
* config/i386/i386.c (ix86_compute_frame_layout): Repace the
frame argument with &cfun->machine->frame.
(ix86_can_use_return_insn_p): Don't pass &frame to
ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
(ix86_can_eliminate): Likewise.
(ix86_expand_prologue): Likewise.
(ix86_expand_epilogue): Likewise.
(ix86_expand_split_stack_prologue): Likewise.
From-SVN: r256691
2018-01-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Backport from trunk
PR libgfortran/83811
* gfortran.dg/fmt_e.f90: New test.
* gfortran.dg/fmt_e.f90: New test.
From-SVN: r256675
[gcc]
2018-01-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
2018-01-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/83677
* config/rs6000/altivec.md (*altivec_vpermr_<mode>_internal):
Reverse order of second and third operands in first alternative.
* config/rs6000/rs6000.c (rs6000_expand_vector_set): Reverse order
of first and second elements in UNSPEC_VPERMR vector.
(altivec_expand_vec_perm_le): Likewise.
[gcc/testsuite]
2018-01-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
2018-01-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/83677
* gcc.target/powerpc/pr83677.c: New file.
From-SVN: r256670
2012-01-13 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from mainline
PR fortran/78814
* interface.c (symbol_rank): Check for NULL pointer.
2012-01-13 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from mainline
PR fortran/78814
* gfortran.dg/interface_40.f90: New testcase.
From-SVN: r256646
* python/libstdcxx/v6/printers.py (register_type_printers): Remove
printer for experimental::any. Fix printers for experimental::optional
and experimental::basic_string_view.
From-SVN: r256604
PR rtl-optimization/83565
* rtlanal.c (nonzero_bits1): On WORD_REGISTER_OPERATIONS machines, do
not extend the result to a larger mode for rotate operations.
(num_sign_bit_copies1): Likewise.
From-SVN: r256573
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82367
* resolve.c (resolve_allocate_expr): Check for NULL pointer.
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82367
* gfortran.dg/deferred_character_18.f90: New test.
From-SVN: r256466
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from trunk
PR fortran/83093
* resolve.c (resolve_charlen): Check the type of cl->length
after resolution.
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from trunk
PR fortran/83093
* gfortran.dg/allocate_with_typespec_7.f90: New test.
From-SVN: r256459
2018-01-10 Steven G. Kargl <kargl@kgcc.gnu.org>
Backport r254555 from trunk
PR Fortran/82841
* gfortran.dg/transfer_simplify_11.f90: New test.
2018-01-10 Steven G. Kargl <kargl@kgcc.gnu.org>
Backport r254555 from trunk
PR Fortran/82841
* simplify.c(gfc_simplify_transfer): Do not dereference a NULL pointer.
Unwrap a short line.
From-SVN: r256445
Backport from mainline
2017-10-19 Jonathan Wakely <jwakely@redhat.com>
* testsuite/experimental/filesystem/iterators/
recursive_directory_iterator.cc: Ensure that error_code arguments are
cleared when required.
* testsuite/experimental/filesystem/operations/create_directory.cc:
Remove redundant check.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Ensure that error_code argument is cleared when required.
From-SVN: r256293
Backport from mainline
2017-12-27 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/83600
* include/bits/regex.h (match_results::end()): Return valid iterator
when not ready.
* testsuite/28_regex/match_results/ctors/char/default.cc: Check that
unready objects are empty and have equal begin and end iterators.
* testsuite/28_regex/match_results/ctors/wchar_t/default.cc: Likewise.
From-SVN: r256292
Backport from mainline
2018-01-05 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/83626
* src/filesystem/ops.cc (remove(const path&, error_code&)): Do not
report an error for ENOENT.
(remove_all(const path&)): Fix type of result variable.
(remove_all(const path&, error_code&)): Use non-throwing increment
for directory iterator. Call POSIX remove directly to avoid redundant
calls to symlink_status. Do not report errors for ENOENT.
* testsuite/experimental/filesystem/operations/remove_all.cc: Test
throwing overload.
Backport from mainline
2018-01-04 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/83626
* src/filesystem/ops.cc (remove(const path&, error_code&))): Remove
redundant call to ec.clear().
(remove_all(const path&, error_code&))): Do not return an error for
non-existent paths.
* testsuite/experimental/filesystem/operations/remove.cc: New test.
* testsuite/experimental/filesystem/operations/remove_all.cc: Fix
expected results for non-existent paths.
From-SVN: r256287
2018-01-05 Michael Weiser <michael.weiser@gmx.de>
Backport from trunk
2017-12-20 Michael Weiser <michael.weiser@gmx.de>
PR preprocessor/83492
* lex.c (search_line_fast) [__ARM_NEON && __ARM_64BIT_STATE]:
Fix selection of big-endian shift parameters by using
__ARM_BIG_ENDIAN.
From-SVN: r256278
2018-01-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR Fortran/83679
* simplify.c (gfc_simplify_cshift): Restore early return for zero-sized
array. Update Copyright year while here.
From-SVN: r256263
Backport from mainline
2018-01-03 Ville Voutilainen <ville.voutilainen@gmail.com>
Protect optional's deduction guide with the feature macro
* include/std/optional: Use the feature macro.
From-SVN: r256261
Backport from trunk.
It turns out that Linux never reads or writes more than 2147479552
bytes in a single syscall. For writes this is not a problem as
libgfortran already contains a loop around write() to handle short
writes. But for reads we cannot do this, since then read will hang if
we have a short read when reading from the terminal. Also, there are
reports that macOS fails I/O's larger than 2 GB. Thus, to work around
these issues do large reads/writes in chunks.
The testcase from the PR
program largewr
integer(kind=1) :: a(2_8**31+1)
a = 0
a(size(a, kind=8)) = 1
open(10, file="largewr.dat", access="stream", form="unformatted")
write (10) a
close(10)
a(size(a, kind=8)) = 2
open(10, file="largewr.dat", access="stream", form="unformatted")
read (10) a
if (a(size(a, kind=8)) == 1) then
print *, "All is well"
else
print *, "Oh no"
end if
end program largewr
fails on trunk but works with the patch.
Regtested on x86_64-pc-linux-gnu, committed to trunk.
libgfortran/ChangeLog:
2018-01-03 Janne Blomqvist <jb@gcc.gnu.org>
PR libgfortran/83649
* io/unix.c (MAX_CHUNK): New define.
(raw_read): For reads larger than MAX_CHUNK, loop.
(raw_write): Write no more than MAX_CHUNK bytes per iteration.
---
libgfortran/io/unix.c | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 8 deletions(-)
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index a07a3c9..7a982b3 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -292,18 +292,49 @@ raw_flush (unix_stream *s __attribute__ ((unused)))
return 0;
}
+/* Write/read at most 2 GB - 4k chunks at a time. Linux never reads or
+ writes more than this, and there are reports that macOS fails for
+ larger than 2 GB as well. */
+#define MAX_CHUNK 2147479552
+
static ssize_t
raw_read (unix_stream *s, void *buf, ssize_t nbyte)
{
/* For read we can't do I/O in a loop like raw_write does, because
that will break applications that wait for interactive I/O. We
- still can loop around EINTR, though. */
- while (true)
+ still can loop around EINTR, though. This however causes a
+ problem for large reads which must be chunked, see comment above.
+ So assume that if the size is larger than the chunk size, we're
+ reading from a file and not the terminal. */
+ if (nbyte <= MAX_CHUNK)
{
- ssize_t trans = read (s->fd, buf, nbyte);
- if (trans == -1 && errno == EINTR)
- continue;
- return trans;
+ while (true)
+ {
+ ssize_t trans = read (s->fd, buf, nbyte);
+ if (trans == -1 && errno == EINTR)
+ continue;
+ return trans;
+ }
+ }
+ else
+ {
+ ssize_t bytes_left = nbyte;
+ char *buf_st = buf;
+ while (bytes_left > 0)
+ {
+ ssize_t to_read = bytes_left < MAX_CHUNK ? bytes_left: MAX_CHUNK;
+ ssize_t trans = read (s->fd, buf_st, to_read);
+ if (trans == -1)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return trans;
+ }
+ buf_st += trans;
+ bytes_left -= trans;
+ }
+ return nbyte - bytes_left;
}
}
@@ -317,10 +348,13 @@ raw_write (unix_stream *s, const void *buf, ssize_t nbyte)
buf_st = (char *) buf;
/* We must write in a loop since some systems don't restart system
- calls in case of a signal. */
+ calls in case of a signal. Also some systems might fail outright
+ if we try to write more than 2 GB in a single syscall, so chunk
+ up large writes. */
while (bytes_left > 0)
{
- trans = write (s->fd, buf_st, bytes_left);
+ ssize_t to_write = bytes_left < MAX_CHUNK ? bytes_left: MAX_CHUNK;
+ trans = write (s->fd, buf_st, to_write);
if (trans == -1)
{
if (errno == EINTR)
--
2.7.4
From-SVN: r256172