Aw: Re: asking for __attribute__((aligned()) clarification

2019-08-19 Thread Markus Fröschle
Thank you (and others) for your answers. Now I'm just as smart as before, 
however.

Is it a supported, documented, 'long term' feature we can rely on or not?

If yes, I would expect it to be properly documented. If not, never mind.

> Gesendet: Montag, 19. August 2019 um 16:08 Uhr
> Von: "Alexander Monakov" 
> An: "Richard Earnshaw (lists)" 
> Cc: "Paul Koning" , "Markus Fröschle" 
> , gcc@gcc.gnu.org
> Betreff: Re: asking for __attribute__((aligned()) clarification
>
> On Mon, 19 Aug 2019, Richard Earnshaw (lists) wrote:
> 
> > Correct, but note that you can only pack structs and unions, not basic 
> > types.
> > there is no way of under-aligning a basic type except by wrapping it in a
> > struct.
> 
> I don't think that's true. In GCC-9 the doc for 'aligned' attribute has been
> significantly revised, and now ends with
> 
>   When used as part of a typedef, the aligned attribute can both increase and
>   decrease alignment, and specifying the packed attribute generates a 
> warning. 
> 
> (but I'm sure defacto behavior of accepting and honoring reduced alignment on
> a typedef'ed scalar type goes way earlier than gcc-9)
> 
> Alexander
>


[doc] Re: install.texi and alpha

2019-08-19 Thread Gerald Pfeifer
On Sun, 12 Mar 2017, Gerald Pfeifer wrote:
>> References to dependencies on really, really old versions of
>> binutils (talking 10+ years here) which I think we can remove.
>> Let me follow-up with some of you with concrete suggestions 
>> around that.
> 
> The alpha*-*-* section currently has this:
> 
>   We require binutils 2.11.2 or newer.
>   Previous binutils releases had a number of problems with DWARF 2
>   debugging information, not the least of which is incorrect linking of
>   shared libraries.
> 
> Okay to yank this?

I do not recall ever seeing a response, and it's now been two
further years, so I went ahead and committed the patch below.

Gerald

2019-08-20  Gerald Pfeifer  

* doc/install.texi (Specific, alpha): Remove note to use
binutils 2.11.2 or later.

Index: doc/install.texi
===
--- doc/install.texi(revision 274619)
+++ doc/install.texi(working copy)
@@ -3472,11 +3472,6 @@ This section contains general configuration inform
 Alpha-based platforms using ELF@.  In addition to reading this
 section, please read all other sections that match your target.
 
-We require binutils 2.11.2 or newer.
-Previous binutils releases had a number of problems with DWARF 2
-debugging information, not the least of which is incorrect linking of
-shared libraries.
-
 @html
 
 @end html


[Bug middle-end/89544] Argument marshalling incorrectly assumes stack slots are naturally aligned.

2019-08-19 Thread edlinger at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89544

--- Comment #8 from Bernd Edlinger  ---
Author: edlinger
Date: Tue Aug 20 05:32:49 2019
New Revision: 274691

URL: https://gcc.gnu.org/viewcvs?rev=274691=gcc=rev
Log:
2019-08-20  Bernd Edlinger  

PR middle-end/89544
* function.c (assign_parm_find_stack_rtl): Use larger alignment
when possible.

testsuite:
2019-08-20  Bernd Edlinger  

PR middle-end/89544
* gcc.target/arm/unaligned-argument-1.c: New test.
* gcc.target/arm/unaligned-argument-2.c: New test.

Added:
trunk/gcc/testsuite/gcc.target/arm/unaligned-argument-1.c
trunk/gcc/testsuite/gcc.target/arm/unaligned-argument-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/function.c
trunk/gcc/testsuite/ChangeLog

[Bug driver/18206] -dynamic-linker option seems to be badly named and broken

2019-08-19 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18206

Eric Gallager  changed:

   What|Removed |Added

  Component|target  |driver

--- Comment #4 from Eric Gallager  ---
(In reply to sandra from comment #2)
> I was discussing this with Joseph Myers earlier today. He said "There isn't
> meant to be a GCC driver -dynamic-linker option." and pointed at
> 
> https://gcc.gnu.org/ml/gcc-patches/2010-12/msg00194.html
> 
> but apparently some backends have broken again since then:
> arm/freebsd.h c6x/uclinux-elf.h rs6000/freebsd64.h
> 
> I found through experimentation that nios2-linux-gnu-gcc accepts
> -dynamic-linker as a link option without error, but totally ignores it. 
> Joseph's explanation is that the driver accepts it as -d but
> doesn't check the .  If you try compiling with that option and not
> just linking, gcc does diagnose that the  are invalid.
> 

...so it seems to me, then, that the "driver" component would make more sense
here than "target"

[Bug other/44210] Warning discoverability: generate parts of invoke.texi directly from .opt files to make it easier to find warning flag relationships

2019-08-19 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44210

Eric Gallager  changed:

   What|Removed |Added

 Depends on||44209
Summary|Extended warning control:   |Warning discoverability:
   |like -Wevery -show-warnings |generate parts of
   ||invoke.texi directly from
   ||.opt files to make it
   ||easier to find warning flag
   ||relationships

--- Comment #9 from Eric Gallager  ---
(In reply to Manuel López-Ibáñez from comment #8)
> EnabledBy is already implemented. Also, -Wall --help=warnings shows which
> warnings are enabled by -Wall.
> 
> The only remaining thing is to generate parts of invoke.texi directly from
> the .opt file.

Retitling then.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44209
[Bug 44209] [meta-bug] Some warnings are not linked to diagnostics options

[Bug libstdc++/91495] New: std::transform_reduce with unary op is implemented in the parallel case but not the basic case

2019-08-19 Thread a.boettcher at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91495

Bug ID: 91495
   Summary: std::transform_reduce with unary op is implemented in
the parallel case but not the basic case
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: a.boettcher at gmail dot com
  Target Milestone: ---

The iso standard per 29.8.5 requires a definition of the type below which is
conspicuously missing in GCC-9, despite the parallel versions existing.

templateT transform_reduce(InputIterator first, InputIterator last,T
init,BinaryOperation binary_op, UnaryOperation unary_op);

Seems like an obvious mistake

[GSoC-19] Final Evaluations

2019-08-19 Thread Tejas Joshi
Hello.
The deadline for final evaluations is 26th of August and there are
certain things that I need to submit along with the code.
A link has to be submitted of the codes that I have written and I am
thinking of doing it as a github gist along with links to commits to
my gcc fork. I know that the documentation in the respective .texi
files is still remaining, of whatever changes I have made and I will
do it as soon as I can but I have to give some of my time to
university exams from 20th to 24th of this month.
I also need to mention the codes that have been merged with the
original source code of GCC. I don't know what codes are OK to be
merged with GCC.
Patches I have submitted till now :





Other things like FADD variants expansion and fromfp variants
expansion that needed to be completed in the course of GSoC is
remaining and I am trying my best to complete it till the end of
deadline. Even if some work remains, I will continue to work on them
to completion and also want to extend my work with other intricacies
or works, even in the ISO/IEC specifications/extensions.

Thanks,
Tejas


[Bug c/91494] New: Performance Regression when upgrading from 8.3.0 to 9.0

2019-08-19 Thread mc_george123 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91494

Bug ID: 91494
   Summary: Performance Regression when upgrading from 8.3.0 to
9.0
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mc_george123 at hotmail dot com
  Target Milestone: ---

During the phoronix tests of botan-1.4.0-blowfish benchmark and crafty-1.4.4
benchmark, there are performance regressions in compilation process between
version 8.3.0-433 and 9.0-454.

[Bug middle-end/91433] Performance Regression when upgrading from 8.3.0 to 9.0

2019-08-19 Thread mc_george123 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91433

--- Comment #2 from George Fan  ---
The compiler option for botan is "-fstack-protector -m64 -pthread -lbotan-2
-ldl -lrt", which the compiler option for crafty is "-pthread -lstdc++
-fprofile-use -lm". While the sub-architecture is coffee lake.

Re: [PATCH] issue consistent warning for past-the-end array stores (PR 91457)

2019-08-19 Thread Martin Sebor

On 8/19/19 8:10 AM, Richard Biener wrote:

On Sat, Aug 17, 2019 at 12:43 AM Martin Sebor  wrote:


With the recent enhancement to the strlen handling of multibyte
stores the g++.dg/warn/Warray-bounds-4.C for zero-length arrays
started failing on hppa (and probably elsewhere as well).  This
is partly the result of the added detection of past-the-end
writes into the strlen pass which detects more instances of
the problem than -Warray-bounds.  Since the IL each warning
works with varies between targets, the same invalid code can
be diagnosed by one warning one target and different warning
on another.

The attached patch does three things:

1) It enhances compute_objsize to also determine the size of
a flexible array member (and its various variants), including
from its initializer if necessary.  (This resolves 91457 but
introduces another warning where was previously just one.)
2) It guards the new instance of -Wstringop-overflow with
the no-warning bit on the assignment to avoid warning on code
that's already been diagnosed.
3) It arranges for -Warray-bounds to set the no-warning bit on
the enclosing expression to keep -Wstringop-overflow from issuing
another warning for the same problem.

Testing the compute_objsize enhancement to bring it up to par
with -Warray-bounds in turn exposed a weakness in the latter
warning for flexible array members.  Rather than snowballing
additional improvements into this one I decided to put that
off until later, so the new -Warray-bounds test has a bunch
of XFAILs.  I'll see if I can find the time to deal with those
either still in stage 1 or in stage 3 (one of them is actually
an ancient regression).


+static tree
+get_initializer_for (tree init, tree decl)
+{

can't you use fold_ctor_reference here?


Yes, but only with an additional enhancement.  Char initializers
for flexible array members aren't transformed to STRING_CSTs yet,
so without the size of the initializer specified, the function
returns the initializer for the smallest subobject, or char in
this case.  I've enhanced the function to handle them.



+/* Determine the size of the flexible array FLD from the initializer
+   expression for the struct object DECL in which the meber is declared
+   (possibly recursively).  Return the size or zero constant if it isn't
+   initialized.  */
+
+static tree
+get_flexarray_size (tree decl, tree fld)
+{
+  if (tree init = DECL_INITIAL (decl))
+{
+  init = get_initializer_for (init, fld);
+  if (init)
+   return TYPE_SIZE_UNIT (TREE_TYPE (init));
+}
+
+  return integer_zero_node;

so you're hoping that the (sub-)CONSTRUCTOR get_initializer_for
returns has a complete type but the initialized object didn't get it
completed.  Isnt that wishful thinking?


I don't know what you mean.  When might a CONSTRUCTOR not have
a complete type, and if/when it doesn't, why would that be
a problem here?  TYPE_SIZE_UNIT will evaluate to null meaning
"don't know" and that's fine.  Could you try to be more specific
about the problem you're pointing out?


And why return integer_zero_node
rather than NULL_TREE here?


Because the size of a flexible array member with no initializer
is zero.



+  if (TREE_CODE (dest) == COMPONENT_REF)
+{
+  *pdecl = TREE_OPERAND (dest, 1);
+
+  /* If the member has a size return it.  Otherwise it's a flexible
+array member.  */
+  if (tree size = DECL_SIZE_UNIT (*pdecl))
+   return size;

because here you do.


Not sure what you mean here either.  (This code was also a bit
out of date WRT to the patch I had tested.  Not sure how that
happened.  The attached patch is up to date.)



Also once you have an underlying VAR_DECL you can compute
the flexarray size by DECL_SIZE (var) - offset-of flexarray member.
Isn't that way cheaper than walking the initializer (possibly many
times?)


It would be nice if it were this easy.  Is the value of DECL_SIZE
(var) supposed to include the size of the flexible array member?
I don't see it mentioned in the comments in tree.h and in my tests
it only does in C but not in C++.  Is that a bug that in C++ it
doesn't?

Attached is an updated patch that uses fold_ctor_reference as you
suggested.  I've also made a few other minor changes to diagnose
a few more invalid strlen calls with out-of-bounds offsets.
(More still remain.)

Martin



Richard.



Martin

PS I imagine the new get_flexarray_size function will probably
need to move somewhere more appropriate so that other warnings
(like -Warray-bounds to remove the XFAILs) and optimizations
can make use of it.


PR tree-optimization/91457 - inconsistent warning for writing past the end of an array member

gcc/testsuite/ChangeLog:

	PR tree-optimization/91457
	* c-c++-common/Wstringop-overflow-2.c: New test.
	* g++.dg/warn/Warray-bounds-8.C: New test.
	* g++.dg/warn/Wstringop-overflow-3.C: New test.
	* gcc.dg/Wstringop-overflow-15.c: New test.

gcc/ChangeLog:

	PR tree-optimization/91457
	* builtins.c (c_strlen): Rename argument and 

[Bug c++/91493] New: g++ 9.2.1 crashes compiling clickhouse

2019-08-19 Thread rafaeldtinoco at ubuntu dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91493

Bug ID: 91493
   Summary: g++ 9.2.1 crashes compiling clickhouse
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rafaeldtinoco at ubuntu dot com
  Target Milestone: ---

The following function:

std::string toString(const ColumnDefaultKind kind)
{
static const std::unordered_map map{
{ ColumnDefaultKind::Default, AliasNames::DEFAULT },
{ ColumnDefaultKind::Materialized, AliasNames::MATERIALIZED },
{ ColumnDefaultKind::Alias, AliasNames::ALIAS }
};

const auto it = map.find(kind);
return it != std::end(map) ? it->second : throw Exception{"Invalid
ColumnDefaultKind", ErrorCodes::LOGICAL_ERROR};
}

causes gcc9 (with attached dump) to crash while other similar function (in
related syntax):

ColumnDefaultKind columnDefaultKindFromString(const std::string & str)
{
static const std::unordered_map map{
{ AliasNames::DEFAULT, ColumnDefaultKind::Default },
{ AliasNames::MATERIALIZED, ColumnDefaultKind::Materialized },
{ AliasNames::ALIAS, ColumnDefaultKind::Alias }
};

const auto it = map.find(str);
return it != std::end(map) ? it->second : throw Exception{"Unknown column
default specifier: " + str, ErrorCodes::LOGICAL_ERROR};
}

does not. Changing the syntax to:

std::string toString(const ColumnDefaultKind kind)
{
static const std::unordered_map map{
{ ColumnDefaultKind::Default, AliasNames::DEFAULT },
{ ColumnDefaultKind::Materialized, AliasNames::MATERIALIZED },
{ ColumnDefaultKind::Alias, AliasNames::ALIAS }
};

const auto it = map.find(kind);

if (it != std::end(map))
throw Exception{"Invalid ColumnDefaultKind",
ErrorCodes::LOGICAL_ERROR};

return it->second;
}

fixes the issue.

[Bug lto/91478] FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)

2019-08-19 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91478

--- Comment #3 from dave.anglin at bell dot net ---
On 2019-08-19 2:51 a.m., rguenth at gcc dot gnu.org wrote:
> Is this a new failure, thus can it be bisected somehow?
The failure was introduced in r273662:
https://gcc.gnu.org/ml/gcc-cvs/2019-07/msg00827.html

[Bug rtl-optimization/91347] [7/8/9/10 Regression] pointer_string in linux vsprintf.c is miscompiled when sibling calls are optimized

2019-08-19 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91347

--- Comment #18 from dave.anglin at bell dot net ---
On 2019-08-19 4:36 a.m., ebotcazou at gcc dot gnu.org wrote:
> Created attachment 46728
>   --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46728=edit
> Execution test
Works on hppa without -fno-inline.

[Bug ada/91492] [10 regression] Ada documentation issue starting with r274637

2019-08-19 Thread hp at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91492

Hans-Peter Nilsson  changed:

   What|Removed |Added

 CC||hp at gcc dot gnu.org

--- Comment #1 from Hans-Peter Nilsson  ---
Apparently also happens for targets where ada isn't enabled (like cris-elf).

Re: [PATCH 2/8] bpf: new GCC port

2019-08-19 Thread Jim Wilson
On Mon, Aug 19, 2019 at 5:01 AM Segher Boessenkool
 wrote:
>
> On Thu, Aug 15, 2019 at 12:22:46AM +0200, Jose E. Marchesi wrote:
> > --- a/configure
> > +++ b/configure
> > @@ -754,6 +754,7 @@ infodir
> >  docdir
> >  oldincludedir
> >  includedir
> > +runstatedir
> >  localstatedir
> >  sharedstatedir
> >  sysconfdir
>
> (etc.)
>
> You seem to have generated this with the wrong version of auto, or
> the wrong options, or the previous version was.  Please check?  Or, what
> else caused this change?

My experience is that this is a commonly added patch to the system
autoconf binary, e.g. /usr/bin/autoconf.  So you need to build your
own autoconf from the FSF sources to get an exact match.  Or maybe use
a different linux distro that doesn't modify autoconf.  But personally
I just build my own autoconf binaries to avoid this problem.

Jim


Re: Help with bug in GCC garbage collector

2019-08-19 Thread Steve Ellcey
On Mon, 2019-08-19 at 17:05 -0600, Jeff Law wrote:
> 
> There's a real good chance Martin Liska has already fixed this.  He's
> made a couple fixes in the last week or so with the interactions
> between
> the GC system and the symbol tables.
> 
> 
> 2019-08-15  Martin Liska  
> 
> PR ipa/91404
> * passes.c (order): Remove.
> (uid_hash_t): Likewise).
> (remove_cgraph_node_from_order): Remove from set
> of pointers (cgraph_node *).
> (insert_cgraph_node_to_order): New.
> (duplicate_cgraph_node_to_order): New.
> (do_per_function_toporder): Register all 3 cgraph hooks.
> Skip removed_nodes now as we know about all of them.
> 
> 
> The way I'd approach would be to configure a compiler with
> --enable-checking=gc,gcac, just build it through stage1.  Then run your
> test through that compiler which should fail.  THen apply Martin's patch
> (or update to the head of the trunk), rebuild the stage1 compiler and
> verify it works.

I had already built a compiler with --enable-checking=gc,gcac, that did
not catch the bug (I still got a segfault).  I did update my sources
though and the bug does not happen at ToT so it looks like Martin's
patch did fix my bug.

Steve Ellcey
sell...@marvell.com


Re: Help with bug in GCC garbage collector

2019-08-19 Thread Jeff Law
On 8/19/19 4:59 PM, Steve Ellcey wrote:
> I was wondering if anyone could help me investigate a bug I am
> seeing in the GCC garbage collector.  This bug (which may or may not
> be PR 89179) is causing a segfault in GCC, but when I try to create
> a preprocessed source file, the bug doesn't trigger.  The problem is
> with the garbage collector trying to mark some memory that has
> already been freed.  I have tracked down the initial allocation to:
> 
> symbol_table::allocate_cgraph_symbol
> 
> It has:
> 
> node = ggc_cleared_alloc ();
> 
> to allocate a cgraph node.  With the GGC debugging on I see this 
> allocated:
> 
> Allocating object, requested size=360, actual=360 at 0x7029c210
> on 0x41b148c0
> 
> then freed:
> 
> Freeing object, actual size=360, at 0x7029c210 on 0x41b148c0
> 
> And then later, while the garbage collector is marking nodes, I see:
> 
> Marking 0x7029c210
> 
> The garbage collector shouldn't be marking this node if has already 
> been freed.
> 
> So I guess my main question is how do I figure out how the garbage 
> collector got to this memory location?  I am guessing some GTY
> pointer is still pointing to it and hadn't got nulled out when the
> memory was freed.  Does that seem like the most likely cause?
> 
> I am not sure why I am only running into this with one particular 
> application on my Aarch64 platform.  I am building it with -fopenmp, 
> which could have something to do with it (though there are no simd
> functions in the application).  The application is not that large as
> C++ programs go.
There's a real good chance Martin Liska has already fixed this.  He's
made a couple fixes in the last week or so with the interactions between
the GC system and the symbol tables.


2019-08-15  Martin Liska  

PR ipa/91404
* passes.c (order): Remove.
(uid_hash_t): Likewise).
(remove_cgraph_node_from_order): Remove from set
of pointers (cgraph_node *).
(insert_cgraph_node_to_order): New.
(duplicate_cgraph_node_to_order): New.
(do_per_function_toporder): Register all 3 cgraph hooks.
Skip removed_nodes now as we know about all of them.


The way I'd approach would be to configure a compiler with
--enable-checking=gc,gcac, just build it through stage1.  Then run your
test through that compiler which should fail.  THen apply Martin's patch
(or update to the head of the trunk), rebuild the stage1 compiler and
verify it works.


jeff


Re: [EXTERNAL]Re: [PATCH 1/2][MIPS] Emit .note.GNU-stack for soft-float linux targets.

2019-08-19 Thread Jeff Law
On 8/12/19 9:21 AM, Dragan Mladjenovic wrote:
> On 09.08.2019. 23:31, Jeff Law wrote:
>> On 8/5/19 4:47 AM, Dragan Mladjenovic wrote:
>>> From: "Dragan Mladjenovic" 
>>>
>>> gcc/ChangeLog:
>>>
>>> 2019-08-05  Dragan Mladjenovic  
>>>
>>> * config/mips/linux.h (NEED_INDICATE_EXEC_STACK): Define to
>>> TARGET_SOFT_FLOAT.
>>> * config/mips/mips.c (TARGET_ASM_FILE_END): Define to ...
>>> (mips_asm_file_end): New function. Delegate to
>>> file_end_indicate_exec_stack if NEED_INDICATE_EXEC_STACK is true.
>>> * config/mips/mips.h (NEED_INDICATE_EXEC_STACK): Define to 0.
>>>
>>> libgcc/ChangeLog:
>>>
>>> 2019-08-05  Dragan Mladjenovic  
>>>
>>> * config/mips/gnustack.h: New file.
>>> * config/mips/crti.S: Include gnustack.h.
>>> * config/mips/crtn.S: Likewise.
>>> * config/mips/mips16.S: Likewise.
>>> * config/mips/vr4120-div.S: Likewise.
>> Seems reasonable.  What testing has been done for this patch?  I don't
>> doubt it works for the MIPS linux targets, I'm more interested in making
>> sure it doesn't do the wrong thing for the embedded mips targets.
> 
> I've built a cross mips-mti-elf toolchain, albeit with reduced multilib, 
> but still there were not .note.GNU-stack in sysroot.
> Is this enough?
Yea.  Mostly just wanted to make sure the *-elf targets still build -- I
didn't expect problems, but it's good to have sanity checking.

> 
>  >
>  > Do you have write access to the repository?
>  >
> 
> I do not have write access to the repository.
We should probably fix that.

https://sourceware.org/cgi-bin/pdw/ps_form.cgi

List me as your sponsor.



jeff



Re: [PATCHv5] Fix not 8-byte aligned ldrd/strd on ARMv5 (PR 89544)

2019-08-19 Thread Jeff Law
On 8/15/19 1:47 PM, Bernd Edlinger wrote:
> On 8/15/19 6:29 PM, Richard Biener wrote:
 Please split it into the parts for the PR and parts making the
 asserts not trigger.

>>> Yes, will do.
>>>
> Okay, here is the rest of the PR 89544 fix,
> actually just an optimization, making the larger stack alignment
> known to the middle-end, and the test cases.
> 
> 
> Boot-strapped and reg-tested on x86_64-pc-linux-gnu and arm-linux-gnueabihf.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 
> 
> patch-arm-align-abi.diff
> 
> 2019-08-15  Bernd Edlinger  
> 
>   PR middle-end/89544
>   * function.c (assign_parm_find_stack_rtl): Use larger alignment
>   when possible.
> 
> testsuite:
> 2019-08-15  Bernd Edlinger  
> 
>   PR middle-end/89544
>   * gcc.target/arm/unaligned-argument-1.c: New test.
>   * gcc.target/arm/unaligned-argument-2.c: New test.
OK.

Given the sensitivity of this code, let's give the tester a chance to
run with this patch applied before we add the next one for sanitizing
the middle end interface.

jeff


Help with bug in GCC garbage collector

2019-08-19 Thread Steve Ellcey
I was wondering if anyone could help me investigate a bug I am seeing
in the GCC garbage collector.  This bug (which may or may not be PR
89179) is causing a segfault in GCC, but when I try to create a
preprocessed source file, the bug doesn't trigger.  The problem is with
the garbage collector trying to mark some memory that has already been
freed.  I have tracked down the initial allocation to:

symbol_table::allocate_cgraph_symbol

It has:

node = ggc_cleared_alloc ();

to allocate a cgraph node.  With the GGC debugging on I see this
allocated:

Allocating object, requested size=360, actual=360 at 0x7029c210 on 
0x41b148c0

then freed:

Freeing object, actual size=360, at 0x7029c210 on 0x41b148c0

And then later, while the garbage collector is marking nodes, I see:

Marking 0x7029c210

The garbage collector shouldn't be marking this node if has already
been freed.

So I guess my main question is how do I figure out how the garbage
collector got to this memory location?  I am guessing some GTY pointer
is still pointing to it and hadn't got nulled out when the memory was
freed.  Does that seem like the most likely cause?

I am not sure why I am only running into this with one particular
application on my Aarch64 platform.  I am building it with -fopenmp,
which could have something to do with it (though there are no simd functions in 
the application).  The application is not that large as C++ programs go.

Steve Ellcey
sell...@marvell.com


Re: [PATCH] Improve DSE to handle redundant zero initializations.

2019-08-19 Thread Jeff Law
On 8/19/19 1:53 PM, Matthew Beliveau wrote:

>> Jeff
> 
> DSE-3.patch
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2019-08-19  Matthew Beliveau  
> 
>   * tree-ssa-dse.c (dse_optimize_redundant_stores): Improved check to
>   catch more redundant zero initialization cases.
>   (dse_dom_walker::dse_optimize_stmt): Likewise.
> 
>   * gcc.dg/tree-ssa/redundant-assign-zero-1.c: New test.
>   * gcc.dg/tree-ssa/redundant-assign-zero-2.c: New test.
OK for the trunk.  THanks for your patience.

Jeff


Re: [PATCH,i386] Don't use errno when freestanding (was: config/i386/xmmintrin.h: Only #include if __STDC_HOSTED__)

2019-08-19 Thread Jeff Law
On 8/18/19 10:29 AM, Gerald Pfeifer wrote:
> On Sat, 9 Dec 2017, Jakub Jelinek wrote:
>>> Some users on FreeBSD noticed a problem when trying to use GCC to
>>> build things in a standalone environment that manifests itself as
>>>
>>> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/xmmintrin.h:34 
>>> from
>>> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/immintrin.h:29 
>>> from
>>> /workspace/src/sys/crypto/aesni/intel_sha256.c:62 
>>> In function '_mm_malloc':
>>> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/mm_malloc.h:39: 
>>> error: 'errno' undeclared (first use in this function)
>>>
>>> It turns out the clang version of xmmintrin.h does not include mm_malloc.h 
>>> if !__STDC_HOSTED__ whereas ours unconditionally does so.
>>
>> Wouldn't it be better to just ifdef out parts of gmm_malloc.h (pmm_malloc.h
>> should be ok)?
> 
> Very good point, Jakub.  Thank you!  
> 
> Somehow I thought I had submitted this updated patch, but apparently 
> not so. :-(  (This has been on my autotester for ages.)
> 
> Okay?  And if so, okay for GCC 9 after a while?
> 
> Gerald
> 
> 
> 2019-08-18  Gerald Pfeifer  
>  
>   * config/i386/gmm_malloc.h: Only include errno.h and use errno
>   if __STDC_HOSTED__.
OK.
jeff



Re: [PATCH] Intrinsic documentation for DIM, MOD and MODULO.

2019-08-19 Thread Jeff Law
On 8/19/19 10:19 AM, Steve Kargl wrote:
> On Mon, Aug 19, 2019 at 09:08:12AM -0600, Jeff Law wrote:
>> On 8/19/19 3:11 AM, Mark Eggleston wrote:
>>> The intrinsics DIM, MOD and MODULO can accept arguments of different
>>> kinds and return values with the larger of the two kinds. Notes to this
>>> effect have been added as they were missing from the documentation.
>>>
>>> Please find attached the patch.
>>>
>>> ChangeLog:
>>>
>>> gcc/fortran/ChangeLog
>>>
>>>     Mark Eggleston  
>>>
>>>     PR fortran/89236
>>>     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
>>>
>> Do we want to be more specific about what types are accepted as a GNU
>> extension for these operators?
>>
> 
> The current documentation already has that info.
Ah, in that case Mark's patch seems like a no-brainer :-)

Jeff


Re: [PATCH] Adding _Dependent_ptr type qualifier in C part 1/3

2019-08-19 Thread Joseph Myers
On Tue, 30 Jul 2019, Martin Sebor wrote:

> On 7/30/19 1:13 AM, Akshat Garg wrote:
> > Hi,
> > This patch includes C front-end code for a type qualifier _Dependent_ptr.
> 
> Just some very high-level comments/questions.  I only followed
> the _Dependent_ptr discussion from a distance and I'm likely
> missing some context so the first thing I looked for in this
> patch is documentation of the new qualifier.  Unless it's

The first question for any new thing that is syntactically a qualifier is: 
is it intended generally to be counted as a qualifier where the standard 
refers to qualified type, the unqualified version of a type, etc.?  Or is 
it, like _Atomic, a qualifier only syntactically and generally excluded 
from references to qualifiers?

For the _Atomic implementation I had to go through all the references to 
qualifiers or TYPE_MAIN_VARIANT in the front end and consider in each case 
whether it handled _Atomic correctly, given that _Atomic is not counted as 
a qualifier in the standard (so the unqualified version of const _Atomic 
int is _Atomic int not int, and so can't be derived simply by using 
TYPE_MAIN_VARIANT, for example).  Some cases didn't need changing because 
the handling (e.g. diagnostic for different types) was still appropriate 
for _Atomic even though not formally a qualifier, but plenty did need 
changing and associated tests added.

Such a check of front end code is probably unavoidable (before a change is 
ready for trunk, not necessarily for an initial rough RFC patch) for any 
new qualifier, whether it counts as a qualifier in standard terms or not 
(and the patch reviewer will need to do their own check of references to 
qualifiers or TYPE_MAIN_VARIANT that didn't get changed by the patch), but 
the answer to that question helps indicate whether the default is to 
expect code to need changing for the new qualifier or not.

> you point to it?  (In that case, or if a proposal is planned,
> the feature should probably either only be available with
> -std=c2x and -std=gnu2x or a pedantic warning should be issued

There should not be any -std=c2x (flag_isoc2x) conditionals simply based 
on "a proposal is planned".  flag_isoc2x conditionals (pedwarn_c11 calls, 
etc.) should be for cases where a feature is *accepted and committed into 
the C2x branch of Jens's git repository for the C standard*, not for 
something that might be proposed, or is proposed, but doesn't yet have 
specific text integrated into the text of the standard.

If something is simply proposed *and we've concluded it's a good feature 
to have as an extension in any case* then you have a normal 
pedwarn-if-pedantic (no condition on standard version) as for any GNU 
extension (and flag_isoc2x conditions / changes to use pedwarn_c11 instead 
can be added later if the extension is added to the standard).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [13/13] Add a pass_by_reference flag to function_arg_info

2019-08-19 Thread Jeff Law
On 8/19/19 9:24 AM, Richard Sandiford wrote:
> This patch adds a flag that tells targets whether an argument
> has been converted to pass-by-reference form.  This replaces
> assign_parm_data_one::passed_pointer in function.c.
> 
> The flag is set automatically for places that call
> apply_pass_by_reference_rules.  Places that apply
> pass-by-reference manually need to set it themselves.
> 
> (After previous changes, no targets apply pass-by-reference
> manually.  They all go through apply_pass_by_reference_rules.)
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * calls.h (function_arg_info): Add a pass_by_reference field,
>   defaulting to false.
>   * calls.c (apply_pass_by_reference_rules): Set pass_by_reference
>   when applying pass-by-reference semantics.
>   (initialize_argument_information): Likewise.
>   (emit_library_call_value_1): Likewise.
>   * function.c (assign_parm_data_one): Remove passed_pointer field.
>   (assign_parm_find_data_types): Don't set it.
>   (assign_parm_find_stack_rtl, assign_parm_adjust_stack_rtl)
>   (assign_parm_setup_reg, assign_parms, gimplify_parameters): Use
>   arg.pass_by_reference instead of passed_pointer.
> 
OK.  I think that's the whole series.  I don't expect any problems, but
my tester will pick testing across the various targets ~24hrs after
you've committed the changes.

jeff


Re: [12/13] Make calls.c use function_arg_info internally

2019-08-19 Thread Jeff Law
On 8/19/19 9:23 AM, Richard Sandiford wrote:
> This patch makes the two main calls.c argument-processing
> routines track the state of the argument in a function_arg_info
> instead of using separate mode variables.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * calls.c (emit_library_call_value_1): Merge arg and orig_arg
>   into a single function_arg_info, updating its fields when we
>   apply pass-by-reference and promotion semantics.  Use the
>   function_arg_info to track the mode rather than keeping it in
>   a separate local variable.
>   (initialize_argument_information): Likewise.  Base the final
>   arg_to_skip on this new function_arg_info rather than creating
>   a new one from scratch.
> 
OK
jeff


Re: [11/13] Make function.c use function_arg_info internally

2019-08-19 Thread Jeff Law
On 8/19/19 9:22 AM, Richard Sandiford wrote:
> This patch adds a function_arg_info field to assign_parm_data_one,
> so that:
> 
>   - passed_type -> arg.type
>   - promoted_mode -> arg.mode
>   - named_arg -> arg.named
> 
> We can then pass this function_arg_info directly to the converted
> hooks.
> 
> Between the initialisation of the assign_parm_data_one and the
> application of promotion rules (which is a state internal to
> assign_parm_find_data_types), arg.mode is equivalent to passed_mode
> (i.e. to TYPE_MODE).
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * function.c (assign_parm_data_one): Replace passed_type,
>   promoted_mode and named_arg with a function_arg_info field.
>   (assign_parm_find_data_types): Remove local variables and
>   assign directly to "data".  Make data->passed_mode shadow
>   data->arg.mode until promotion, then assign the promoted
>   mode to data->arg.mode.
>   (assign_parms_setup_varargs, assign_parm_find_entry_rtl)
>   (assign_parm_find_stack_rtl, assign_parm_adjust_entry_rtl)
>   (assign_parm_remove_parallels, assign_parm_setup_block_p)
>   (assign_parm_setup_block, assign_parm_setup_reg)
>   (assign_parm_setup_stack, assign_parms, gimplify_parameters): Use
>   arg.mode instead of promoted_mode, arg.type instead of passed_type
>   and arg.named instead of named_arg.  Use data->arg for
>   function_arg_info structures that had the field values passed_type,
>   promoted_mode and named_arg.  Base other function_arg_infos on
>   data->arg, changing the necessary properties.
OK
jeff


Re: Fix up -fexcess-precision handling in LTO (was Re: [GCC][middle-end] Add rules to strip away unneeded type casts in expressions (2nd patch))

2019-08-19 Thread Joseph Myers
On Tue, 30 Jul 2019, Jakub Jelinek wrote:

> Furthermore, some comments claimed that the proper EXCESS_PRECISION_STANDARD
> handling requires FE support, but that also doesn't seem to be the case
> these days, some FEs even just use EXCESS_PRECISION_STANDARD by default
> (go, D).
> 
> So, the following patch gets rid of flag_excess_precision and renames
> flag_excess_precision_cmdline to flag_excess_precision, plus adds
> Optimization flag to that command line option, so that we remember it during
> compilation and e.g. during LTO can then have some functions with standard
> excess precision and others with fast excess precision.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK minus the removal of the comment in lhd_post_options.  Proper handling 
requires front-end support (to generate GIMPLE with the operations in the 
intended type).  Back-end support (to avoid having insn patterns claiming 
to operate on the types the processor in fact does not have direct support 
for arithmetic on), although not strictly required, is a very good idea, 
to make it more obvious if something is wrongly generating arithmetic on 
inappropriate types.  And then you need the middle-end support (to avoid 
transformations introducing operations in the types that aren't meant to 
have direct operations, even if in fact the semantics are equivalent) as 
well.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] PR libstdc++/91371 make std::is_function handle other calling conventions

2019-08-19 Thread Jonathan Wakely

On 16/08/19 16:35 +0100, Jonathan Wakely wrote:

The x86 attributes such as ms_abi, stdcall, fastcall etc. alter the
function type, which means that functions with one of those attributes
do not match any of the partial specializations of std::is_function.

Rather than duplicating the list for every calling convention, this
adds a fallback to the std::is_function primary template which
identifies other function types. The fallback works by assuming that
all function types fall into one of two categories: referenceable and
abominable. The former can be detected by testing for
function-to-pointer decay, and the latter are non-referenceable types
that are not cv void.

In order to detect referenceable types it's necessary to replace the
current definition of __is_referenceable with one that doesn't depend on
std::is_function, to avoid a cycle. The definition of std::decay can
also be modified to only act on referenceable function types, because
abominable function types do not decay.

PR libstdc++/91371
* include/std/type_traits (__declval, declval, __void_t): Declare
earlier in the file.
(__is_referenceable): Rewrite to not depend on is_function.
(__is_referenceable_function): New trait to identify non-abominable
function types.
(__is_qualified_function): New alias to identify abominable function
types.
(is_function): Make primary template use __is_referenceable_function
and __is_qualified_function to detect function types not covered by
the partial specializations.
(__decay_selector): Use __is_referenceable_function instead of
is_function.
(__decay_selector<_Up, false, true>): Do not use add_pointer.
* testsuite/20_util/bind/91371.cc: New test.
* testsuite/20_util/is_function/91371.cc: New test.
* testsuite/20_util/is_function/value.cc: Check more pointer types.
* testsuite/20_util/is_member_function_pointer/91371.cc: New test.

Tested x86_64-linux. Not committed yet.

I'd like to hear Daniel's thoughts on this approach, as he wrote the
original __is_referenceable trait, and much of .

This new __is_referenceable simply uses void_t to detect whether
forming T& is valid.

The detection for function-to-pointer decay works by checking whether
static_cast(declval()) is well-formed. If T is not a class
type (which could have a conversion operator) and is not nullptr or cv
void*cv (which can convert to nullptr* and cv void*cv* repectively)
then it must be a function.

The detection for abominable function types assumes that all types are
referenceable except functions with cv- or ref-qualifiers and cv void
types. So if it's not referenceable and not void, it's an abominable
function type.


Alisdair pointed out a much simpler implementation of is_function:

 /// is_function
 template
   struct is_function
   : public __bool_constant::value> { };

 template
   struct is_function<_Tp&>
   : public false_type { };

 template
   struct is_function<_Tp&&>
   : public false_type { };

I'm testing the attached patch which uses the above trick and keeps my
earlier simplification for __is_referenceable. I plan to commit this,
probably tomorrow.


commit 310eae1386a8410682b86aef3fa5391018583577
Author: Jonathan Wakely 
Date:   Mon Aug 19 22:04:58 2019 +0100

PR libstdc++/91371 make std::is_function handle other calling conventions

The x86 attributes such as ms_abi, stdcall, fastcall etc. alter the
function type, which means that functions with one of those attributes
do not match any of the partial specializations of std::is_function.

Rather than duplicating the list for every calling convention, use a
much simpler definition of std::is_function.

Also redefine __is_referenceable to not rely on partial specializations
for each type of referenceable function.

PR libstdc++/91371
* include/std/type_traits (is_function): Simplify definition. Remove
partial specializations for function types.
(__is_referenceable): Simplify definition.
* testsuite/20_util/bind/91371.cc: New test.
* testsuite/20_util/is_function/91371.cc: New test.
* testsuite/20_util/is_function/value.cc: Check more pointer types.
* testsuite/20_util/is_member_function_pointer/91371.cc: New test.
* testsuite/20_util/is_object/91371.cc: New test.

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 44db2cade5d..443208813b1 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -223,11 +223,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   struct __failure_type
   { };
 
-  // Primary type categories.
-
   template
 struct remove_cv;
 
+  template
+struct is_const;
+
+  // Primary type categories.
+
   template
 struct __is_void_helper
 : public false_type { };
@@ -481,105 

Go patch committed: New debugging functions

2019-08-19 Thread Ian Lance Taylor
This Go patch by Than McIntosh adds some new debugging output
methods/functions, to dump named objects, package bindings, and the
top level Gogo package list.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 274678)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-b0ba5daa8216a0424b24f74466cedab0b986f3b4
+a453eebae76296a39a1ded5bd2bffa78bedf40bd
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 274169)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -5430,6 +5430,29 @@ Gogo::convert_named_types_in_bindings(Bi
 }
 }
 
+void
+debug_go_gogo(Gogo* gogo)
+{
+  if (gogo != NULL)
+gogo->debug_dump();
+}
+
+void
+Gogo::debug_dump()
+{
+  std::cerr << "Packages:\n";
+  for (Packages::const_iterator p = this->packages_.begin();
+   p != this->packages_.end();
+   ++p)
+{
+  const char *tag = "  ";
+  if (p->second == this->package_)
+tag = "* ";
+  std::cerr << tag << "'" << p->first << "' "
+<< p->second->pkgpath() << " " << ((void*)p->second) << "\n";
+}
+}
+
 // Class Function.
 
 Function::Function(Function_type* type, Named_object* enclosing, Block* block,
@@ -8593,6 +8616,61 @@ Named_object::get_id(Gogo* gogo)
   return decl_name;
 }
 
+void
+debug_go_named_object(Named_object* no)
+{
+  if (no == NULL)
+{
+  std::cerr << "";
+  return;
+}
+  std::cerr << "'" << no->name() << "': ";
+  const char *tag;
+  switch (no->classification())
+{
+  case Named_object::NAMED_OBJECT_UNINITIALIZED:
+tag = "uninitialized";
+break;
+  case Named_object::NAMED_OBJECT_ERRONEOUS:
+tag = "";
+break;
+  case Named_object::NAMED_OBJECT_UNKNOWN:
+tag = "";
+break;
+  case Named_object::NAMED_OBJECT_CONST:
+tag = "constant";
+break;
+  case Named_object::NAMED_OBJECT_TYPE:
+tag = "type";
+break;
+  case Named_object::NAMED_OBJECT_TYPE_DECLARATION:
+tag = "type_decl";
+break;
+  case Named_object::NAMED_OBJECT_VAR:
+tag = "var";
+break;
+  case Named_object::NAMED_OBJECT_RESULT_VAR:
+tag = "result_var";
+break;
+  case Named_object::NAMED_OBJECT_SINK:
+tag = "";
+break;
+  case Named_object::NAMED_OBJECT_FUNC:
+tag = "func";
+break;
+  case Named_object::NAMED_OBJECT_FUNC_DECLARATION:
+tag = "func_decl";
+break;
+  case Named_object::NAMED_OBJECT_PACKAGE:
+tag = "package";
+break;
+  default:
+tag = "";
+break;
+  };
+  std::cerr << tag << "\n";
+}
+
 // Get the backend representation for this named object.
 
 void
@@ -9140,6 +9218,31 @@ Bindings::traverse(Traverse* traverse, b
   return TRAVERSE_CONTINUE;
 }
 
+void
+Bindings::debug_dump()
+{
+  std::set defs;
+  for (size_t i = 0; i < this->named_objects_.size(); ++i)
+defs.insert(this->named_objects_[i]);
+  for (Contour::iterator p = this->bindings_.begin();
+   p != this->bindings_.end();
+   ++p)
+{
+  const char* tag = "  ";
+  if (defs.find(p->second) != defs.end())
+tag = "* ";
+  std::cerr << tag;
+  debug_go_named_object(p->second);
+}
+}
+
+void
+debug_go_bindings(Bindings* bindings)
+{
+  if (bindings != NULL)
+bindings->debug_dump();
+}
+
 // Class Label.
 
 // Clear any references to this label.
Index: gcc/go/gofrontend/gogo.h
===
--- gcc/go/gofrontend/gogo.h(revision 274169)
+++ gcc/go/gofrontend/gogo.h(working copy)
@@ -341,6 +341,9 @@ class Gogo
   set_debug_optimization(bool b)
   { this->debug_optimization_ = b; }
 
+  // Dump to stderr for debugging
+  void debug_dump();
+
   // Return the size threshold used to determine whether to issue
   // a nil-check for a given pointer dereference. A threshold of -1
   // implies that all potentially faulting dereference ops should
@@ -3068,6 +3071,9 @@ class Bindings
   first_declaration()
   { return this->bindings_.empty() ? NULL : this->bindings_.begin()->second; }
 
+  // Dump to stderr for debugging
+  void debug_dump();
+
  private:
   Named_object*
   add_named_object_to_contour(Contour*, Named_object*);
@@ -3746,4 +3752,10 @@ extern Gogo* go_get_gogo();
 // interface.
 extern bool saw_errors();
 
+// For use in the debugger
+extern void debug_go_gogo(Gogo*);
+extern void debug_go_named_object(Named_object*);
+extern void debug_go_bindings(Bindings*);
+
+
 #endif // !defined(GO_GOGO_H)


Re: [10/13] Add a apply_pass_by_reference_rules helper

2019-08-19 Thread Jeff Law
On 8/19/19 9:21 AM, Richard Sandiford wrote:
> This patch adds a helper routine that applies pass-by-reference
> semantics to an existing function_arg_info.
> 
> The c6x part means that c6x_function_arg and c6x_function_arg_advance
> see the same "named" value as pass_by_reference did, rather than
> pass_by_reference seeing "true" and the others seeing "false".
> This doesn't matter because the c6x port doesn't care about namedness.
> 
> The rs6000.c patch removes an assignment to "type", but the only
> later code to use it was the patched promote_mode line.
> 
> (The reason for patching these places despite the above is that
> often target code gets used as a basis for new targets or changes
> to existing ones.)
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * calls.h (apply_pass_by_reference_rules): Declare.
>   * calls.c (apply_pass_by_reference_rules): New function.
>   * config/c6x/c6x.c (c6x_call_saved_register_used): Use it.
>   * config/rs6000/rs6000-call.c (rs6000_parm_needs_stack): Likewise.
>   * config/s390/s390.c (s390_call_saved_register_used): Likewise.
>   * function.c (assign_parm_find_data_types): Likewise.
>   * var-tracking.c (prepare_call_arguments): Likewise.
> 
OK
jeff


[Bug c++/79817] GCC does not recognize [[deprecated]] attribute for namespace

2019-08-19 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79817

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #4 from Marek Polacek  ---
I have a WIP patch:

w.C: In function ‘int main()’:
w.C:5:9: warning: ‘ns’ is deprecated [-Wdeprecated-declarations]
5 | ns::i = 0;
  | ^
w.C:1:26: note: declared here
1 | namespace [[deprecated]] ns { int i ; }
  |  ^~

Re: [09/13] Use function_arg_info for TARGET_MUST_PASS_IN_STACK

2019-08-19 Thread Jeff Law
On 8/19/19 9:20 AM, Richard Sandiford wrote:
> Use function_arg_info for TARGET_MUST_PASS_IN_STACK.
> 
> The hook is passed the promoted mode instead of the original type mode.
> 
> The expr.h reference in the documentation is no longer correct, but
> pointing to calls.h or calls.c doesn't help much either.  I just left
> this as-is since it's not related to the point of the series.
> 
> After previous changes, most places already pass arg.mode and arg.type.
> Only i386 and mcore needed to construct a new one out of nothing.
> rs6000 needs to construct one slightly earlier than before.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (must_pass_in_stack): Take a function_arg_info instead
>   of a mode and a type.
>   * doc/tm.texi: Regenerate.
>   * calls.h (must_pass_in_stack_var_size): Take a function_arg_info
>   instead of a mode and a type.
>   (must_pass_in_stack_var_size_or_pad): Likewise.
>   * calls.c (must_pass_in_stack_var_size): Likewise.
>   (must_pass_in_stack_var_size_or_pad): Likewise.
>   (initialize_argument_information): Update call to
>   targetm.calls.must_pass_in_stack.
>   (must_pass_va_arg_on_stack): Likewise.
>   * function.c (assign_parm_find_entry_rtl): Likewise.
>   * targhooks.c (hook_pass_by_reference_must_pass_in_stack): Likewise.
>   * config/alpha/alpha.c (alpha_function_arg): Likewise.
>   (alpha_function_arg_advance): Likewise.
>   * config/cr16/cr16.c (cr16_function_arg): Likewise.
>   (cr16_function_arg_advance): Likewise.
>   * config/cris/cris.c (cris_pass_by_reference): Likewise.
>   (cris_arg_partial_bytes): Likewise.
>   * config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise.
>   * config/lm32/lm32.c (lm32_function_arg): Likewise.
>   * config/mcore/mcore.c (mcore_num_arg_regs): Likewise.
>   (mcore_function_arg, mcore_arg_partial_bytes): Likewise.
>   * config/mips/mips.c (mips_pass_by_reference): Likewise.
>   * config/mmix/mmix.c (mmix_function_arg_advance): Likewise.
>   (mmix_function_arg_1, mmix_pass_by_reference): Likewise.
>   * config/sh/sh.c (sh_pass_by_reference): Likewise.
>   * config/stormy16/stormy16.c (xstormy16_function_arg): Likewise.
>   * config/xtensa/xtensa.c (xtensa_function_arg_advance): Likewise.
>   * config/arm/arm.c (arm_must_pass_in_stack): Take a function_arg_info
>   instead of a mode and a type.
>   * config/fr30/fr30.c (fr30_must_pass_in_stack): Likewise.
>   (fr30_num_arg_regs): Likewise.
>   (fr30_setup_incoming_varargs): Update calls accordingly.
>   (fr30_arg_partial_bytes, fr30_function_arg): Likewise.
>   (fr30_function_arg_advance): Likewise.
>   * config/frv/frv.c (frv_must_pass_in_stack): Take a function_arg_info
>   instead of a mode and a type.
>   * config/gcn/gcn.c (num_arg_regs): Likewise.
>   (gcn_function_arg, gcn_function_arg_advance): Update calls to
>   num_arg_regs and targetm.calls.must_pass_in_stack.
>   (gcn_arg_partial_bytes): Likewise.
>   * config/i386/i386.c (ix86_must_pass_in_stack): Take a
>   function_arg_info instead of a mode and a type.
>   (classify_argument): Update call accordingly.
>   * config/nds32/nds32.c (nds32_must_pass_in_stack): Take a
>   function_arg_info instead of a mode and a type.
>   * config/rs6000/rs6000-internal.h (rs6000_must_pass_in_stack):
>   Likewise.
>   * config/rs6000/rs6000-call.c (rs6000_must_pass_in_stack): Likewise.
>   (rs6000_parm_needs_stack): Update call accordingly.
>   (setup_incoming_varargs): Likewise.
> 
OK
jeff


Merge from trunk to gccgo branch

2019-08-19 Thread Ian Lance Taylor
I've merged trunk revision 274678 to the gccgo branch.

Ian


Re: [08/13] Use function_arg_info for TARGET_CALLEE_COPIES

2019-08-19 Thread Jeff Law
On 8/19/19 9:19 AM, Richard Sandiford wrote:
> Use function_arg_info for TARGET_CALLEE_COPIES.
> 
> The hook is passed the unpromoted type mode instead of the promoted mode.
> 
> The aarch64 definition is redundant, but worth keeping for emphasis.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (callee_copies): Take a function_arg_info instead
>   of a mode, type and named flag.
>   * doc/tm.texi: Regenerate.
>   * targhooks.h (hook_callee_copies_named): Take a function_arg_info
>   instead of a mode, type and named flag.
>   (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete.
>   (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise.
>   (hook_bool_CUMULATIVE_ARGS_arg_info_true): New function.
>   * targhooks.c (hook_callee_copies_named): Take a function_arg_info
>   instead of a mode, type and named flag.
>   (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete.
>   (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise.
>   (hook_bool_CUMULATIVE_ARGS_arg_info_true): New function.
>   * calls.h (reference_callee_copied): Take a function_arg_info
>   instead of a mode, type and named flag.
>   * calls.c (reference_callee_copied): Likewise.
>   (initialize_argument_information): Update call accordingly.
>   (emit_library_call_value_1): Likewise.
>   * function.c (gimplify_parameters): Likewise.
>   * config/aarch64/aarch64.c (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_false instead of
>   hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false.
>   * config/c6x/c6x.c (c6x_callee_copies): Delete.
>   (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_true instead.
>   * config/epiphany/epiphany.c (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
>   hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.
>   * config/mips/mips.c (mips_callee_copies): Take a function_arg_info
>   instead of a mode, type and named flag.
>   * config/mmix/mmix.c (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
>   hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.
>   * config/mn10300/mn10300.c (TARGET_CALLEE_COPIES): Likewise.
>   * config/msp430/msp430.c (msp430_callee_copies): Delete.
>   (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_true instead.
>   * config/pa/pa.c (pa_callee_copies): Take a function_arg_info
>   instead of a mode, type and named flag.
>   * config/sh/sh.c (sh_callee_copies): Likewise.
>   * config/v850/v850.c (TARGET_CALLEE_COPIES): Define to
>   hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
>   hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.
> 
OK
jeff


Re: [07/13] Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCE

2019-08-19 Thread Jeff Law
On 8/19/19 9:18 AM, Richard Sandiford wrote:
> Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCE.
> 
> There seems to be a bit of confusion around this one.  Almost all
> callers pass the same arguments as TARGET_FUNCTION_ARG, meaning
> that the mode is the promoted mode rather than the type mode.
> But the calls.c handling for normal typed arguments instead passes
> the unpromoted TYPE_MODE (despite passing the promoted mode to
> TARGET_FUNCTION_ARG).  I've kept this behaviour with a ??? comment.
> 
> (The calls.c handling of libgcc functions does pass the promoted
> mode though, as does the function.c handling of incoming arguments.)
> 
> Also, a couple of the arm callers don't seem to be using the hook
> correctly.  Again I kept the current choices and added a ??? comment.
Keeping current behavior seems reasonable as does marking the
inconsistent bits.


> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (function_arg_advance): Take a function_arg_info instead
>   of a mode, type and named flag.
>   * doc/tm.texi: Regenerate.
>   * targhooks.h (default_function_arg_advance): Take a function_arg_info
>   instead of a mode, type and named flag.
>   * targhooks.c (default_function_arg_advance): Likewise.
>   * calls.c (initialize_argument_information): Update call to
>   targetm.calls.function_arg_advance.
>   (emit_library_call_value_1): Likewise.
>   * dse.c (get_call_args): Likewise.
>   * expr.c (block_move_libcall_safe_for_call_parm): Likewise.
>   * function.c (assign_parms, gimplify_parameters): Likewise.
>   * var-tracking.c (prepare_call_arguments): Likewise.
>   * config/aarch64/aarch64.c (aarch64_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (aarch64_setup_incoming_varargs): Update call accordingly.
>   * config/alpha/alpha.c (alpha_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (alpha_setup_incoming_varargs): Update call accordingly.
>   * config/arc/arc.c (arc_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (arc_setup_incoming_varargs): Update call accordingly.
>   * config/arm/arm.c (arm_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (cmse_func_args_or_return_in_stack): Update call accordingly.
>   (arm_function_ok_for_sibcall): Likewise.
>   (cmse_nonsecure_call_clear_caller_saved): Likewise.
>   * config/avr/avr.c (avr_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/bfin/bfin.c (bfin_function_arg_advance): Likewise.
>   * config/c6x/c6x.c (c6x_function_arg_advance): Likewise.
>   (c6x_call_saved_register_used): Update call accordingly.
>   * config/cr16/cr16.c (cr16_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/cris/cris.c (cris_function_arg_advance): Likewise.
>   * config/csky/csky.c (csky_function_arg_advance): Likewise.
>   (csky_setup_incoming_varargs): Update call accordingly.
>   * config/epiphany/epiphany.c (epiphany_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/fr30/fr30.c (fr30_function_arg_advance): Likewise.
>   * config/frv/frv.c (frv_function_arg_advance): Likewise.
>   * config/ft32/ft32.c (ft32_function_arg_advance): Likewise.
>   * config/gcn/gcn.c (gcn_function_arg_advance): Likewise.
>   * config/h8300/h8300.c (h8300_function_arg_advance): Likewise.
>   * config/i386/i386.c (ix86_function_arg_advance): Likewise.
>   (ix86_setup_incoming_varargs): Update call accordingly.
>   * config/ia64/ia64.c (ia64_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (ia64_setup_incoming_varargs): Update call accordingly.
>   * config/iq2000/iq2000.c (iq2000_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (iq2000_expand_prologue): Update call accordingly.
>   * config/lm32/lm32.c (lm32_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/m32c/m32c.c (m32c_function_arg_advance): Likewise.
>   * config/m32r/m32r.c (m32r_function_arg_advance): Likewise.
>   * config/m68k/m68k.c (m68k_function_arg_advance): Likewise.
>   * config/mcore/mcore.c (mcore_function_arg_advance): Likewise.
>   * config/microblaze/microblaze.c (microblaze_function_arg_advance):
>   Likewise.
>   (microblaze_expand_prologue): Update call accordingly.
>   * config/mips/mips.c (mips_function_arg_advance): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (mips_setup_incoming_varargs): Update call accordingly.
>   

Re: [06/13] Use function_arg_info for TARGET_FUNCTION_(INCOMING_)ARG

2019-08-19 Thread Jeff Law
On 8/19/19 9:16 AM, Richard Sandiford wrote:
> This patch makes both TARGET_FUNCTION_ARG and
> TARGET_FUNCTION_INCOMING_ARG take a function_arg_info.
> They have to be done together since many targets use the
> same function for both.
> 
> The hooks are passed the promoted mode instead of the original type mode.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (function_arg, function_incoming_arg): Take a
>   function_arg_info instead of a mode, tree and named flag.
>   * doc/tm.texi: Regenerate.
>   * targhooks.h (default_function_arg): Take a function_arg_info
>   instead of a mode, tree and named flag.
>   (default_function_incoming_arg): Likewise.
>   * targhooks.c (default_function_arg): Likewise.
>   (default_function_incoming_arg): Likewise.
>   * calls.h (function_arg_info::end_marker_p): New function.
>   (function_arg_info::end_marker): Likewise.
>   * calls.c (prepare_call_address, initialize_argument_information)
>   (expand_call, emit_library_call_value_1): Update calls to
>   targetm.calls.function_arg and targetm.calls.function_incoming_arg.
>   * dse.c: Include calls.h.
>   (get_call_args): Update call to targetm.calls.function_arg.
>   * expr.c (block_move_libcall_safe_for_call_parm): Likewise.
>   * var-tracking.c (prepare_call_arguments): Likewise.
>   * function.c (assign_parm_find_entry_rtl): Update call to
>   targetm.calls.function_incoming_arg.
>   * config/aarch64/aarch64.c (aarch64_function_arg): Take a
>   function_arg_info instead of a mode, tree and named flag.
>   * config/alpha/alpha.c (alpha_function_arg): Likewise.
>   * config/arc/arc.c (arc_function_arg): Likewise.
>   * config/arm/arm.c (arm_function_arg): Likewise.
>   (cmse_func_args_or_return_in_stack): Update call accordingly.
>   (arm_function_ok_for_sibcall): Likewise.
>   (cmse_nonsecure_call_clear_caller_saved): Likewise.
>   * config/avr/avr.c (avr_function_arg): Take a function_arg_info
>   instead of a mode, tree and named flag.
>   * config/bfin/bfin.c (bfin_function_arg): Likewise.
>   * config/c6x/c6x.c (c6x_function_arg): Likewise.
>   (c6x_call_saved_register_used): Update call accordingly.
>   * config/cr16/cr16.c (cr16_function_arg): Take a function_arg_info
>   instead of a mode, tree and named flag.
>   * config/cris/cris.c (cris_function_arg, cris_function_incoming_arg)
>   (cris_function_arg_1): Likewise.
>   * config/csky/csky.c (csky_function_arg): Likewise.
>   * config/epiphany/epiphany.c (epiphany_function_arg): Likewise.
>   * config/fr30/fr30.c (fr30_function_arg): Likewise.
>   * config/frv/frv.c (frv_function_arg, frv_function_incoming_arg)
>   (frv_function_arg_1): Likewise.
>   * config/ft32/ft32.c (ft32_function_arg): Likewise.
>   * config/gcn/gcn.c (gcn_function_arg): Likewise.
>   * config/h8300/h8300.c (h8300_function_arg): Likewise.
>   * config/i386/i386.c (ix86_function_arg): Likewise.
>   * config/ia64/ia64.c (ia64_function_arg, ia64_function_incoming_arg)
>   (ia64_function_arg_1): Likewise.
>   * config/iq2000/iq2000.c (iq2000_function_arg): Likewise.
>   (iq2000_expand_prologue, iq2000_pass_by_reference): Update call
>   accordingly.
>   * config/lm32/lm32.c (lm32_function_arg): Take a function_arg_info
>   instead of a mode, tree and named flag.
>   * config/m32c/m32c.c (m32c_function_arg): Likewise.
>   * config/m32r/m32r.c (m32r_function_arg): Likewise.
>   * config/m68k/m68k.c (m68k_function_arg): Likewise.
>   * config/mcore/mcore.c (mcore_function_arg): Likewise.
>   * config/microblaze/microblaze.c (microblaze_function_arg): Likewise.
>   (microblaze_expand_prologue): Update call accordingly.
>   * config/mips/mips.c (mips_function_arg): Take a function_arg_info
>   instead of a mode, tree and named flag.
>   * config/mmix/mmix.c (mmix_function_incoming_arg, mmix_function_arg)
>   (mmix_function_arg_1): Likewise.
>   * config/mn10300/mn10300.c (mn10300_function_arg): Likewise.
>   * config/moxie/moxie.c (moxie_function_arg): Likewise.
>   * config/msp430/msp430.c (msp430_function_arg): Likewise.
>   * config/nds32/nds32.c (nds32_function_arg): Likewise.
>   * config/nios2/nios2.c (nios2_function_arg): Likewise.
>   * config/nvptx/nvptx.c (nvptx_function_arg): Likewise.
>   (nvptx_function_incoming_arg): Likewise.
>   * config/or1k/or1k.c (or1k_function_arg): Likewise.
>   * config/pa/pa.c (pa_function_arg): Likewise.
>   * config/pdp11/pdp11.c (pdp11_function_arg): Likewise.
>   * config/pru/pru.c (pru_function_arg): Likewise.
>   * config/riscv/riscv.c (riscv_function_arg): Likewise.
>   * config/rl78/rl78.c (rl78_function_arg): Likewise.
>   * config/rs6000/rs6000-internal.h (rs6000_function_arg): Likewise.
>   * config/rs6000/rs6000-call.c 

[Bug rtl-optimization/91154] [10 Regression] 456.hmmer regression on Haswell caused by r272922

2019-08-19 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91154

--- Comment #31 from H.J. Lu  ---
(In reply to Uroš Bizjak from comment #28)
> (In reply to Richard Biener from comment #26)
> > This is the powers of simplify_subreg I guess.  We're lucky it doesn't do
> > this to arbitrary arithmetic.
> > 
> > So we need to really change all defs we introduce to vector modes instead of
> > making our live easy and using paradoxical subregs all over the place.
> 
> No, IMO IRA should be "fixed" to avoid stack temporary and (based on some
> cost metric) use direct move for paradoxical subregs.

The problem is

  /* Moves between SSE and integer units are expensive.  */
  if (SSE_CLASS_P (class1) != SSE_CLASS_P (class2))

/* ??? By keeping returned value relatively high, we limit the number
   of moves between integer and SSE registers for all targets.
   Additionally, high value prevents problem with x86_modes_tieable_p(),
   where integer modes in SSE registers are not tieable
   because of missing QImode and HImode moves to, from or between
   MMX/SSE registers.  */
return MAX (8, SSE_CLASS_P (class1)
? ix86_cost->hard_register.sse_to_integer
: ix86_cost->hard_register.integer_to_sse);

The minimum cost of moves between SSE and integer units is 8.

Re: [05/13] Use function_arg_info for TARGET_SETUP_INCOMING_ARGS

2019-08-19 Thread Jeff Law
On 8/19/19 9:16 AM, Richard Sandiford wrote:
> Use function_arg_info for TARGET_SETUP_INCOMING_ARGS.
> 
> The hook is passed the promoted mode instead of the original type mode.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (setup_incoming_varargs): Take a function_arg_info
>   instead of a mode and tree.
>   * doc/tm.texi: Regenerate.
>   * targhooks.h (default_setup_incoming_varargs): Take a
>   function_arg_info instead of a mode and tree.
>   * targhooks.c (default_setup_incoming_varargs): Likewise.
>   * config/aarch64/aarch64.c (aarch64_setup_incoming_varargs): Likewise.
>   * config/alpha/alpha.c (alpha_setup_incoming_varargs): Likewise.
>   * config/arc/arc.c (arc_setup_incoming_varargs): Likewise.
>   * config/arm/arm.c (arm_setup_incoming_varargs): Likewise.
>   * config/bfin/bfin.c (setup_incoming_varargs): Likewise.
>   * config/cris/cris.c (cris_setup_incoming_varargs): Likewise.
>   * config/csky/csky.c (csky_setup_incoming_varargs): Likewise.
>   * config/epiphany/epiphany.c (epiphany_setup_incoming_varargs):
>   Likewise.
>   * config/fr30/fr30.c (fr30_setup_incoming_varargs): Likewise.
>   * config/frv/frv.c (frv_setup_incoming_varargs): Likewise.
>   * config/ft32/ft32.c (ft32_setup_incoming_varargs): Likewise.
>   * config/i386/i386.c (ix86_setup_incoming_varargs): Likewise.
>   * config/ia64/ia64.c (ia64_setup_incoming_varargs): Likewise.
>   * config/iq2000/iq2000.c (iq2000_setup_incoming_varargs): Likewise.
>   * config/lm32/lm32.c (lm32_setup_incoming_varargs): Likewise.
>   * config/m32r/m32r.c (m32r_setup_incoming_varargs): Likewise.
>   * config/mcore/mcore.c (mcore_setup_incoming_varargs): Likewise.
>   * config/mips/mips.c (mips_setup_incoming_varargs): Likewise.
>   * config/mmix/mmix.c (mmix_setup_incoming_varargs): Likewise.
>   * config/moxie/moxie.c (moxie_setup_incoming_varargs): Likewise.
>   * config/nds32/nds32.c (nds32_setup_incoming_varargs): Likewise.
>   * config/nios2/nios2.c (nios2_setup_incoming_varargs): Likewise.
>   * config/riscv/riscv.c (riscv_setup_incoming_varargs): Likewise.
>   * config/rs6000/rs6000-internal.h (setup_incoming_varargs): Likewise.
>   * config/rs6000/rs6000-call.c (setup_incoming_varargs): Likewise.
>   * config/sh/sh.c (sh_setup_incoming_varargs): Likewise.
>   * config/spu/spu.c (spu_setup_incoming_varargs): Likewise.
>   * config/tilegx/tilegx.c (tilegx_setup_incoming_varargs): Likewise.
>   * config/tilepro/tilepro.c (tilepro_setup_incoming_varargs): Likewise.
>   * config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
>   * function.c (assign_parms_setup_varargs): Update call to
>   targetm.calls.setup_incoming_varargs.
OK
jeff


Re: [04/13] Use function_arg_info for TARGET_PASS_BY_REFERENCE

2019-08-19 Thread Jeff Law
On 8/19/19 9:15 AM, Richard Sandiford wrote:
> Use function_arg_info for TARGET_PASS_BY_REFERENCE.
> 
> The hook is passed the unpromoted type mode instead of the promoted mode.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (pass_by_reference): Take a function_arg_info instead
>   of a mode, type and named flag.
>   * doc/tm.texi: Regenerate.
>   * targhooks.h (hook_pass_by_reference_must_pass_in_stack): Update
>   accordingly.
>   (hook_bool_CUMULATIVE_ARGS_arg_info_false): Declare.
>   * targhooks.c (hook_pass_by_reference_must_pass_in_stack): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (hook_bool_CUMULATIVE_ARGS_arg_info_false): New function.
>   * calls.h (pass_by_reference): Take a function_arg_info instead of a
>   mode, type and named flag.
>   * calls.c (pass_by_reference): Likewise.
>   (pass_va_arg_by_reference): Update call accordingly.
>   (initialize_argument_information): Likewise.
>   (emit_library_call_value_1): Likewise.
>   * function.c (assign_parm_find_data_types): Likewise.
>   * var-tracking.c (prepare_call_arguments): Likewise.
>   * stor-layout.c: Include calls.h.
>   (compute_record_mode): Update call to targetm.calls.pass_by_reference.
>   * config/aarch64/aarch64.c (aarch64_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/alpha/alpha.c (alpha_pass_by_reference): Likewise.
>   * config/arc/arc.c (arc_pass_by_reference): Likewise.
>   * config/arm/arm.c (arm_pass_by_reference): Likewise.
>   * config/bfin/bfin.c (bfin_pass_by_reference): Likewise.
>   * config/c6x/c6x.c (c6x_pass_by_reference): Likewise.
>   (c6x_call_saved_register_used): Update call to pass_by_reference.
>   * config/cris/cris.c (cris_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/epiphany/epiphany.c (epiphany_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (epiphany_arg_partial_bytes): Update call accordingly.
>   * config/ft32/ft32.c (ft32_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (ft32_arg_partial_bytes): Update call accordingly.
>   * config/i386/i386.c (ix86_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise.
>   * config/m32c/m32c.c (m32c_pass_by_reference): Likewise.
>   * config/m32r/m32r.c (m32r_pass_by_reference): Likewise.
>   (m32r_return_in_memory): Update call accordingly.
>   * config/mips/mips.c (mips_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/mmix/mmix.c (mmix_pass_by_reference): Likewise.
>   * config/mn10300/mn10300.c (mn10300_pass_by_reference): Likewise.
>   * config/moxie/moxie.c (moxie_pass_by_reference): Likewise.
>   (moxie_arg_partial_bytes): Update call accordingly.
>   * config/msp430/msp430.c (msp430_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/nvptx/nvptx.c (nvptx_pass_by_reference): Likewise.
>   * config/or1k/or1k.c (or1k_pass_by_reference): Likewise.
>   * config/pa/pa.c (pa_pass_by_reference): Likewise.
>   * config/riscv/riscv.c (riscv_pass_by_reference): Likewise.
>   (riscv_return_in_memory): Update call accordingly.
>   * config/rs6000/rs6000-internal.h (rs6000_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/rs6000/rs6000-call.c (rs6000_pass_by_reference): Likewise.
>   (rs6000_parm_needs_stack): Update call to pass_by_reference.
>   * config/s390/s390.c (s390_pass_by_reference): Take a
>   function_arg_info instead of a mode, type and named flag.
>   (s390_call_saved_register_used): Update call accordingly.
>   * config/sh/sh.c (sh_pass_by_reference): Take a function_arg_info
>   instead of a mode, type and named flag.
>   * config/sparc/sparc.c (sparc_pass_by_reference): Likewise.
>   * config/spu/spu.c (spu_pass_by_reference): Likewise.
>   * config/tilegx/tilegx.c (tilegx_pass_by_reference): Likewise.
>   * config/tilepro/tilepro.c (tilepro_pass_by_reference): Likewise.
>   * config/v850/v850.c (v850_pass_by_reference): Likewise.
>   * config/visium/visium.c (visium_pass_by_reference): Likewise.
> 
> gcc/ada/
>   * gcc-interface/misc.c (default_pass_by_ref): Update call to
>   pass_by_reference.
OK
jeff


[Bug libstdc++/91486] future::wait_for and shared_timed_mutex::wait_for do not work properly with float duration

2019-08-19 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91486

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-08-19
 Ever confirmed|0   |1

--- Comment #4 from Jonathan Wakely  ---
Yes that probably makes sense to do.

[Bug c++/91484] Error message: std::is_constructible with incomplete types.

2019-08-19 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91484

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2019-08-19
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
Please read https://gcc.gnu.org/bugs (as requested when creating a new bug) and
provide the required information.

Re: [03/13] Use function_arg_info for TARGET_ARG_PARTIAL_BYTES

2019-08-19 Thread Jeff Law
On 8/19/19 9:14 AM, Richard Sandiford wrote:
> This patch adds the function_arg_info class and uses it for
> TARGET_ARG_PARTIAL_BYTES.
> 
> The hook is passed the promoted mode instead of the original type mode.
> 
> The arguments aren't mentioned in the documentation, which is why the
> target.def change is so small.
> 
> The patch changes "true" to "arg.named" in:
> 
>   gcc_assert (!epiphany_pass_by_reference (cum, mode, type, /* named */ 
> true));
> 
> but epiphany_pass_by_reference doesn't care about the named flag.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * target.def (arg_partial_bytes): Take a function_arg_info instead
>   of a mode, type and named flag.
>   * doc/tm.texi: Regenerate.
>   * target.h (function_arg_info): Declare.
>   * calls.h (function_arg_info): New class.
>   * targhooks.h (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete.
>   (hook_int_CUMULATIVE_ARGS_arg_info_0): Declare.
>   * targhooks.c (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete.
>   (hook_int_CUMULATIVE_ARGS_arg_info_0): New function.
>   * calls.c (initialize_argument_information): Update call to
>   targetm.calls.partial_bytes.
>   (emit_library_call_value_1): Likewise.
>   * expr.c (block_move_libcall_safe_for_call_parm): Likewise.
>   * function.c (assign_parm_find_entry_rtl): Likewise.
>   * config/alpha/alpha.c (alpha_arg_partial_bytes): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/arc/arc.c (arc_arg_partial_bytes): Likewise.
>   * config/arm/arm.c (arm_arg_partial_bytes): Likewise.
>   (cmse_func_args_or_return_in_stack): Update accordingly.
>   * config/bfin/bfin.c (bfin_arg_partial_bytes): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/cris/cris.c (cris_arg_partial_bytes): Likewise.
>   * config/csky/csky.c (csky_arg_partial_bytes): Likewise.
>   * config/epiphany/epiphany.c (epiphany_arg_partial_bytes): Likewise.
>   * config/fr30/fr30.c: Include calls.h.
>   (fr30_arg_partial_bytes): Take a function_arg_info instead of a mode,
>   type and named flag.
>   * config/frv/frv.c: Include calls.h.
>   (frv_arg_partial_bytes): Take a function_arg_info instead of a mode,
>   type and named flag.
>   * config/ft32/ft32.c (ft32_arg_partial_bytes): Likewise.
>   * config/gcn/gcn.c (gcn_arg_partial_bytes): Likewise.
>   * config/ia64/ia64.c (ia64_arg_partial_bytes): Likewise.
>   * config/iq2000/iq2000.c (iq2000_arg_partial_bytes): Likewise.
>   * config/m32r/m32r.c (m32r_arg_partial_bytes): Likewise.
>   * config/mcore/mcore.c (mcore_arg_partial_bytes): Likewise.
>   * config/microblaze/microblaze.c (function_arg_partial_bytes):
>   Likewise.
>   * config/mips/mips.c (mips_arg_partial_bytes): Likewise.
>   * config/mn10300/mn10300.c (mn10300_arg_partial_bytes): Likewise.
>   * config/moxie/moxie.c (moxie_arg_partial_bytes): Likewise.
>   * config/msp430/msp430.c (msp430_arg_partial_bytes): Likewise.
>   * config/nds32/nds32.c (nds32_arg_partial_bytes): Likewise.
>   * config/nios2/nios2.c (nios2_arg_partial_bytes): Likewise.
>   * config/pa/pa.c (pa_arg_partial_bytes): Likewise.
>   * config/pru/pru.c (pru_arg_partial_bytes): Likewise.
>   * config/riscv/riscv.c (riscv_arg_partial_bytes): Likewise.
>   * config/rs6000/rs6000-internal.h (rs6000_arg_partial_bytes): Likewise.
>   * config/rs6000/rs6000-call.c (rs6000_arg_partial_bytes): Likewise.
>   (rs6000_parm_needs_stack): Update call accordingly.
>   * config/sh/sh.c (sh_arg_partial_bytes): Take a
>   function_arg_info instead of a mode, type and named flag.
>   * config/sparc/sparc.c (sparc_arg_partial_bytes): Likewise.
>   * config/v850/v850.c (v850_arg_partial_bytes): Likewise.
OK
jeff


Re: [PATCH V2 6/8] bpf: adjust GCC testsuite to eBPF limitations

2019-08-19 Thread jose . marchesi


> It also seems like rather than checking for ebpf on files with large
> stacks, we should be using the generic mechanisms to defined the 
allowed
> size of the stack (mentioned in prior review) & mark test which use 
too
> much space.  This would almost certainly help other embedded targets 
as
> well.
> 
> I first thought about doing that, but hesitated when I realized it would
> require to alter existing tests in no trivial ways: will the test still
> effectively test whatever it is supposed to test, after the size of an
> array is changed, for example?
I think you just add something like

/* dg-require-stack-size "" */

Assuming that's right you don't have to worry about changing the test
itself and potentially changing its meaning.

I wouldn't necessarily try to figure the exact size needed by each test.
 A reasonable guesstimation ought to be sufficient.

Oh nice, I didn't know about that directive.
Thanks!


Re: [PATCH V2 2/8] bpf: new GCC port

2019-08-19 Thread Richard Sandiford
In addition to Segher's comments:

jema...@gnu.org (Jose E. Marchesi) writes:
> [...]
> +/* This file contains the definition of the kernel helpers that are
> +   available to eBPF programs.
> +
> +   The primary source for information on kernel helpers is the
> +   linux/include/uapi/linux/bpf.h file in the Linux source tree.
> +   Please keep this database in sync.
> +
> +   The first column is the first kernel version featuring the helper
> +   function.  This should be an enumerate from bpf_kernel_version,
> +   defined in bpf-opts.h.  Note that the backend assumes that helpers
> +   never get deprecated in the kernel.  If that eventually happens,
> +   then we will need to use a bitmask here instead of an enumerate.
> +
> +   The second column is the constant-name for the helper.
> +   The third column is the program-name of the helper.
> +
> +   The fourth column is a list of names describing the types of the
> +   values returned and accepted by the helper, in one of these forms:
> +
> + TYPES (type1, type2, ..., 0)
> + VTYPES (type1, type2, ..., 0)
> +
> +   VTYPES should be used should the helper accept a variable number of
> +   arguments, TYPES otherwise.  The valid type names are:
> +
> + `vt' for void.
> + `it' for signed int.
> + `ut' for unsigned int.
> + `pt' for *void.
> + `cpt' for const *void.

"*" after "void" in both cases.

> + `st' for short int.
> + `ust' for unsigned short int.
> + `cst' for const char *.

Very minor, but it might be less confusing to pick something other than "s"
for "cst" given the above.

> [...]
> +/* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions.  We
> +   provide the "standard" names as synonyms of the corresponding GCC
> +   builtins.  Note how the SKB argument is ignored.  */
> +
> +static inline long long
> +load_byte (void *skb, unsigned long long off)
> +{
> +  return __builtin_bpf_load_byte (off);
> +}
> [etc]

It might be worth adding __attribute__((unused)) to them, in case
anyone compiles with -Wsystem-headers.

> [...]
> +/* Supported versions of the Linux kernel.  */
> +enum bpf_kernel_version
> +{
> + /* Linux 4.x */
> + LINUX_V4_0,
> [etc.]

The contents should be indented by two spaces.

> [...]
> +enum bpf_builtins
> +{
> + BPF_BUILTIN_UNUSED = 0,
> + /* Built-ins for kernel helpers.  */
> +#define DEF_HELPER(V,D,N,T) BPF_BUILTIN_HELPER_##D,
> +#  include "bpf-helpers.def"
> +#undef DEF_HELPER
> + BPF_BUILTIN_HELPER_MAX,
> + /* Built-ins for non-generic loads and stores.  */
> + BPF_BUILTIN_LOAD_BYTE = BPF_BUILTIN_HELPER_MAX,
> + BPF_BUILTIN_LOAD_HALF,
> + BPF_BUILTIN_LOAD_WORD,
> + BPF_BUILTIN_MAX,
> +};
> +
> +/* This table is indexed by an enum bpf_builtin.  */
> +static const char *bpf_helper_names[] =
> +{
> + NULL,
> +#define DEF_HELPER(V,D,N,T) #N,
> +#  include "bpf-helpers.def"
> +#undef DEF_HELPER
> + NULL,
> + NULL,
> + NULL,
> + NULL
> +};

Same for these two.

> [...]
> +#define INCLUDE_STRING

You didn't seem to rely on this (i.e. std::string).

> [...]
> +/* Override options and do some other initialization.  */
> +
> +static void
> +bpf_option_override (void)
> +{
> +  /* Set the default target kernel if no -mkernel was specified.  */
> +  if (!global_options_set.x_bpf_kernel)
> +bpf_kernel = LINUX_LATEST;

LINUX_LATEST is the default in the .opt file, so when is this needed?

> [...]
> +  /* Define BPF_KERNEL_VERSION_CODE */
> +  {
> +const char *version_code;
> +char *kernel_version_code;
> +
> +switch (bpf_kernel)
> +  {
> +  case LINUX_V4_0: version_code = "0x4"; break;
> +  case LINUX_V4_1: version_code = "0x40100"; break;
> +  case LINUX_V4_2: version_code = "0x40200"; break;
> +  case LINUX_V4_3: version_code = "0x40300"; break;
> +  case LINUX_V4_4: version_code = "0x40400"; break;
> +  case LINUX_V4_5: version_code = "0x40500"; break;
> +  case LINUX_V4_6: version_code = "0x40600"; break;
> +  case LINUX_V4_7: version_code = "0x40700"; break;
> +  case LINUX_V4_8: version_code = "0x40800"; break;
> +  case LINUX_V4_9: version_code = "0x40900"; break;
> +  case LINUX_V4_10: version_code = "0x40a00"; break;
> +  case LINUX_V4_11: version_code = "0x40b00"; break;
> +  case LINUX_V4_12: version_code = "0x40c00"; break;
> +  case LINUX_V4_13: version_code = "0x40d00"; break;
> +  case LINUX_V4_14: version_code = "0x40e00"; break;
> +  case LINUX_V4_15: version_code = "0x40f00"; break;
> +  case LINUX_V4_16: version_code = "0x41000"; break;
> +  case LINUX_V4_17: version_code = "0x42000"; break;
> +  case LINUX_V4_18: version_code = "0x43000"; break;
> +  case LINUX_V4_19: version_code = "0x44000"; break;
> +  case LINUX_V4_20: version_code = "0x45000"; break;
> +  case LINUX_V5_0: version_code = "0x5"; break;
> +  case LINUX_V5_1: version_code = "0x50100"; break;
> +  case LINUX_V5_2: version_code = "0x50200"; break;
> +  default:
> + 

Re: [PATCH] Improve DSE to handle redundant zero initializations.

2019-08-19 Thread Matthew Beliveau
Hello,

This should have the changes you wanted!

Thank you,
Matthew Beliveau

On Fri, Aug 16, 2019 at 12:30 PM Jeff Law  wrote:
>
> On 8/13/19 9:09 AM, Matthew Beliveau wrote:
> > Hello,
> >
> > This should have the changes you all asked for! Let me know if I
> > missed anything!
> >
> > Thank you,
> > Matthew Beliveau
> >
> > On Tue, Aug 13, 2019 at 5:15 AM Richard Biener
> >  wrote:
> >> On Tue, Aug 13, 2019 at 10:18 AM Richard Sandiford
> >>  wrote:
> >>> Thanks for doing this.
> >>>
> >>> Matthew Beliveau  writes:
>  diff --git gcc/tree-ssa-dse.c gcc/tree-ssa-dse.c
>  index 5b7c4fc6d1a..dcaeb8edbfe 100644
>  --- gcc/tree-ssa-dse.c
>  +++ gcc/tree-ssa-dse.c
>  @@ -628,11 +628,8 @@ dse_optimize_redundant_stores (gimple *stmt)
> tree fndecl;
> if ((is_gimple_assign (use_stmt)
>   && gimple_vdef (use_stmt)
>  -&& ((gimple_assign_rhs_code (use_stmt) == CONSTRUCTOR
>  - && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (use_stmt)) == 0
>  - && !gimple_clobber_p (stmt))
>  -|| (gimple_assign_rhs_code (use_stmt) == INTEGER_CST
>  -&& integer_zerop (gimple_assign_rhs1 (use_stmt)
>  +&& initializer_zerop (gimple_op (use_stmt, 1), NULL)
>  +&& !gimple_clobber_p (stmt))
>  || (gimple_call_builtin_p (use_stmt, BUILT_IN_NORMAL)
>  && (fndecl = gimple_call_fndecl (use_stmt)) != NULL
>  && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMSET
>  @@ -1027,15 +1024,13 @@ dse_dom_walker::dse_optimize_stmt 
>  (gimple_stmt_iterator *gsi)
>   {
> bool by_clobber_p = false;
> 
>  -  /* First see if this store is a CONSTRUCTOR and if there
>  -  are subsequent CONSTRUCTOR stores which are totally
>  -  subsumed by this statement.  If so remove the subsequent
>  -  CONSTRUCTOR store.
>  +  /* Check if this store initalizes zero, or some aggregate of 
>  zeros,
>  +  and check if there are subsequent stores which are subsumed by 
>  this
>  +  statement.  If so, remove the subsequent store.
> 
> This will tend to make fewer calls into memset with longer
> arguments.  */
>  -  if (gimple_assign_rhs_code (stmt) == CONSTRUCTOR
>  -   && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (stmt)) == 0
>  +  if (initializer_zerop (gimple_op (stmt, 1), NULL)
>  && !gimple_clobber_p (stmt))
>    dse_optimize_redundant_stores (stmt);
> 
> >>> In addition to Jeff's comment, the original choice of gimple_assign_rhs1
> >>> is the preferred way to write this (applies to both hunks).
> >> And the !gimple_clobber_p test is now redundant.
> >>
> >>> Richard
> >
> > DSE-2.patch
> >
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> >
> > 2019-08-13  Matthew Beliveau  
> >
> >   * tree-ssa-dse.c (dse_optimize_redundant_stores): Improved check to
> >   catch more redundant zero initialization cases.
> >   (dse_dom_walker::dse_optimize_stmt): Likewise.
> >
> >   * gcc.dg/tree-ssa/redundant-assign-zero-1.c: New test.
> >   * gcc.dg/tree-ssa/redundant-assign-zero-2.c: New test.
> >
> > diff --git gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-1.c 
> > gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-1.c
> > new file mode 100644
> > index 000..b8d01d1644b
> > --- /dev/null
> > +++ gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-1.c
> > @@ -0,0 +1,13 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O2 -fdump-tree-dse-details" } */
> > +
> > +void blah (char *);
> > +
> > +void bar ()
> > +{
> > +  char a[256] = "";
> > +  a[3] = 0;
> > +  blah (a);
> > +}
> > +
> > +/* { dg-final { scan-tree-dump-times "Deleted redundant store" 1 "dse1"} } 
> > */
> > diff --git gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-2.c 
> > gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-2.c
> > new file mode 100644
> > index 000..8cefa6f0cb7
> > --- /dev/null
> > +++ gcc/testsuite/gcc.dg/tree-ssa/redundant-assign-zero-2.c
> > @@ -0,0 +1,18 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O2 -fdump-tree-dse-details" } */
> > +
> > +#include 
> > +
> > +void blahd (double *);
> > +
> > +void fubar ()
> > +{
> > +  double d;
> > +  double *x = 
> > +
> > +  memset (, 0 , sizeof d);
> > +  *x = 0.0;
> > +  blahd (x);
> > +}
> > +
> > +/* { dg-final { scan-tree-dump-times "Deleted redundant store" 1 "dse1"} } 
> > */
> > diff --git gcc/tree-ssa-dse.c gcc/tree-ssa-dse.c
> > index 5b7c4fc6d1a..14b66228e1e 100644
> > --- gcc/tree-ssa-dse.c
> > +++ gcc/tree-ssa-dse.c
> > @@ -628,11 +628,7 @@ dse_optimize_redundant_stores (gimple *stmt)
> >tree fndecl;
> >if ((is_gimple_assign (use_stmt)
> >  && gimple_vdef (use_stmt)
> > -&& ((gimple_assign_rhs_code (use_stmt) == CONSTRUCTOR
> > - && CONSTRUCTOR_NELTS 

Re: [02/13] Add must_pass_va_arg_in_stack

2019-08-19 Thread Jeff Law
On 8/19/19 9:12 AM, Richard Sandiford wrote:
> This patch splits out another idiom from the va_arg gimplification
> routines, so that there's only one place to update later.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * calls.h (must_pass_va_arg_in_stack): Declare.
>   * calls.c (must_pass_va_arg_in_stack): New function.
>   * config/alpha/alpha.c (alpha_gimplify_va_arg_1): Use it.
>   * config/sh/sh.c (sh_gimplify_va_arg_expr): Likewise.
>   * config/stormy16/stormy16.c (xstormy16_gimplify_va_arg_expr):
>   Likewise.
>   * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
OK.  Hopefully they're all this easy to review :-)

jeff


Re: [01/13] Add pass_va_arg_by_reference

2019-08-19 Thread Jeff Law
On 8/19/19 9:11 AM, Richard Sandiford wrote:
> This patch splits out a common idiom from the va_arg gimplification
> routines, so that there's only one place to update later.
> 
> 
> 2019-08-19  Richard Sandiford  
> 
> gcc/
>   * calls.h (pass_va_arg_by_reference): Declare.
>   * calls.c (pass_va_arg_by_reference): New function.
>   * config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it.
>   * config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise.
>   * config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise.
>   * config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
>   * config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
>   * config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise.
>   (mips_gimplify_va_arg_expr): Likewise.
>   * config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise.
>   * config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
>   * config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise.
>   * config/s390/s390.c (s390_gimplify_va_arg): Likewise.
>   * config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
>   * config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise.
>   * config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise.
>   * config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise.
>   * config/visium/visium.c (visium_gimplify_va_arg): Likewise.
>   * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
>   * targhooks.c (std_gimplify_va_arg_expr): Likewise.
OK
jeff


Re: [PATCH V2 6/8] bpf: adjust GCC testsuite to eBPF limitations

2019-08-19 Thread Jeff Law
On 8/19/19 8:23 AM, Jose E. Marchesi wrote:
> 
> [...]
> > * gcc.dg/Wframe-larger-than-2.c: Likewise.
> > * gcc.dg/Wframe-larger-than.c: Likewise.
> > * gcc.dg/Wrestrict-11.c: Likewise.
> So I think we probably want an effective target check for indirect calls
> rather than checking explicitly for ebpf in all these files.
> 
> Ok, will introduce it.
> 
> It also seems like rather than checking for ebpf on files with large
> stacks, we should be using the generic mechanisms to defined the allowed
> size of the stack (mentioned in prior review) & mark test which use too
> much space.  This would almost certainly help other embedded targets as
> well.
> 
> I first thought about doing that, but hesitated when I realized it would
> require to alter existing tests in no trivial ways: will the test still
> effectively test whatever it is supposed to test, after the size of an
> array is changed, for example?
I think you just add something like

/* dg-require-stack-size "" */

Assuming that's right you don't have to worry about changing the test
itself and potentially changing its meaning.

I wouldn't necessarily try to figure the exact size needed by each test.
 A reasonable guesstimation ought to be sufficient.


> 
> Not sure the best way to deal with too many arguments.  I suspect we
> want an efffective target check for that.  Keeping this up-to-date will
> be painful as people write more tests.
> 
> Yeah, that won't be fun :(
> 
>   /* Copyright (C) 2000, 2003 Free Software Foundation */
> >  __complex__ long long f ()
> > diff --git a/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
> > b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
> > index be0bdcf7631..9f6bd0af2e5 100644
> > --- a/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
> > +++ b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
> > @@ -3,6 +3,7 @@
> >  /* { dg-skip-if "too much code for pdp11" { "pdp11-*-*" } } */
> >  /* { dg-xfail-if "PR36698" { spu-*-* } { "-O0" } { "" } } */
> >  /* { dg-skip-if "" { m32c-*-* } } */
> > +/* { dg-skip-if "jumps too far for eBPF" { bpf-*-* } } */
> >  /* { dg-timeout-factor 4.0 } */
> Jumps too far is probably an indication you need to fix something in
> your port.  Though I guess its OK if you're never going to support far
> away targets.
> 
> The reasons for this are that eBPF doesn't have indirect jump
> instructions, and the direct jump instruction's displacement is a signed
> PC-relative 16-bit offset, in 64-bit word units.
> 
> So, unless the compiler gets able to generate a "chain" of direct jumps
> to reach the destination (that would be a fun hack :D) the range for
> branches is severely limited.
OK.  Perhaps another effective target check.   Or leave this one with
the epf check.

jeff


Re: [PATCH 1/2] gcc/riscv: Include more registers in SIBCALL_REGS

2019-08-19 Thread Andrew Waterman
x5 is used as an alternate link register, so using it for sibcalls
will confuse hardware return-address stacks and reduce performance for
implementations that have one.

The reason I excluded a0-a7 is that those are used to pass arguments
to the sibcallee.  It's of course possible that's more restrictive
than necessary, but make sure to test before merging.


On Mon, Aug 19, 2019 at 12:16 PM Andrew Burgess
 wrote:
>
> The current SIBCALL_REGS are x6, x7, and x28 to x31.  These are all
> caller saved registers, however, they are not all of the caller saved
> registers.
>
> I don't see any reason why we couldn't add t1, and a0 to a7 into this
> set, and this is what this patch does.
>
> gcc/ChangeLog:
>
> * config/riscv/riscv.h (REG_CLASS_CONTENTS): Update SIBCALL_REGS.
> ---
>  gcc/ChangeLog| 4 
>  gcc/config/riscv/riscv.h | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
> index 5fc9be8edbf2..bb8240bb849a 100644
> --- a/gcc/config/riscv/riscv.h
> +++ b/gcc/config/riscv/riscv.h
> @@ -400,7 +400,7 @@ enum reg_class
>  #define REG_CLASS_CONTENTS \
>  {  \
>{ 0x, 0x, 0x },  /* NO_REGS */   \
> -  { 0xf0c0, 0x, 0x },  /* SIBCALL_REGS */  \
> +  { 0xf003fce0, 0x, 0x },  /* SIBCALL_REGS */  \
>{ 0xffc0, 0x, 0x },  /* JALR_REGS */ \
>{ 0x, 0x, 0x },  /* GR_REGS */   \
>{ 0x, 0x, 0x },  /* FP_REGS */   \
> --
> 2.14.5
>


New Chinese (simplified) PO file for 'gcc' (version 9.1.0)

2019-08-19 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Chinese (simplified) team of translators.  The file is available at:

https://translationproject.org/latest/gcc/zh_CN.po

(This file, 'gcc-9.1.0.zh_CN.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

https://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

https://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




[PATCH 2/2] gcc/riscv: Add a mechanism to remove some calls to _riscv_save_0

2019-08-19 Thread Andrew Burgess
When using the -msave-restore flag we end up with calls to
_riscv_save_0 and _riscv_restore_0.  These functions adjust the stack
and save or restore the return address.  Due to grouping multiple
save/restore stub functions together the save/restore 0 calls actually
save s0, s1, s2, and the return address, but only the return address
actually matters.  Leaf functions don't call the save/restore stubs,
so whenever we do see a call to the save/restore stubs, the store of
the return address is required.

If we look in gcc/config/riscv/riscv.c at the function
riscv_expand_prologue and riscv_expand_epilogue we can see that it
would be reasonably easy to adjust these functions to avoid the calls
to the save/restore stubs for those cases where we are about to call
_riscv_save_0 and _riscv_restore_0, however, the actual code size
saving this would give is debatable, with linker relaxation, the calls
to save/restore are often just 4-bytes, and can sometimes even be
2-bytes, while leaving the stack adjust and return address save inline
is always going to be 4-bytes.

The interesting case is when we call _riscv_save_0 and
_riscv_restore_0, and also have a frame that would (without
save/restore) have resulted in a tail call.  In this case if we could
remove the save/restore calls, and restore the tail call then we would
get a real size saving.

The problem is that the choice of generating a tail call or not is
done during the gimple expand pass, at which point we don't know how
many registers we need to save (or restore).

The solution presented in this patch offers a partial solution to this
problem.  By using the TARGET_MACHINE_DEPENDENT_REORG pass to
implement a very limited pattern matching we identify functions that
call _riscv_save_0 and _riscv_restore_0, and which could be converted
to make use of a tail call.  These functions are then converted to the
non save/restore tail call form.

This should result in a code size reduction when compiling with -Os
and with the -msave-restore flag.

gcc/ChangeLog:

* config.gcc: Add riscv-sr.o to extra_objs for riscv.
* config/riscv/riscv-sr.c: New file.
* config/riscv/riscv.c (riscv_reorg): New function.
(TARGET_MACHINE_DEPENDENT_REORG): Define.
* config/riscv/riscv.h (SIBCALL_REG_P): Define.
(CALLEE_SAVED_REG_P): Define.
(riscv_remove_unneeded_save_restore_calls): Declare.
* config/riscv/t-riscv (riscv-sr.o): New build rule.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/save-restore-2.c: New file.
* gcc.target/riscv/save-restore-3.c: New file.
* gcc.target/riscv/save-restore-4.c: New file.
* gcc.target/riscv/save-restore-5.c: New file.
* gcc.target/riscv/save-restore-6.c: New file.
* gcc.target/riscv/save-restore-7.c: New file.
* gcc.target/riscv/save-restore-8.c: New file.
---
 gcc/ChangeLog   |  11 +
 gcc/config.gcc  |   2 +-
 gcc/config/riscv/riscv-sr.c | 375 
 gcc/config/riscv/riscv.c|  13 +
 gcc/config/riscv/riscv.h|  20 ++
 gcc/config/riscv/t-riscv|   5 +
 gcc/testsuite/ChangeLog |  10 +
 gcc/testsuite/gcc.target/riscv/save-restore-2.c |  22 ++
 gcc/testsuite/gcc.target/riscv/save-restore-3.c |  16 +
 gcc/testsuite/gcc.target/riscv/save-restore-4.c |  27 ++
 gcc/testsuite/gcc.target/riscv/save-restore-5.c |   9 +
 gcc/testsuite/gcc.target/riscv/save-restore-6.c |  16 +
 gcc/testsuite/gcc.target/riscv/save-restore-7.c |  30 ++
 gcc/testsuite/gcc.target/riscv/save-restore-8.c |  12 +
 14 files changed, 567 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/riscv/riscv-sr.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-2.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-3.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-4.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-5.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-6.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-7.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-8.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 40cbc52dc994..ac02d1835372 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -520,7 +520,7 @@ pru-*-*)
;;
 riscv*)
cpu_type=riscv
-   extra_objs="riscv-builtins.o riscv-c.o"
+   extra_objs="riscv-builtins.o riscv-c.o riscv-sr.o"
d_target_objs="riscv-d.o"
;;
 rs6000*-*-*)
diff --git a/gcc/config/riscv/riscv-sr.c b/gcc/config/riscv/riscv-sr.c
new file mode 100644
index ..7d12c0d82111
--- /dev/null
+++ b/gcc/config/riscv/riscv-sr.c
@@ -0,0 +1,375 @@
+/* This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as 

[PATCH 1/2] gcc/riscv: Include more registers in SIBCALL_REGS

2019-08-19 Thread Andrew Burgess
The current SIBCALL_REGS are x6, x7, and x28 to x31.  These are all
caller saved registers, however, they are not all of the caller saved
registers.

I don't see any reason why we couldn't add t1, and a0 to a7 into this
set, and this is what this patch does.

gcc/ChangeLog:

* config/riscv/riscv.h (REG_CLASS_CONTENTS): Update SIBCALL_REGS.
---
 gcc/ChangeLog| 4 
 gcc/config/riscv/riscv.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 5fc9be8edbf2..bb8240bb849a 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -400,7 +400,7 @@ enum reg_class
 #define REG_CLASS_CONTENTS \
 {  \
   { 0x, 0x, 0x },  /* NO_REGS */   \
-  { 0xf0c0, 0x, 0x },  /* SIBCALL_REGS */  \
+  { 0xf003fce0, 0x, 0x },  /* SIBCALL_REGS */  \
   { 0xffc0, 0x, 0x },  /* JALR_REGS */ \
   { 0x, 0x, 0x },  /* GR_REGS */   \
   { 0x, 0x, 0x },  /* FP_REGS */   \
-- 
2.14.5



[PATCH 0/2] RISCV: Reduce code size when compiling with -msave-restore

2019-08-19 Thread Andrew Burgess
The following two patches are an attempt at further reducing code size
when compiling with -msave-restore by attempting to claw back some of
the tail call cases where we currently include a call to
__riscv_save_0 and __riscv_restore_0.

Any feedback, or suggestions for improvements, or for better
approaches I could take are gratefully recieved.

Thanks,
Andrew

--

Andrew Burgess (2):
  gcc/riscv: Include more registers in SIBCALL_REGS
  gcc/riscv: Add a mechanism to remove some calls to _riscv_save_0

 gcc/ChangeLog   |  15 +
 gcc/config.gcc  |   2 +-
 gcc/config/riscv/riscv-sr.c | 375 
 gcc/config/riscv/riscv.c|  13 +
 gcc/config/riscv/riscv.h|  22 +-
 gcc/config/riscv/t-riscv|   5 +
 gcc/testsuite/ChangeLog |  10 +
 gcc/testsuite/gcc.target/riscv/save-restore-2.c |  22 ++
 gcc/testsuite/gcc.target/riscv/save-restore-3.c |  16 +
 gcc/testsuite/gcc.target/riscv/save-restore-4.c |  27 ++
 gcc/testsuite/gcc.target/riscv/save-restore-5.c |   9 +
 gcc/testsuite/gcc.target/riscv/save-restore-6.c |  16 +
 gcc/testsuite/gcc.target/riscv/save-restore-7.c |  30 ++
 gcc/testsuite/gcc.target/riscv/save-restore-8.c |  12 +
 14 files changed, 572 insertions(+), 2 deletions(-)
 create mode 100644 gcc/config/riscv/riscv-sr.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-2.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-3.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-4.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-5.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-6.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-7.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-8.c

-- 
2.14.5



libgo patch committed: Stricter GC checking

2019-08-19 Thread Ian Lance Taylor
This libgo patch by Cherry Zhang enables stricter GC checking in libgo.

With https://golang.org/cl/190599
(https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01220.html), along with
what we do in greyobject, we ensure that we only mark allocated heap
objects.  As a result we can be more strict in GC:

- Enable "sweep increased allocation count" check, which checks that
the number of mark bits set are no more than the number of allocation
bits.

- Enable invalid pointer check on heap scan. We only trace allocated
heap objects, which should not contain invalid pointer.

This also makes the libgo runtime more convergent with the gc runtime.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 274614)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-85857977230437f2b3dcbeea009efbb8b2789039
+b0ba5daa8216a0424b24f74466cedab0b986f3b4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/mcentral.go
===
--- libgo/go/runtime/mcentral.go(revision 274169)
+++ libgo/go/runtime/mcentral.go(working copy)
@@ -56,15 +56,6 @@ retry:
c.empty.insertBack(s)
unlock()
s.sweep(true)
-
-   // With gccgo's conservative GC, the returned span may
-   // now be full. See the comments in mspan.sweep.
-   if uintptr(s.allocCount) == s.nelems {
-   s.freeindex = s.nelems
-   lock()
-   goto retry
-   }
-
goto havespan
}
if s.sweepgen == sg-1 {
Index: libgo/go/runtime/mgcsweep.go
===
--- libgo/go/runtime/mgcsweep.go(revision 274169)
+++ libgo/go/runtime/mgcsweep.go(working copy)
@@ -326,39 +326,16 @@ func (s *mspan) sweep(preserve bool) boo
freeToHeap = true
}
nfreed := s.allocCount - nalloc
-
-   // This check is not reliable with gccgo, because of
-   // conservative stack scanning. The test boils down to
-   // checking that no new bits have been set in gcmarkBits since
-   // the span was added to the sweep count. New bits are set by
-   // greyobject. Seeing a new bit means that a live pointer has
-   // appeared that was not found during the mark phase. That can
-   // not happen when pointers are followed strictly. However,
-   // with conservative checking, it is possible for a pointer
-   // that will never be used to appear live and to cause a mark
-   // to be added. That is unfortunate in that it causes this
-   // check to be inaccurate, and it will keep an object live
-   // unnecessarily, but provided the pointer is not really live
-   // it is not otherwise a problem. So we disable the test for gccgo.
-   nfreedSigned := int(nfreed)
if nalloc > s.allocCount {
-   if usestackmaps {
-   print("runtime: nelems=", s.nelems, " nalloc=", nalloc, 
" previous allocCount=", s.allocCount, " nfreed=", nfreed, "\n")
-   throw("sweep increased allocation count")
-   }
-
-   // For gccgo, adjust the freed count as a signed number.
-   nfreedSigned = int(s.allocCount) - int(nalloc)
-   if uintptr(nalloc) == s.nelems {
-   s.freeindex = s.nelems
-   }
+   print("runtime: nelems=", s.nelems, " nalloc=", nalloc, " 
previous allocCount=", s.allocCount, " nfreed=", nfreed, "\n")
+   throw("sweep increased allocation count")
}
 
s.allocCount = nalloc
wasempty := s.nextFreeIndex() == s.nelems
s.freeindex = 0 // reset allocation index to start of span.
if trace.enabled {
-   getg().m.p.ptr().traceReclaimed += uintptr(nfreedSigned) * 
s.elemsize
+   getg().m.p.ptr().traceReclaimed += uintptr(nfreed) * s.elemsize
}
 
// gcmarkBits becomes the allocBits.
@@ -374,7 +351,7 @@ func (s *mspan) sweep(preserve bool) boo
// But we need to set it before we make the span available for 
allocation
// (return it to heap or mcentral), because allocation code assumes 
that a
// span is already swept if available for allocation.
-   if freeToHeap || nfreedSigned <= 0 {
+   if freeToHeap || nfreed == 0 {
// The span must be in our exclusive ownership until we update 
sweepgen,
// check for potential races.
if s.state != mSpanInUse || s.sweepgen 

Re: [PATCH 0/3] add support for POD struct convention (PR 61339)

2019-08-19 Thread Jason Merrill
On Wed, Aug 14, 2019, 11:44 AM Pedro Alves  wrote:

> On 7/12/19 9:24 AM, Jakub Jelinek wrote:
> > I'd just arrange that when being compiled with clang we compile with
> > -Wno-mismatched-tags to get rid of their misdesigned warning and not add
> > such misdesigned warning to GCC, that will just help people spread this
> > weirdo requirement further.
>
> FWIW and FYI, this is what GDB does (gdb/warning.m4).
>

As I understand it, the warning reflects a hard requirement for code that
wants to be portable to MSVC++, so I think it's useful to have for that
purpose.

Jason


Re: C++ PATCH for c++/81676 - bogus -Wunused warnings in constexpr if

2019-08-19 Thread Marek Polacek
On Fri, Aug 16, 2019 at 06:20:20PM -0700, Jason Merrill wrote:
> On 8/16/19 2:29 PM, Marek Polacek wrote:
> > This patch is an attempt to fix the annoying -Wunused-but-set-* warnings 
> > that
> > tend to occur with constexpr if.  When we have something like
> > 
> >template < typename T >
> >int f(T v){
> >if constexpr(sizeof(T) == sizeof(int)){
> >   return v;
> >}else{
> >   return 0;
> >}
> >}
> > 
> > and call f('a'), then the condition is false, meaning that we won't 
> > instantiate
> > the then-branch, as per tsubst_expr/IF_STMT:
> > 17284   if (IF_STMT_CONSTEXPR_P (t) && integer_zerop (tmp))
> > 17285 /* Don't instantiate the THEN_CLAUSE. */;
> > so we'll never get round to mark_exp_read-ing the decls used in the
> > then-branch, causing finish_function to emit "parameter set but not used"
> > warnings.
> > 
> > It's unclear how to best deal with this.  Marking the decls DECL_READ_P 
> > while
> > parsing doesn't seem like a viable approach
> 
> Why not?

Well, while parsing, we're in a template and so the condition won't be
evaluated until tsubst_expr.  So we can't tell which branch is dead.

I suppose we could still mark all the _DECLs in then/else branches as read,
in finish_if_stmt if IF_STMT_CONSTEXPR_P, but that seems really really ugly.

--
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA


Re: Special Memory Constraint [was Re: Indirect memory addresses vs. lra]

2019-08-19 Thread John Darrington
On Mon, Aug 19, 2019 at 10:07:11AM -0500, Segher Boessenkool wrote:

 > ? As I remember there were a few other ideas from Richard Biener and 
 > Segher Boessenkool.? I also proposed to add a new address register which 
 > will be always a fixed stack memory slot at the end. Unfortunately I am 
 > not familiar with the target and the port to say in details how to do 
 > it.? But I think it is worth to try.
 
 The m68hc11 port used the fake Z register approach, and I believe it had
 some special machine pass to get rid of it right before assembler output.
 
 (r171302 is when it was removed -- last version was
 
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/m68hc11/m68hc11.c;h=1e414102c3f1fed985e4fb8db7954342e965190b;hb=bae8bb65d842d7ffefe990c1f0ac004491f3c105#l4061
 for the machine reorg stuff).
 
 No idea how well it works...  But it's only needed if you are forced to
 have a frame pointer IIUC?
 
 
 Segher


Most of these suggestions involve adding some sort of virtual registers
So I hacked the machine description to add two new registers Z1 and Z2 
with the same mode as X and Y.

Obviously the assembler balks at this.  However the compiler still
ICEs at the same place as before.

So this suggests that our original diagnosis, viz: there are not enough
address registers was not accurate, and in fact there is some other
problem?

J'

-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.



[Bug fortran/91426] Different colors for errors with multiple locations

2019-08-19 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91426

--- Comment #4 from David Malcolm  ---
(In reply to Thomas Koenig from comment #2)
> Having had occasion to look at a few hundred multi-line error messages
> today, I have now changed my mind on what I would consider best :-)
> 
> I now think different colors for primary and secondary error message
> (if we stick with a maximum of two) is actually quite good.
> 
> What would help a lot if the markers (1) and (2) in
> 
> Error: Duplicate statement label 10 at (1) and (2)
> 
> were also colored the same as the two markers under the
> text of the program.
> 
> Would this be doable / would others also find that useful?

The patch I've just attached ought to do this (though it's just a crude
prototype - it only works for the gfc_error_opt case).

With that caveat, how does the output look?

[Bug fortran/91426] Different colors for errors with multiple locations

2019-08-19 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91426

--- Comment #3 from David Malcolm  ---
Created attachment 46732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46732=edit
Prototype patch to colorize the (1) and (2) in the example given

Re: [PATCH], Patch #2 of 10, Add RTL prefixed attribute

2019-08-19 Thread Segher Boessenkool
Hi Mike,

Some comments on this patch:

On Wed, Aug 14, 2019 at 05:59:13PM -0400, Michael Meissner wrote:
> Due to some of the existing load and store insns not using the traditional
> operands[0] and operands[1], the functions that test whether an insn is
> prefixed only use the insn and not the operands directly.

Both the "update" and the "indexed" attributes have no problem with
this: the insns that have the problem set the attribute value directly.
This is mainly all the various update insns, but there are a bunch more,
and they all need different settings for their attributes.

>   * config/rs6000/rs6000.c (rs6000_emit_move): Add support for
>   loading up pc-relatve addresses.

(typo btw)

> +void
> +rs6000_final_prescan_insn (rtx_insn *insn)
> +{
> +  next_insn_prefixed_p = (get_attr_prefixed (insn) != PREFIXED_NO);
> +  return;
> +}

Don't say "return;" at the end of a function please.

> +void
> +rs6000_asm_output_opcode (FILE *stream, const char *)
> +{
> +  if (next_insn_prefixed_p)
> +{
> +  next_insn_prefixed_p = false;
> +  fprintf (stream, "p");
> +}

You don't need to clear the flag here; the next call to
rs6000_final_prescan_insn will.

> +#define FINAL_PRESCAN_INSN(INSN, OPERANDS, NOPERANDS)
> \
> +do   \
> +  {  \
> +if (TARGET_PREFIXED_ADDR)
> \
> +  rs6000_final_prescan_insn (INSN);  
> \
> +  }  \
> +while (0)

Either have the function only do what it needs to for prefixed, and call
it something with prefixed in the name, or put the TARGET_PREFIXED_ADDR
test in the function itself.

> +;; Load up a pc-relative address.  ASM_OUTPUT_OPCODE will emit the initial 
> "p".
> +(define_insn "*pcrel_addr"
> +  [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
> + (match_operand:DI 1 "pcrel_address"))]
> +  "TARGET_PCREL"
> +  "la %0,%a1"
> +  [(set_attr "prefixed" "yes")])

(use P for addresses please)

> +;; Load up a pc-relative address to an external symbol.  If the symbol and 
> the
> +;; program are both defined in the main program, the linker will optimize 
> this
> +;; to a PADDI.  Otherwise, it will create a GOT address that is relocated by
> +;; the dynamic linker and loaded up.
> +(define_insn "*pcrel_ext_addr"
> +  [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
> + (match_operand:DI 1 "pcrel_external_address"))]
> +  "TARGET_PCREL"
> +  "ld %0,%a1"
> +  [(set_attr "prefixed" "yes")])

pld does an indirection more than pla does, but this is not clear at all
from the RTL, from the predicate names.  All this is *before* the linker
has done its thing, so pcrel_external_address is really some GOT memory,
so it should have that in its name.


Segher


[Bug ada/91492] New: [10 regression] Ada documentation issue starting with r274637

2019-08-19 Thread seurer at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91492

Bug ID: 91492
   Summary: [10 regression]  Ada documentation issue starting with
r274637
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: seurer at gcc dot gnu.org
  Target Milestone: ---

FAIL: compiler driver --help=ada option(s): "^ +-.*[^:.]$" absent from output:
"  -fdump-scos Dump Source Coverage Obligations"

Did a test case not get updated with the recent Ada changes?

[Bug tree-optimization/91491] New: [9 Regression] glib2.0 build not working when built with -O2 on x86_64-linux-gnu

2019-08-19 Thread doko at debian dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91491

Bug ID: 91491
   Summary: [9 Regression] glib2.0 build not working when built
with -O2 on x86_64-linux-gnu
   Product: gcc
   Version: 9.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: doko at debian dot org
  Target Milestone: ---

Created attachment 46731
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46731=edit
preprocessed source

[forwarded from https://bugs.debian.org/931921]

Seen with 9.2.0 on x86_64-linux-gnu, works with GCC 8, or with GCC 9 -O1.

Further tracked down to:

On Fri, 02 Aug 2019 at 19:49:20 +0100, Simon McVittie wrote:
> If you compile test_run_seed() with -O1, and the rest of gtestutils.c
> with -O2, the clutter test hangs.

Binary-searching through the extra optimizations enabled by -O2 [1]
led me to the minimal change being: if you modify test_run_seed() to add

__attribute__((optimize("no-tree-pre")))

then the clutter test passes. Without that attribute it fails.


Attaching the preprocessed gtestutils source.

Re: Faster number printing and pointer alignment algorithms.

2019-08-19 Thread Ruslan Kabatsayev
Hi Cale,

On Mon, 19 Aug 2019 at 19:50, Cale McCollough  wrote:
>
> My name is Cale McCollough and I'm the author of the Fastest Method to
> Print Integers and Floating-point Numbers, the Puff algorithm, that
> eliminates over half of the division instructions from the
> industry-standard mod 100 div 100 technique, saving hundreds to thousands
> of clock cycles and eliminating one division instruction from Grisu2, the
> world's fastest floating-point-to-string algoihrm.

How does performance of your method compare to that of Ryū
(sources[1], paper[2])?

[1]: https://github.com/ulfjack/ryu
[2]: https://dl.acm.org/citation.cfm?id=3192369

> The article can be found
> at:
> https://github.com/kabuki-starship/script2/wiki/Fastest-Method-to-Print-Integers-and-Floating-point-Numbers
>
> The other Visual-C++ optimization I have for the community is the Fastest
> Method to Align Pointers, which uses only 3 instructions plus loading the
> mask. I have verified is faster than Microsoft and GCC implementation. The
> article can be found at:
> https://github.com/kabuki-starship/script2/wiki/Fastest-Method-to-Align-Pointers
>
> Also, I have invested all of my time and labor into these open-source
> technologies, have worked for years without pay, and I am looking for a
> cool job that can facilitate my MongoDB/BJSON competitor called the ASCII
> Abstract Data Specification, Chinese Room Abstract Stack Machine (Crabs),
> SCRIPT Protocol, and Script2. Thanks.

Regards,
Ruslan


Re: [AArch64] Tweak handling of fp moves via int registers

2019-08-19 Thread James Greenhalgh
On Wed, Aug 07, 2019 at 07:12:19PM +0100, Richard Sandiford wrote:
> The AArch64 port uses define_splits to prefer moving certain float
> constants via integer registers over loading them from memory.  E.g.:
> 
> (set (reg:SF X) (const_double:SF C))
> 
> splits to:
> 
> (set (reg:SI tmp) (const_int C'))
> (set (reg:SF X) (subreg:SF (reg:SI tmp) 0))
> 
> The problem with using splits for this -- especially when the split
> instruction is a constant move -- is that the original form is still
> valid and can be recreated by later pre-RA passes.  (And I think that's
> a valid thing for them to do, since they're folding away what appears in
> rtl terms to be a redundant instruction.)
> 
> One pass that can do this is ira's combine_and_move_insns, which among
> other things looks for registers that are set once and used once.
> If the register is set to a rematerialisable value, the code tries
> to fold that value into the single use.
> 
> We don't normally see this effect at -O2 and above because
> combine_and_move_insns isn't run when -fsched-pressure is enabled
> (which it is by default on AArch64).  But arguably the combine part is
> useful independently of -fsched-pressure, and only the move part is
> suspect.  So I don't think we should rely on the combination not
> happening here.
> 
> The new tests demonstrate the problem by running the original tests
> at -O instead of -O2.
> 
> This patch does the optimisation by splitting the moves at generation
> time and rejecting the combined form while the split is still possible.
> REG_EQUAL notes on the second move still give the original floating-point
> value for passes that need it.
> 
> Tested on aarch64-linux-gnu (with and without SVE) and aarch64_be-elf.
> OK to install?

OK.

Thanks,
James

> Richard
> 
> 
> 2019-08-07  Richard Sandiford  
> 
> gcc/
>   * config/aarch64/aarch64-protos.h (aarch64_move_float_via_int_p):
>   Declare.
>   * config/aarch64/aarch64.c (aarch64_move_float_via_int_p): New
>   function, extracted from the GPF_HF move splitter.
>   * config/aarch64/aarch64.md: Remove GPF_HF move splitter.
>   (mov): Move via an integer register if
>   aarch64_move_float_via_int_p.
>   (*movhf_aarch64, *movsf_aarch64, *movdf_aarch64): Check
>   aarch64_move_float_via_int_p.
>   * config/aarch64/iterators.md (fcvt_target): Handle TI and TF.
>   (FCVT_TARGET): Likewise.
> 
> gcc/testsuite/
>   * gcc.target/aarch64/dbl_mov_immediate_2.c: New test.
>   * gcc.target/aarch64/f16_mov_immediate_5.c: Likewise.
>   * gcc.target/aarch64/flt_mov_immediate_2.c: Likewise.


Faster number printing and pointer alignment algorithms.

2019-08-19 Thread Cale McCollough
My name is Cale McCollough and I'm the author of the Fastest Method to
Print Integers and Floating-point Numbers, the Puff algorithm, that
eliminates over half of the division instructions from the
industry-standard mod 100 div 100 technique, saving hundreds to thousands
of clock cycles and eliminating one division instruction from Grisu2, the
world's fastest floating-point-to-string algoihrm. The article can be found
at:
https://github.com/kabuki-starship/script2/wiki/Fastest-Method-to-Print-Integers-and-Floating-point-Numbers

The other Visual-C++ optimization I have for the community is the Fastest
Method to Align Pointers, which uses only 3 instructions plus loading the
mask. I have verified is faster than Microsoft and GCC implementation. The
article can be found at:
https://github.com/kabuki-starship/script2/wiki/Fastest-Method-to-Align-Pointers

Also, I have invested all of my time and labor into these open-source
technologies, have worked for years without pay, and I am looking for a
cool job that can facilitate my MongoDB/BJSON competitor called the ASCII
Abstract Data Specification, Chinese Room Abstract Stack Machine (Crabs),
SCRIPT Protocol, and Script2. Thanks.


Re: PR90724 - ICE with __sync_bool_compare_and_swap with -march=armv8.2-a

2019-08-19 Thread James Greenhalgh
On Thu, Aug 15, 2019 at 02:11:25PM +0100, Prathamesh Kulkarni wrote:
> On Thu, 8 Aug 2019 at 11:22, Prathamesh Kulkarni
>  wrote:
> >
> > On Thu, 1 Aug 2019 at 15:34, Prathamesh Kulkarni
> >  wrote:
> > >
> > > On Thu, 25 Jul 2019 at 11:56, Prathamesh Kulkarni
> > >  wrote:
> > > >
> > > > On Wed, 17 Jul 2019 at 18:15, Prathamesh Kulkarni
> > > >  wrote:
> > > > >
> > > > > On Wed, 17 Jul 2019 at 13:45, Kyrill Tkachov
> > > > >  wrote:
> > > > > >
> > > > > > Hi Prathamesh
> > > > > >
> > > > > > On 7/10/19 12:24 PM, Prathamesh Kulkarni wrote:
> > > > > > > Hi,
> > > > > > > For following test-case,
> > > > > > > static long long AL[24];
> > > > > > >
> > > > > > > int
> > > > > > > check_ok (void)
> > > > > > > {
> > > > > > >   return (__sync_bool_compare_and_swap (AL+1, 0x20003ll,
> > > > > > > 0x1234567890ll));
> > > > > > > }
> > > > > > >
> > > > > > > Compiling with -O2 -march=armv8.2-a results in:
> > > > > > > pr90724.c: In function ‘check_ok’:
> > > > > > > pr90724.c:7:1: error: unrecognizable insn:
> > > > > > > 7 | }
> > > > > > >   | ^
> > > > > > > (insn 11 10 12 2 (set (reg:CC 66 cc)
> > > > > > > (compare:CC (reg:DI 95)
> > > > > > > (const_int 8589934595 [0x20003]))) 
> > > > > > > "pr90724.c":6:11 -1
> > > > > > >  (nil))
> > > > > > >
> > > > > > > IIUC, the issue is that 0x20003 falls outside the range of
> > > > > > > allowable immediate in cmp ? If it's replaced by a small constant 
> > > > > > > then
> > > > > > > it works.
> > > > > > >
> > > > > > > The ICE results with -march=armv8.2-a because, we enter if
> > > > > > > (TARGET_LSE) { ... } condition
> > > > > > > in aarch64_expand_compare_and_swap, while with -march=armv8.a it 
> > > > > > > goes
> > > > > > > into else,
> > > > > > > which forces oldval into register if the predicate fails to match.
> > > > > > >
> > > > > > > The attached patch checks if y (oldval) satisfies 
> > > > > > > aarch64_plus_operand
> > > > > > > predicate and if not, forces it to be in register, which resolves 
> > > > > > > ICE.
> > > > > > > Does it look OK ?
> > > > > > >
> > > > > > > Bootstrap+testing in progress on aarch64-linux-gnu.
> > > > > > >
> > > > > > > PS: The issue has nothing to do with SVE, which I incorrectly
> > > > > > > mentioned in bug report.
> > > > > > >
> > > > > > This looks ok to me (but you'll need maintainer approval).
> > > > > >
> > > > > > Does this fail on the branches as well?
> > > > > Hi Kyrill,
> > > > > Thanks for the review. The test also fails on gcc-9-branch (but not 
> > > > > on gcc-8).
> > > > Hi James,
> > > > Is the patch OK to commit  ?
> > > > https://gcc.gnu.org/ml/gcc-patches/2019-07/msg00793.html
> > > ping * 3: https://gcc.gnu.org/ml/gcc-patches/2019-07/msg00793.html
> > ping * 4: https://gcc.gnu.org/ml/gcc-patches/2019-07/msg00793.html
> ping * 5: https://gcc.gnu.org/ml/gcc-patches/2019-07/msg00793.html

Hi,

Sorry, this missed my filters as it didn't mention AArch64 in the subject
line.

Thais is good for trunk, thanks for waiting.

James



[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-08-19 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Jambor  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #23 from Martin Jambor  ---
(In reply to Martin Liška from comment #22)
> Should be fixed now.

So let's assume it is.

Re: [PATCH 0/2] PR libstdc++/41861 Add full steady_clock support to condition_variable

2019-08-19 Thread Mike Crowe
On Monday 15 July 2019 at 17:47:47 +0100, Mike Crowe wrote:
> The pthread_cond_clockwait function was recently added[1] to glibc,
> and is due to be released in glibc 2.30. If this function is available
> in the C library it can be used it to fix
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41861 by supporting
> std::chrono::steady_clock properly with std::condition_variable.
> 
> Mike Crowe (2):
>   Add user-defined clock to libstdc++ condition_variable tests
>   PR libstdc++/41861 Add full steady_clock support to condition_variable
> 
>  libstdc++-v3/ChangeLog| 34 
> +-
>  libstdc++-v3/acinclude.m4 | 31 
> +++-
>  libstdc++-v3/config.h.in  |  3 
> +++-
>  libstdc++-v3/configure| 83 
> -
>  libstdc++-v3/configure.ac |  3 
> +++-
>  libstdc++-v3/include/std/condition_variable   | 52 
> +++--
>  libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc | 29 
> ++---
>  libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc | 29 
> ++---
>  8 files changed, 252 insertions(+), 12 deletions(-)
> 
> base-commit: 7b0d7c79224b412ea5073593943ab1525cbbda73
> -- 
> git-series 0.9.1

glibc 2.30 has now been released and contains pthread_cond_clockwait.

Mike.


Re: [PING][AArch64] Use scvtf fbits option where appropriate

2019-08-19 Thread James Greenhalgh
On Mon, Jul 08, 2019 at 04:41:06PM +0100, Joel Hutton wrote:
> On 01/07/2019 18:03, James Greenhalgh wrote:
> 
> >> gcc/testsuite/ChangeLog:
> >>
> >> 2019-06-12  Joel Hutton  
> >>
> >>   * gcc.target/aarch64/fmul_scvtf_1.c: New test.
> > This testcase will fail on ILP32 targets where unsigned long will still
> > live in a 'w' register.
> Updated to use long long and unsigned long long.

Sorry, this slipped through the cracks.

OK for trunk.

Thanks,
James


> 
> Joel
> 

> From e10d5fdb9430799cd2050b8a2f567d1b4e43cde1 Mon Sep 17 00:00:00 2001
> From: Joel Hutton 
> Date: Mon, 8 Jul 2019 11:59:50 +0100
> Subject: [PATCH] SCVTF
> 
> ---
>  gcc/config/aarch64/aarch64-protos.h   |   1 +
>  gcc/config/aarch64/aarch64.c  |  23 +++
>  gcc/config/aarch64/aarch64.md |  39 +
>  gcc/config/aarch64/constraints.md |   7 +
>  gcc/config/aarch64/predicates.md  |   4 +
>  .../gcc.target/aarch64/fmul_scvtf_1.c | 140 ++
>  6 files changed, 214 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/fmul_scvtf_1.c
> 


Re: [PATCH] Intrinsic documentation for DIM, MOD and MODULO.

2019-08-19 Thread Steve Kargl
On Mon, Aug 19, 2019 at 09:08:12AM -0600, Jeff Law wrote:
> On 8/19/19 3:11 AM, Mark Eggleston wrote:
> > The intrinsics DIM, MOD and MODULO can accept arguments of different
> > kinds and return values with the larger of the two kinds. Notes to this
> > effect have been added as they were missing from the documentation.
> > 
> > Please find attached the patch.
> > 
> > ChangeLog:
> > 
> > gcc/fortran/ChangeLog
> > 
> >     Mark Eggleston  
> > 
> >     PR fortran/89236
> >     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
> > 
> Do we want to be more specific about what types are accepted as a GNU
> extension for these operators?
> 

The current documentation already has that info.

_Arguments_:
 X   The type shall be 'INTEGER' or 'REAL'
 Y   The type shall be the same type and kind as X.

In Fortran standardese, INTEGER means any of the supported
integer kinds (e.g., INTEGER(2)).  X and Y must both be either
INTEGER or REAL, and X and Y must have the same kind type
paramter.  Mark's addition to the manual notes that the
GNU extension allows different kind type parameters, e.g.,

integer(1) i
integer(2) j
...
  k = dim(i,j) 

converts i to an integer(2) before executing the function.

Mark, BTW and IMHO, for minor changes/improvements to the gfortran
documentation, I consider these to be pre-approved.  For
large changes, or if you want someone to proofread a change,
then asking for commit approval is appropriate. 
-- 
Steve


Re: [patch][aarch64]: add intrinsics for vld1(q)_x4 and vst1(q)_x4

2019-08-19 Thread James Greenhalgh
On Thu, Aug 15, 2019 at 12:28:27PM +0100, Kyrill Tkachov wrote:
> Hi all,
> 
> On 8/6/19 10:51 AM, Richard Earnshaw (lists) wrote:
> On 18/07/2019 18:18, James Greenhalgh wrote:
> > On Mon, Jun 10, 2019 at 06:21:05PM +0100, Sylvia Taylor wrote:
> >> Greetings,
> >>
> >> This patch adds the intrinsic functions for:
> >> - vld1__x4
> >> - vst1__x4
> >> - vld1q__x4
> >> - vst1q__x4
> >>
> >> Bootstrapped and tested on aarch64-none-linux-gnu.
> >>
> >> Ok for trunk? If yes, I don't have any commit rights, so can someone
> >> please commit it on my behalf.
> >
> > Hi,
> >
> > I'm concerned by this strategy for implementing the arm_neon.h builtins:
> >
> >> +__extension__ extern __inline int8x8x4_t
> >> +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
> >> +vld1_s8_x4 (const int8_t *__a)
> >> +{
> >> +  union { int8x8x4_t __i; __builtin_aarch64_simd_xi __o; } __au;
> >> +  __au.__o
> >> += __builtin_aarch64_ld1x4v8qi ((const __builtin_aarch64_simd_qi *) 
> >> __a);
> >> +  return __au.__i;
> >> +}
> >
> > As far as I know this is undefined behaviour in C++11. This was the best
> > resource I could find pointing to the relevant standards paragraphs.
> >
> >
> > https://stackoverflow.com/questions/11373203/accessing-inactive-union-member-and-undefined-behavior
> >
> > That said, GCC explicitly allows it, so maybe this is fine?
> >
> >
> > https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Optimize-Options.html#Type-punning
> >
> > Can anyone from the languages side chime in on whether we're exposing
> > undefined behaviour (in either C or C++) here?
> 
> Yes, this is a GNU extension.  My only question is whether or not this
> can be disabled within GCC if you're trying to check for strict
> standards conformance of your code?  And if so, is there a way of making
> sure that this header still works in that case?  A number of GNU
> extensions can be protected with __extension__ but it's not clear how
> that could be applied in this case.  Perhaps the outer __extension__ on
> the function will already do that.
> 
> 
> It should still work. The only relevant flag is -fstrict-aliasing and it is
> documented to preserve this case:
> 
> https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Optimize-Options.html#Optimize-Options
> 
> Note that we've already been using this idiom in arm_neon.h since 2014 [1]
> and it's worked fine.

Based on that input, this is OK for trunk.

Thanks,
James

> 
> Thanks,
> 
> Kyrill
> 
> [1] http://gcc.gnu.org/r209880
> 
> 
> 
> R.


[Bug c++/79817] GCC does not recognize [[deprecated]] attribute for namespace

2019-08-19 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79817

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek  ---
This is relevant to range-v3 which renamed the "view" namespace to "views",
following the PascalCase -> snake_case change.

[Bug target/91386] [9 regression] open-iscsi iscsiadm miscompiled by LTO on aarch64

2019-08-19 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91386

Richard Earnshaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |9.3

--- Comment #24 from Richard Earnshaw  ---
Fixed for gcc-9.3.

Re: [aarch64] PR target/91386 Use copy_rtx to avoid modifying original insns in peep2 pattern

2019-08-19 Thread Richard Earnshaw (lists)

On 09/08/2019 17:15, Richard Earnshaw (lists) wrote:

PR target/91386 is a situation where a peephole2 pattern substitution
is discarded late because the selected instructions contain
frame-related notes that we cannot redistribute (because the pattern
has more than one insn in the output).  Unfortunately, the original
insns were being modified during the generation, so after the undo we
are left with corrupt RTL.

We avoid this by ensuring that the modifications are always made on a
copy, so that the original insns are never changed.

 PR target/91386
 * config/aarch64/aarch64.c (aarch64_gen_adjusted_ldpstp): Use copy_rtx
 to preserve the contents of the original insns.

Committed to trunk.


And now backported to gcc-9.

R.


[Bug target/91386] [9 regression] open-iscsi iscsiadm miscompiled by LTO on aarch64

2019-08-19 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91386

--- Comment #23 from Richard Earnshaw  ---
Author: rearnsha
Date: Mon Aug 19 16:11:30 2019
New Revision: 274675

URL: https://gcc.gnu.org/viewcvs?rev=274675=gcc=rev
Log:
[aarch64] PR target/91386 Use copy_rtx to avoid modifying original insns in
peep2 pattern

PR target/91386 is a situation where a peephole2 pattern substitution
is discarded late because the selected instructions contain
frame-related notes that we cannot redistribute (because the pattern
has more than one insn in the output).  Unfortunately, the original
insns were being modified during the generation, so after the undo we
are left with corrupt RTL.

We avoid this by ensuring that the modifications are always made on a
copy, so that the original insns are never changed.

Backport from mainline
2019-09-09  Richard Earnshaw  

PR target/91386
* config/aarch64/aarch64.c (aarch64_gen_adjusted_ldpstp): Use copy_rtx
to preserve the contents of the original insns.


Modified:
branches/gcc-9-branch/gcc/ChangeLog
branches/gcc-9-branch/gcc/config/aarch64/aarch64.c

[wwwdocs] Document C++ news in GCC 10 Release Notes

2019-08-19 Thread Marek Polacek
I'm of the mind that we should advertise some of the new cool
C++ changes going into GCC 10, esp. those that are user-visible.

Checking this in.

Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-10/changes.html,v
retrieving revision 1.8
diff -u -r1.8 changes.html
--- changes.html19 Aug 2019 14:08:10 -  1.8
+++ changes.html19 Aug 2019 15:53:27 -
@@ -48,10 +48,46 @@
 
 C++
 
+  Several C++20 features have been implemented:
+  
+P1668R1, Permitting Unevaluated inline-assembly in constexpr 
Functions
+P1161R3, Deprecate a[b,c]
+P0848R3, Conditionally Trivial Special Member Functions
+P1091R3, Extending structured bindings
+
+  
+  Several C++ Defect Reports have been resolved, e.g.:
+  
+DR 1560 (lvalue-to-rvalue conversion in ?:),
+DR 1813 (__is_standard_layout for a class with repeated
+   bases),
+DR 2094 (volatile scalars are trivially copyable),
+DR 2096 (constraints on literal unions),
+DR 2413 (typename in  
conversion-function-ids).
+   
+
+  
   
 G++ can now detect modifying constant objects in constexpr evaluation
 (which is undefined behavior).
   
+  
+G++ no longer emits bogus -Wsign-conversion warnings with 
explicit
+casts.
+  
+  
+Narrowing is now detected in more contexts (e.g., case
+values).
+  
+  
+Memory consumption of the compiler has been reduced in constexpr 
evaluation.
+  
+  
+The noexcept-specifier is now properly treated as a
+complete-class context as per
+http://eel.is/c++draft/class.mem#def:complete-class_context;>
+[class.mem].
+  
 
 
 


Re: [PATCH][ARM] Remove remaining Neon DImode support

2019-08-19 Thread Wilco Dijkstra
   
 
ping
    
  
 Remove the remaining Neon adddi3, subdi3 and negdi2 patterns.  As a result
  adddi3, subdi3 and negdi2 can now always be expanded early irrespectively of
  whether Neon is available.  Also expand the extenddi patterns at the same
  time.  Several Neon arch attributes are no longer used and removed.
  
  Code generation is improved in all cases, saving another 400-500 instructions
  from the PR77308 testcase (total improvement is over 1700 instructions with
  -mcpu=cortex-a57 -O2).
  
  Bootstrap & regress OK on arm-none-linux-gnueabihf --with-cpu=cortex-a57
  
  ChangeLog:
  2019-07-19  Wilco Dijkstra  
  
  * config/arm/arm.md (neon_for_64bits): Remove.
  (avoid_neon_for_64bits): Remove.
  (arm_adddi3): Always split early.
  (arm_subdi3): Always split early.
  (negdi2): Remove Neon expansion.
  (split zero_extend): Split before reload.
  (split sign_extend): Split before reload.
  ---
  
  diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
  index 
10ed70dac4384354c0a2453c5e51a29108c6c062..6d8a5a54997caee0e6956f01018cb5300a9a07e1
 100644
  --- a/gcc/config/arm/arm.md
  +++ b/gcc/config/arm/arm.md
  @@ -125,7 +125,7 @@ (define_attr "length" ""
   ; arm_arch6.  "v6t2" for Thumb-2 with arm_arch6 and "v8mb" for ARMv8-M
   ; Baseline.  This attribute is used to compute attribute "enabled",
   ; use type "any" to enable an alternative in all cases.
  -(define_attr "arch" 
"any,a,t,32,t1,t2,v6,nov6,v6t2,v8mb,neon_for_64bits,avoid_neon_for_64bits,iwmmxt,iwmmxt2,armv6_or_vfpv3,neon"
  +(define_attr "arch" 
"any,a,t,32,t1,t2,v6,nov6,v6t2,v8mb,iwmmxt,iwmmxt2,armv6_or_vfpv3,neon"
     (const_string "any"))
   
   (define_attr "arch_enabled" "no,yes"
  @@ -168,16 +168,6 @@ (define_attr "arch_enabled" "no,yes"
     (match_test "TARGET_THUMB1 && arm_arch8"))
    (const_string "yes")
   
  -    (and (eq_attr "arch" "avoid_neon_for_64bits")
  - (match_test "TARGET_NEON")
  - (not (match_test "TARGET_PREFER_NEON_64BITS")))
  -    (const_string "yes")
  -
  -    (and (eq_attr "arch" "neon_for_64bits")
  - (match_test "TARGET_NEON")
  - (match_test "TARGET_PREFER_NEON_64BITS"))
  -    (const_string "yes")
  -
    (and (eq_attr "arch" "iwmmxt2")
     (match_test "TARGET_REALLY_IWMMXT2"))
    (const_string "yes")
  @@ -450,13 +440,8 @@ (define_expand "adddi3"
   (clobber (reg:CC CC_REGNUM))])]
     "TARGET_EITHER"
     "
  -  if (TARGET_THUMB1)
  -    {
  -  if (!REG_P (operands[1]))
  -    operands[1] = force_reg (DImode, operands[1]);
  -  if (!REG_P (operands[2]))
  -    operands[2] = force_reg (DImode, operands[2]);
  - }
  +  if (TARGET_THUMB1 && !REG_P (operands[2]))
  +    operands[2] = force_reg (DImode, operands[2]);
     "
   )
   
  @@ -465,9 +450,9 @@ (define_insn_and_split "*arm_adddi3"
   (plus:DI (match_operand:DI 1 "arm_general_register_operand" "%0, 0, 
r, 0, r")
    (match_operand:DI 2 "arm_general_adddi_operand"    "r,  0, 
r, Dd, Dd")))
  (clobber (reg:CC CC_REGNUM))]
  -  "TARGET_32BIT && !TARGET_NEON"
  +  "TARGET_32BIT"
     "#"
  -  "TARGET_32BIT && ((!TARGET_NEON && !TARGET_IWMMXT) || reload_completed)"
  +  "TARGET_32BIT"
     [(parallel [(set (reg:CC_C CC_REGNUM)
  (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
    (match_dup 1)))
  @@ -1290,24 +1275,16 @@ (define_expand "subdi3"
   (clobber (reg:CC CC_REGNUM))])]
     "TARGET_EITHER"
     "
  -  if (TARGET_THUMB1)
  -    {
  -  if (!REG_P (operands[1]))
  -    operands[1] = force_reg (DImode, operands[1]);
  -  if (!REG_P (operands[2]))
  -    operands[2] = force_reg (DImode, operands[2]);
  - } 
  -  "
  -)
  +")
   
   (define_insn_and_split "*arm_subdi3"
     [(set (match_operand:DI   0 "arm_general_register_operand" 
"=,,")
   (minus:DI (match_operand:DI 1 "arm_general_register_operand" "0,r,0")
     (match_operand:DI 2 "arm_general_register_operand" 
"r,0,0")))
  (clobber (reg:CC CC_REGNUM))]
  -  "TARGET_32BIT && !TARGET_NEON"
  +  "TARGET_32BIT"
     "#"  ; "subs\\t%Q0, %Q1, %Q2\;sbc\\t%R0, %R1, %R2"
  -  "&& (!TARGET_IWMMXT || reload_completed)"
  +  "TARGET_32BIT"
     [(parallel [(set (reg:CC CC_REGNUM)
  (compare:CC (match_dup 1) (match_dup 2)))
     (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
  @@ -4164,13 +4141,6 @@ (define_expand "negdi2"
    (neg:DI (match_operand:DI 1 "s_register_operand")))
   (clobber (reg:CC CC_REGNUM))])]
     "TARGET_EITHER"
  -  {
  -    if (TARGET_NEON)
  -  {
  -    emit_insn (gen_negdi2_neon (operands[0], operands[1]));
  -   DONE;
  -  }
  -  }
   )
   
   ;; The constraints here are to prevent a *partial* overlap (where %Q0 == 
%R1).
  @@ -4182,7 +4152,7 @@ 

Re: [PATCH][ARM] Cleanup DImode shifts

2019-08-19 Thread Wilco Dijkstra


   
 
ping
    
  
 Like the logical operations, expand all shifts early rather than only
  sometimes.  The Neon shift expansions are never emitted (not even with
  -fneon-for-64bits), so they are not useful.  So all the late expansions
  and Neon shift patterns can be removed, and shifts are more optimized
  as a result.  Since some extend patterns use Neon DImode shifts, remove
  the Neon extend variants and related splits.
  
  A simple example (relying on [1]) generates the same efficient code after
  this patch with -mfpu=neon and -mfpu=vfp (previously just the fact of
  having Neon enabled resulted inefficient code for no reason).
  
  unsigned long long f(unsigned long long x, unsigned long long y)
  { return x & (y >> 33); }
  
  Before:
  strd    r4, r5, [sp, #-8]!
  lsr r4, r3, #1
  mov r5, #0
  and r1, r1, r5
  and r0, r0, r4
  ldrd    r4, r5, [sp]
  add sp, sp, #8
  bx  lr
  
  After:
  and r0, r0, r3, lsr #1
  mov r1, #0
  bx  lr
  
  Bootstrap and regress OK on arm-none-linux-gnueabihf --with-cpu=cortex-a57
  
  [1] https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01301.html
  
  ChangeLog:
  2019-07-19  Wilco Dijkstra  
  
  * config/arm/iterators.md (qhs_extenddi_cstr): Update.
  (qhs_extenddi_cstr): Likewise.
  * config/arm/arm.md (ashldi3): Always expand early.
  (ashlsi3): Likewise.
  (ashrsi3): Likewise.
  (zero_extenddi2): Remove Neon variants.
  (extenddi2): Likewise.
  * config/arm/neon.md (ashldi3_neon_noclobber): Remove.
  (signed_shift_di3_neon): Likewise.
  (unsigned_shift_di3_neon): Likewise.
  (ashrdi3_neon_imm_noclobber): Likewise.
  (lshrdi3_neon_imm_noclobber): Likewise.
  (di3_neon): Likewise.
  (split extend): Remove DI extend split patterns.
  
  testsuite/
  * gcc.target/arm/neon-extend-1.c: Remove test.
  * gcc.target/arm/neon-extend-2.c: Remove test.
  ---
  
  diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
  index 
0dba97a4ebeed0c2133936ca662f1c9e86ffc6ba..10ed70dac4384354c0a2453c5e51a29108c6c062
 100644
  --- a/gcc/config/arm/arm.md
  +++ b/gcc/config/arm/arm.md
  @@ -3601,44 +3601,14 @@ (define_insn "*satsi__shift"
   (define_expand "ashldi3"
     [(set (match_operand:DI    0 "s_register_operand")
   (ashift:DI (match_operand:DI 1 "s_register_operand")
  -   (match_operand:SI 2 "general_operand")))]
  +   (match_operand:SI 2 "reg_or_int_operand")))]
     "TARGET_32BIT"
     "
  -  if (TARGET_NEON)
  -    {
  -  /* Delay the decision whether to use NEON or core-regs until
  -    register allocation.  */
  -  emit_insn (gen_ashldi3_neon (operands[0], operands[1], operands[2]));
  -  DONE;
  -    }
  -  else
  -    {
  -  /* Only the NEON case can handle in-memory shift counts.  */
  -  if (!reg_or_int_operand (operands[2], SImode))
  -    operands[2] = force_reg (SImode, operands[2]);
  -    }
  -
  -  if (!CONST_INT_P (operands[2]) && TARGET_REALLY_IWMMXT)
  -    ; /* No special preparation statements; expand pattern as above.  */
  -  else
  -    {
  -  rtx scratch1, scratch2;
  -
  -  /* Ideally we should use iwmmxt here if we could know that operands[1]
  - ends up already living in an iwmmxt register. Otherwise it's
  - cheaper to have the alternate code being generated than moving
  - values to iwmmxt regs and back.  */
  -
  -  /* Expand operation using core-registers.
  -    'FAIL' would achieve the same thing, but this is a bit smarter.  */
  -  scratch1 = gen_reg_rtx (SImode);
  -  scratch2 = gen_reg_rtx (SImode);
  -  arm_emit_coreregs_64bit_shift (ASHIFT, operands[0], operands[1],
  -    operands[2], scratch1, scratch2);
  -  DONE;
  -    }
  -  "
  -)
  +  arm_emit_coreregs_64bit_shift (ASHIFT, operands[0], operands[1],
  +    operands[2], gen_reg_rtx (SImode),
  +    gen_reg_rtx (SImode));
  +  DONE;
  +")
   
   (define_expand "ashlsi3"
     [(set (match_operand:SI    0 "s_register_operand")
  @@ -3661,35 +3631,11 @@ (define_expand "ashrdi3"
    (match_operand:SI 2 "reg_or_int_operand")))]
     "TARGET_32BIT"
     "
  -  if (TARGET_NEON)
  -    {
  -  /* Delay the decision whether to use NEON or core-regs until
  -    register allocation.  */
  -  emit_insn (gen_ashrdi3_neon (operands[0], operands[1], operands[2]));
  -  DONE;
  -    }
  -
  -  if (!CONST_INT_P (operands[2]) && TARGET_REALLY_IWMMXT)
  -    ; /* No special preparation statements; expand pattern as above.  */
  -  else
  -    {
  -  rtx scratch1, scratch2;
  -
  -  /* Ideally we should use iwmmxt here if we could know that operands[1]
  - ends up 

Re: [PATCH][ARM] Cleanup logical DImode operations

2019-08-19 Thread Wilco Dijkstra
   
 
ping
    
  
 
  Cleanup the logical DImode operations since the current implementation is way
  too complicated.  Thumb-1, Thumb-2, VFP/Neon and iwMMXt all work differently,
  resulting in a bewildering number of expansions, patterns and splits across
  several md files.  All this complexity is counterproductive and results in
  inefficient code.
  
  A much simpler approach is to split these operations early in the expander
  so that optimizations and register allocation are applied on the 32-bit 
halves.
  Code generation is unchanged on Thumb-1 and Arm/Thumb-2 without Neon or iwMMXt
  (which already expand these instructions early).  With Neon these changes save
  ~1000 instructions from the PR77308 testcase, mostly by significantly reducing
  register pressure and spilling.
  
  Bootstrap & regress OK on arm-none-linux-gnueabihf --with-cpu=cortex-a57
  
  OK for commit?
  
  ChangeLog:
  2019-07-18  Wilco Dijkstra  
  
  * config/arm/arm.md (split and/eor/ior): Remove Neon check.
  (split not): Add DImode not splitter.
  (anddi3): Remove pattern.
  (anddi3_insn): Likewise.
  (anddi_zesidi_di): Likewise.
  (anddi_sesdi_di): Likewise.
  (anddi_notdi_di): Likewise.
  (anddi_notzesidi_di): Likewise.
  (anddi_notsesidi_di): Likewise.
  (iordi3): Likewise.
  (iordi3_insn): Likewise.
  (iordi_zesidi_di): Likewise.
  (iordi_sesidi_di): Likewise.
  (xordi3): Likewise.
  (xordi3_insn): Likewise.
  (xordi_sesidi_di): Likewise.
  (xordi_zesidi_di): Likewise.
  (one_cmpldi2): Likewise.
  (one_cmpldi2_insn): Likewise.
  * config/arm/constraints.md: Remove De, Df, Dg constraints.
  * config/arm/iwmmxt.md (iwmmxt_iordi3): Remove general register
  alternative.
  (iwmmxt_xordi3): Likewise.
  (iwmmxt_anddi3): Likewise.
  * config/arm/neon.md (orndi3_neon): Remove pattern.
  (anddi_notdi_di): Likewise.
  * config/arm/predicates.md (arm_anddi_operand_neon): Remove.
  (arm_iordi_operand_neon): Likewise.
  (arm_xordi_operand_neon): Likewise.
  * config/arm/thumb2.md(iordi_notdi_di): Remove pattern.
  (iordi_notzesidi_di): Likewise.
  (iordi_notdi_zesidi): Likewise.
  (iordi_notsesidi_di): Likewise.
  
  
  ---
  diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
  index 
8f4a4c26ea849a023f2e63d2efbf327423512dfc..cab59c403b777c37c1e412ab9a69db2c2ec533a2
 100644
  --- a/gcc/config/arm/arm.md
  +++ b/gcc/config/arm/arm.md
  @@ -2183,19 +2183,16 @@ (define_expand "divdf3"
     "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP_DOUBLE"
     "")
    
  -;; Boolean and,ior,xor insns
   
  -;; Split up double word logical operations
  -
  -;; Split up simple DImode logical operations.  Simply perform the logical
  +;; Split DImode and, ior, xor operations.  Simply perform the logical
   ;; operation on the upper and lower halves of the registers.
  +;; This is needed for atomic operations in arm_split_atomic_op.
   (define_split
     [(set (match_operand:DI 0 "s_register_operand" "")
   (match_operator:DI 6 "logical_binary_operator"
     [(match_operand:DI 1 "s_register_operand" "")
  (match_operand:DI 2 "s_register_operand" "")]))]
     "TARGET_32BIT && reload_completed
  -   && ! (TARGET_NEON && IS_VFP_REGNUM (REGNO (operands[0])))
  && ! IS_IWMMXT_REGNUM (REGNO (operands[0]))"
     [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
  (set (match_dup 3) (match_op_dup:SI 6 [(match_dup 4) (match_dup 5)]))]
  @@ -2210,167 +2207,20 @@ (define_split
     }"
   )
   
  +;; Split DImode not (needed for atomic operations in arm_split_atomic_op).
   (define_split
  -  [(set (match_operand:DI 0 "s_register_operand" "")
  -   (match_operator:DI 6 "logical_binary_operator"
  - [(sign_extend:DI (match_operand:SI 2 "s_register_operand" ""))
  -  (match_operand:DI 1 "s_register_operand" "")]))]
  -  "TARGET_32BIT && reload_completed"
  -  [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
  -   (set (match_dup 3) (match_op_dup:SI 6
  -   [(ashiftrt:SI (match_dup 2) (const_int 31))
  -    (match_dup 4)]))]
  -  "
  -  {
  -    operands[3] = gen_highpart (SImode, operands[0]);
  -    operands[0] = gen_lowpart (SImode, operands[0]);
  -    operands[4] = gen_highpart (SImode, operands[1]);
  -    operands[1] = gen_lowpart (SImode, operands[1]);
  -    operands[5] = gen_highpart (SImode, operands[2]);
  -    operands[2] = gen_lowpart (SImode, operands[2]);
  -  }"
  -)
  -
  -;; The zero extend of operand 2 means we can just copy the high part of
  -;; operand1 into operand0.
  -(define_split
  -  [(set (match_operand:DI 0 "s_register_operand" "")
  -   (ior:DI
  - (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))
  -   

Re: [PATCH][AArch64] Fix symbol offset limit

2019-08-19 Thread Wilco Dijkstra
   
 
ping
    
  
 In aarch64_classify_symbol symbols are allowed full-range offsets on 
relocations. 
  This means the offset can use all of the +/-4GB offset, leaving no offset 
available
  for the symbol itself.  This results in relocation overflow and link-time 
errors
  for simple expressions like _char + 0xff00.
  
  To avoid this, limit the offset to +/-1MB so that the symbol needs to be 
within a
  3.9GB offset from its references.  For the tiny code model use a 64KB offset, 
allowing
  most of the 1MB range for code/data between the symbol and its references.
  
  Bootstrapped on AArch64, passes regress, OK for commit?
  
  ChangeLog:
  2018-11-09  Wilco Dijkstra  
  
  gcc/
  * config/aarch64/aarch64.c (aarch64_classify_symbol):
  Apply reasonable limit to symbol offsets.
  
  testsuite/
  * gcc.target/aarch64/symbol-range.c (foo): Set new limit.
  * gcc.target/aarch64/symbol-range-tiny.c (foo): Likewise.
  
  --
  
  diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
  index 
83453d03095018eddd1801e71ef3836849267444..0023cb37bbae5afe9387840c1bb6b43586d4fac2
 100644
  --- a/gcc/config/aarch64/aarch64.c
  +++ b/gcc/config/aarch64/aarch64.c
  @@ -13047,26 +13047,26 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT 
offset)
    the offset does not cause overflow of the final address.  But
    we have no way of knowing the address of symbol at compile time
    so we can't accurately say if the distance between the PC and
  -    symbol + offset is outside the addressible range of +/-1M in the
  -    TINY code model.  So we rely on images not being greater than
  -    1M and cap the offset at 1M and anything beyond 1M will have to
  -    be loaded using an alternative mechanism.  Furthermore if the
  -    symbol is a weak reference to something that isn't known to
  -    resolve to a symbol in this module, then force to memory.  */
  +    symbol + offset is outside the addressible range of +/-1MB in the
  +    TINY code model.  So we limit the maximum offset to +/-64KB and
  +    assume the offset to the symbol is not larger than +/-(1MB - 
64KB).
  +    Furthermore force to memory if the symbol is a weak reference to
  +    something that doesn't resolve to a symbol in this module.  */
     if ((SYMBOL_REF_WEAK (x)
  && !aarch64_symbol_binds_local_p (x))
  - || !IN_RANGE (offset, -1048575, 1048575))
  + || !IN_RANGE (offset, -0x1, 0x1))
   return SYMBOL_FORCE_TO_MEM;
  +
     return SYMBOL_TINY_ABSOLUTE;
   
   case AARCH64_CMODEL_SMALL:
     /* Same reasoning as the tiny code model, but the offset cap here 
is
  -    4G.  */
  +    1MB, allowing +/-3.9GB for the offset to the symbol.  */
     if ((SYMBOL_REF_WEAK (x)
  && !aarch64_symbol_binds_local_p (x))
  - || !IN_RANGE (offset, HOST_WIDE_INT_C (-4294967263),
  -   HOST_WIDE_INT_C (4294967264)))
  + || !IN_RANGE (offset, -0x10, 0x10))
   return SYMBOL_FORCE_TO_MEM;
  +
     return SYMBOL_SMALL_ABSOLUTE;
   
   case AARCH64_CMODEL_TINY_PIC:
  diff --git a/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c 
b/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
  index 
d7e46b059e41f2672b3a1da5506fa8944e752e01..d49ff4dbe5786ef6d343d2b90052c09676dd7fe5
 100644
  --- a/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
  +++ b/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
  @@ -1,12 +1,12 @@
  -/* { dg-do compile } */
  +/* { dg-do link } */
   /* { dg-options "-O3 -save-temps -mcmodel=tiny" } */
   
  -int fixed_regs[0x0020];
  +char fixed_regs[0x0020];
   
   int
  -foo()
  +main ()
   {
  -  return fixed_regs[0x0008];
  +  return fixed_regs[0x000ff000];
   }
   
   /* { dg-final { scan-assembler-not "adr\tx\[0-9\]+, fixed_regs\\\+" } } */
  diff --git a/gcc/testsuite/gcc.target/aarch64/symbol-range.c 
b/gcc/testsuite/gcc.target/aarch64/symbol-range.c
  index 
6574cf4310430b847e77ea56bf8f20ef312d53e4..75c87c12f08004c153efc5192e5cfab566c089db
 100644
  --- a/gcc/testsuite/gcc.target/aarch64/symbol-range.c
  +++ b/gcc/testsuite/gcc.target/aarch64/symbol-range.c
  @@ -1,12 +1,12 @@
  -/* { dg-do compile } */
  +/* { dg-do link } */
   /* { dg-options "-O3 -save-temps -mcmodel=small" } */
   
  -int fixed_regs[0x2ULL];
  +char fixed_regs[0x2ULL];
   
   int
  -foo()
  +main ()
   {
  -  return fixed_regs[0x1ULL];
  +  return fixed_regs[0xf000ULL];
   }
   
   /* { dg-final { scan-assembler-not "adrp\tx\[0-9\]+, fixed_regs\\\+" } } */
  
  

Re: [PATCH][ARM] Switch to default sched pressure algorithm

2019-08-19 Thread Wilco Dijkstra


ping


  
Currently the Arm backend selects the alternative sched pressure algorithm.
 The issue is that this doesn't take register pressure into account, and so
 it causes significant additional spilling on Arm where there are only 14
 allocatable registers.  SPEC2006 shows significant codesize reduction
 with the default pressure algorithm, so switch back to that.  PR77308 shows
 ~800 fewer instructions.
 
 SPECINT2006 is ~0.6% faster on Cortex-A57 together with the other DImode
 patches. Overall SPEC codesize is 1.1% smaller.
 
 Bootstrap & regress OK on arm-none-linux-gnueabihf --with-cpu=cortex-a57
 
 ChangeLog:
 2019-07-29  Wilco Dijkstra  
 
     * config/arm/arm.c (arm_option_override): Don't override sched
     pressure algorithm.
 
 --
 
 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
 index 
81286cadf32f908e045d704128c5e06842e0cc92..628cf02f23fb29392a63d87f561c3ee2fb73a515
 100644
 --- a/gcc/config/arm/arm.c
 +++ b/gcc/config/arm/arm.c
 @@ -3575,11 +3575,6 @@ arm_option_override (void)
    if (use_neon_for_64bits == 1)
   prefer_neon_for_64bits = true;
  
 -  /* Use the alternative scheduling-pressure algorithm by default.  */
 -  maybe_set_param_value (PARAM_SCHED_PRESSURE_ALGORITHM, SCHED_PRESSURE_MODEL,
 -    global_options.x_param_values,
 -    global_options_set.x_param_values);
 -
    /* Look through ready list and all of queue for instructions
   relevant for L2 auto-prefetcher.  */
    int param_sched_autopref_queue_depth;
 
 

Re: [PATCH] Add --with-static-standard-libraries to the top level

2019-08-19 Thread Tom Tromey
> "Jonathan" == Jonathan Wakely  writes:

Jonathan> Given that the problem does exist, I think being able to disable the
Jonathan> GCC build flags for non-GCC components in the build tree makes sense.
Jonathan> I'm not sure if Jeff deferring to me means I can approve the patch
Jonathan> (normally I can't approve top-level config stuff) but for whatever
Jonathan> it's worth, I approve the patch.

Thanks.  I understood his message as deferring to your judgment, so I am
going to check it in.

Tom


[Bug libstdc++/91067] [9/10 Regression] Clang compiler can't link executable if std::filesystem::directory_iterator is encountered

2019-08-19 Thread ostash at ostash dot kiev.ua
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91067

--- Comment #17 from Viktor Ostashevskyi  ---
Ok, got following today with GCC 9.2 with "-O2 -fno-inline -flto=20":

ld.bfd: /tmp/tests.oKru4z.ltrans32.ltrans.o: in function
`std::__shared_ptr::operator=(std::__shared_ptr&&)':
c++/9.2.0/bits/shared_ptr_base.h:1265: undefined reference to
`std::__shared_ptr::__shared_ptr(std::__shared_ptr&&)'

Code base is huge, so it is hard to minimize test case. Even not sure whether
LTO or libstdc++ is guilty.

[13/13] Add a pass_by_reference flag to function_arg_info

2019-08-19 Thread Richard Sandiford
This patch adds a flag that tells targets whether an argument
has been converted to pass-by-reference form.  This replaces
assign_parm_data_one::passed_pointer in function.c.

The flag is set automatically for places that call
apply_pass_by_reference_rules.  Places that apply
pass-by-reference manually need to set it themselves.

(After previous changes, no targets apply pass-by-reference
manually.  They all go through apply_pass_by_reference_rules.)


2019-08-19  Richard Sandiford  

gcc/
* calls.h (function_arg_info): Add a pass_by_reference field,
defaulting to false.
* calls.c (apply_pass_by_reference_rules): Set pass_by_reference
when applying pass-by-reference semantics.
(initialize_argument_information): Likewise.
(emit_library_call_value_1): Likewise.
* function.c (assign_parm_data_one): Remove passed_pointer field.
(assign_parm_find_data_types): Don't set it.
(assign_parm_find_stack_rtl, assign_parm_adjust_stack_rtl)
(assign_parm_setup_reg, assign_parms, gimplify_parameters): Use
arg.pass_by_reference instead of passed_pointer.

Index: gcc/calls.h
===
--- gcc/calls.h 2019-08-19 15:59:09.801778220 +0100
+++ gcc/calls.h 2019-08-19 15:59:21.817691272 +0100
@@ -34,21 +34,25 @@ #define GCC_CALLS_H
 class function_arg_info
 {
 public:
-  function_arg_info () : type (NULL_TREE), mode (VOIDmode), named (false) {}
+  function_arg_info ()
+: type (NULL_TREE), mode (VOIDmode), named (false),
+  pass_by_reference (false)
+  {}
 
   /* Initialize an argument of mode MODE, either before or after promotion.  */
   function_arg_info (machine_mode mode, bool named)
-: type (NULL_TREE), mode (mode), named (named)
+: type (NULL_TREE), mode (mode), named (named), pass_by_reference (false)
   {}
 
   /* Initialize an unpromoted argument of type TYPE.  */
   function_arg_info (tree type, bool named)
-: type (type), mode (TYPE_MODE (type)), named (named)
+: type (type), mode (TYPE_MODE (type)), named (named),
+  pass_by_reference (false)
   {}
 
   /* Initialize an argument with explicit properties.  */
   function_arg_info (tree type, machine_mode mode, bool named)
-: type (type), mode (mode), named (named)
+: type (type), mode (mode), named (named), pass_by_reference (false)
   {}
 
   /* Return true if the gimple-level type is an aggregate.  */
@@ -100,6 +104,10 @@ #define GCC_CALLS_H
  treated as an unnamed variadic argument (i.e. one passed through
  "...").  See also TARGET_STRICT_ARGUMENT_NAMING.  */
   unsigned int named : 1;
+
+  /* True if we have decided to pass the argument by reference, in which case
+ the function_arg_info describes a pointer to the original argument.  */
+  unsigned int pass_by_reference : 1;
 };
 
 extern int flags_from_decl_or_type (const_tree);
Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-19 15:59:18.145717843 +0100
+++ gcc/calls.c 2019-08-19 15:59:21.817691272 +0100
@@ -946,6 +946,7 @@ apply_pass_by_reference_rules (CUMULATIV
 {
   arg.type = build_pointer_type (arg.type);
   arg.mode = TYPE_MODE (arg.type);
+  arg.pass_by_reference = true;
   return true;
 }
   return false;
@@ -2125,6 +2126,7 @@ initialize_argument_information (int num
  "argument must be passed"
  " by copying");
}
+ arg.pass_by_reference = true;
}
 
   unsignedp = TYPE_UNSIGNED (type);
@@ -4957,6 +4959,7 @@ emit_library_call_value_1 (int retval, r
 call_fusage);
 
  arg.mode = Pmode;
+ arg.pass_by_reference = true;
  val = force_operand (XEXP (slot, 0), NULL_RTX);
}
 
Index: gcc/function.c
===
--- gcc/function.c  2019-08-19 15:59:14.297745685 +0100
+++ gcc/function.c  2019-08-19 15:59:21.821691241 +0100
@@ -2271,7 +2271,6 @@ struct assign_parm_data_one
   machine_mode passed_mode;
   struct locate_and_pad_arg_data locate;
   int partial;
-  BOOL_BITFIELD passed_pointer : 1;
 };
 
 /* A subroutine of assign_parms.  Initialize ALL.  */
@@ -2453,7 +2452,6 @@ assign_parm_find_data_types (struct assi
   if (apply_pass_by_reference_rules (>args_so_far_v, data->arg))
 {
   data->nominal_type = data->arg.type;
-  data->passed_pointer = true;
   data->passed_mode = data->nominal_mode = data->arg.mode;
 }
 
@@ -2653,7 +2651,7 @@ assign_parm_find_stack_rtl (tree parm, s
 stack_parm = gen_rtx_PLUS (Pmode, stack_parm, offset_rtx);
   stack_parm = gen_rtx_MEM (data->arg.mode, stack_parm);
 
-  if (!data->passed_pointer)
+  if (!data->arg.pass_by_reference)
 {
   set_mem_attributes (stack_parm, parm, 1);
   /* set_mem_attributes could set 

[12/13] Make calls.c use function_arg_info internally

2019-08-19 Thread Richard Sandiford
This patch makes the two main calls.c argument-processing
routines track the state of the argument in a function_arg_info
instead of using separate mode variables.


2019-08-19  Richard Sandiford  

gcc/
* calls.c (emit_library_call_value_1): Merge arg and orig_arg
into a single function_arg_info, updating its fields when we
apply pass-by-reference and promotion semantics.  Use the
function_arg_info to track the mode rather than keeping it in
a separate local variable.
(initialize_argument_information): Likewise.  Base the final
arg_to_skip on this new function_arg_info rather than creating
a new one from scratch.

Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-19 15:59:09.801778220 +0100
+++ gcc/calls.c 2019-08-19 15:59:18.145717843 +0100
@@ -1982,7 +1982,6 @@ initialize_argument_information (int num
 {
   tree type = TREE_TYPE (args[i].tree_value);
   int unsignedp;
-  machine_mode mode;
 
   /* Replace erroneous argument with constant zero.  */
   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
@@ -2010,13 +2009,13 @@ initialize_argument_information (int num
 with those made by function.c.  */
 
   /* See if this argument should be passed by invisible reference.  */
-  function_arg_info orig_arg (type, argpos < n_named_args);
-  if (pass_by_reference (args_so_far_pnt, orig_arg))
+  function_arg_info arg (type, argpos < n_named_args);
+  if (pass_by_reference (args_so_far_pnt, arg))
{
  bool callee_copies;
  tree base = NULL_TREE;
 
- callee_copies = reference_callee_copied (args_so_far_pnt, orig_arg);
+ callee_copies = reference_callee_copied (args_so_far_pnt, arg);
 
  /* If we're compiling a thunk, pass through invisible references
 instead of making a copy.  */
@@ -2129,15 +2128,16 @@ initialize_argument_information (int num
}
 
   unsignedp = TYPE_UNSIGNED (type);
-  mode = promote_function_mode (type, TYPE_MODE (type), ,
-   fndecl ? TREE_TYPE (fndecl) : fntype, 0);
+  arg.type = type;
+  arg.mode
+   = promote_function_mode (type, TYPE_MODE (type), ,
+fndecl ? TREE_TYPE (fndecl) : fntype, 0);
 
   args[i].unsignedp = unsignedp;
-  args[i].mode = mode;
+  args[i].mode = arg.mode;
 
   targetm.calls.warn_parameter_passing_abi (args_so_far, type);
 
-  function_arg_info arg (type, mode, argpos < n_named_args);
   args[i].reg = targetm.calls.function_arg (args_so_far, arg);
 
   if (args[i].reg && CONST_INT_P (args[i].reg))
@@ -2177,7 +2177,7 @@ initialize_argument_information (int num
   if (args[i].reg == 0 || args[i].partial != 0
   || reg_parm_stack_space > 0
   || args[i].pass_on_stack)
-   locate_and_pad_parm (mode, type,
+   locate_and_pad_parm (arg.mode, type,
 #ifdef STACK_PARMS_IN_REG_PARM_AREA
 1,
 #else
@@ -2191,7 +2191,7 @@ initialize_argument_information (int num
/* The argument is passed entirely in registers.  See at which
   end it should be padded.  */
args[i].locate.where_pad =
- BLOCK_REG_PADDING (mode, type,
+ BLOCK_REG_PADDING (arg.mode, type,
 int_size_in_bytes (type) <= UNITS_PER_WORD);
 #endif
 
@@ -2208,9 +2208,8 @@ initialize_argument_information (int num
 promoted_mode used for function_arg above.  However, the
 corresponding handling of incoming arguments in function.c
 does pass the promoted mode.  */
-  function_arg_info arg_to_skip (type, TYPE_MODE (type),
-argpos < n_named_args);
-  targetm.calls.function_arg_advance (args_so_far, arg_to_skip);
+  arg.mode = TYPE_MODE (type);
+  targetm.calls.function_arg_advance (args_so_far, arg);
 
   /* Store argument values for functions decorated with attribute
 alloc_size.  */
@@ -4906,24 +4905,25 @@ emit_library_call_value_1 (int retval, r
   for (unsigned int i = 0; count < nargs; i++, count++)
 {
   rtx val = args[i].first;
-  machine_mode mode = args[i].second;
+  function_arg_info arg (args[i].second, /*named=*/true);
   int unsigned_p = 0;
 
   /* We cannot convert the arg value to the mode the library wants here;
 must do it earlier where we know the signedness of the arg.  */
-  gcc_assert (mode != BLKmode
- && (GET_MODE (val) == mode || GET_MODE (val) == VOIDmode));
+  gcc_assert (arg.mode != BLKmode
+ && (GET_MODE (val) == arg.mode
+ || GET_MODE (val) == VOIDmode));
 
   /* Make sure it is a reasonable operand for a move or push insn.  */
   if (!REG_P (val) && !MEM_P (val)
- && !(CONSTANT_P (val) && targetm.legitimate_constant_p 

[11/13] Make function.c use function_arg_info internally

2019-08-19 Thread Richard Sandiford
This patch adds a function_arg_info field to assign_parm_data_one,
so that:

  - passed_type -> arg.type
  - promoted_mode -> arg.mode
  - named_arg -> arg.named

We can then pass this function_arg_info directly to the converted
hooks.

Between the initialisation of the assign_parm_data_one and the
application of promotion rules (which is a state internal to
assign_parm_find_data_types), arg.mode is equivalent to passed_mode
(i.e. to TYPE_MODE).


2019-08-19  Richard Sandiford  

gcc/
* function.c (assign_parm_data_one): Replace passed_type,
promoted_mode and named_arg with a function_arg_info field.
(assign_parm_find_data_types): Remove local variables and
assign directly to "data".  Make data->passed_mode shadow
data->arg.mode until promotion, then assign the promoted
mode to data->arg.mode.
(assign_parms_setup_varargs, assign_parm_find_entry_rtl)
(assign_parm_find_stack_rtl, assign_parm_adjust_entry_rtl)
(assign_parm_remove_parallels, assign_parm_setup_block_p)
(assign_parm_setup_block, assign_parm_setup_reg)
(assign_parm_setup_stack, assign_parms, gimplify_parameters): Use
arg.mode instead of promoted_mode, arg.type instead of passed_type
and arg.named instead of named_arg.  Use data->arg for
function_arg_info structures that had the field values passed_type,
promoted_mode and named_arg.  Base other function_arg_infos on
data->arg, changing the necessary properties.

Index: gcc/function.c
===
--- gcc/function.c  2019-08-19 15:59:09.809778162 +0100
+++ gcc/function.c  2019-08-19 15:59:14.297745685 +0100
@@ -2264,15 +2264,13 @@ struct assign_parm_data_all
 struct assign_parm_data_one
 {
   tree nominal_type;
-  tree passed_type;
+  function_arg_info arg;
   rtx entry_parm;
   rtx stack_parm;
   machine_mode nominal_mode;
   machine_mode passed_mode;
-  machine_mode promoted_mode;
   struct locate_and_pad_arg_data locate;
   int partial;
-  BOOL_BITFIELD named_arg : 1;
   BOOL_BITFIELD passed_pointer : 1;
 };
 
@@ -2407,24 +2405,22 @@ assign_parms_augmented_arg_list (struct
 assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
 struct assign_parm_data_one *data)
 {
-  tree nominal_type, passed_type;
-  machine_mode nominal_mode, passed_mode, promoted_mode;
   int unsignedp;
 
-  memset (data, 0, sizeof (*data));
+  *data = assign_parm_data_one ();
 
   /* NAMED_ARG is a misnomer.  We really mean 'non-variadic'. */
   if (!cfun->stdarg)
-data->named_arg = 1;  /* No variadic parms.  */
+data->arg.named = 1;  /* No variadic parms.  */
   else if (DECL_CHAIN (parm))
-data->named_arg = 1;  /* Not the last non-variadic parm. */
+data->arg.named = 1;  /* Not the last non-variadic parm. */
   else if (targetm.calls.strict_argument_naming (all->args_so_far))
-data->named_arg = 1;  /* Only variadic ones are unnamed.  */
+data->arg.named = 1;  /* Only variadic ones are unnamed.  */
   else
-data->named_arg = 0;  /* Treat as variadic.  */
+data->arg.named = 0;  /* Treat as variadic.  */
 
-  nominal_type = TREE_TYPE (parm);
-  passed_type = DECL_ARG_TYPE (parm);
+  data->nominal_type = TREE_TYPE (parm);
+  data->arg.type = DECL_ARG_TYPE (parm);
 
   /* Look out for errors propagating this far.  Also, if the parameter's
  type is void then its value doesn't matter.  */
@@ -2432,49 +2428,40 @@ assign_parm_find_data_types (struct assi
   /* This can happen after weird syntax errors
 or if an enum type is defined among the parms.  */
   || TREE_CODE (parm) != PARM_DECL
-  || passed_type == NULL
-  || VOID_TYPE_P (nominal_type))
+  || data->arg.type == NULL
+  || VOID_TYPE_P (data->nominal_type))
 {
-  nominal_type = passed_type = void_type_node;
-  nominal_mode = passed_mode = promoted_mode = VOIDmode;
-  goto egress;
+  data->nominal_type = data->arg.type = void_type_node;
+  data->nominal_mode = data->passed_mode = data->arg.mode = VOIDmode;
+  return;
 }
 
   /* Find mode of arg as it is passed, and mode of arg as it should be
  during execution of this function.  */
-  passed_mode = TYPE_MODE (passed_type);
-  nominal_mode = TYPE_MODE (nominal_type);
+  data->passed_mode = data->arg.mode = TYPE_MODE (data->arg.type);
+  data->nominal_mode = TYPE_MODE (data->nominal_type);
 
   /* If the parm is to be passed as a transparent union or record, use the
  type of the first field for the tests below.  We have already verified
  that the modes are the same.  */
-  if ((TREE_CODE (passed_type) == UNION_TYPE
-   || TREE_CODE (passed_type) == RECORD_TYPE)
-  && TYPE_TRANSPARENT_AGGR (passed_type))
-passed_type = TREE_TYPE (first_field (passed_type));
+  if ((TREE_CODE (data->arg.type) == UNION_TYPE
+   || TREE_CODE (data->arg.type) == RECORD_TYPE)
+  

[10/13] Add a apply_pass_by_reference_rules helper

2019-08-19 Thread Richard Sandiford
This patch adds a helper routine that applies pass-by-reference
semantics to an existing function_arg_info.

The c6x part means that c6x_function_arg and c6x_function_arg_advance
see the same "named" value as pass_by_reference did, rather than
pass_by_reference seeing "true" and the others seeing "false".
This doesn't matter because the c6x port doesn't care about namedness.

The rs6000.c patch removes an assignment to "type", but the only
later code to use it was the patched promote_mode line.

(The reason for patching these places despite the above is that
often target code gets used as a basis for new targets or changes
to existing ones.)


2019-08-19  Richard Sandiford  

gcc/
* calls.h (apply_pass_by_reference_rules): Declare.
* calls.c (apply_pass_by_reference_rules): New function.
* config/c6x/c6x.c (c6x_call_saved_register_used): Use it.
* config/rs6000/rs6000-call.c (rs6000_parm_needs_stack): Likewise.
* config/s390/s390.c (s390_call_saved_register_used): Likewise.
* function.c (assign_parm_find_data_types): Likewise.
* var-tracking.c (prepare_call_arguments): Likewise.

Index: gcc/calls.h
===
--- gcc/calls.h 2019-08-19 15:59:04.261818304 +0100
+++ gcc/calls.h 2019-08-19 15:59:09.801778220 +0100
@@ -118,6 +118,8 @@ extern void fixup_tail_calls (void);
 
 extern bool pass_by_reference (CUMULATIVE_ARGS *, function_arg_info);
 extern bool pass_va_arg_by_reference (tree);
+extern bool apply_pass_by_reference_rules (CUMULATIVE_ARGS *,
+  function_arg_info &);
 extern bool reference_callee_copied (CUMULATIVE_ARGS *,
 const function_arg_info &);
 extern void maybe_warn_alloc_args_overflow (tree, tree, tree[2], int[2]);
Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-19 15:59:04.261818304 +0100
+++ gcc/calls.c 2019-08-19 15:59:09.801778220 +0100
@@ -935,6 +935,22 @@ pass_va_arg_by_reference (tree type)
   return pass_by_reference (NULL, function_arg_info (type, /*named=*/false));
 }
 
+/* Decide whether ARG, which occurs in the state described by CA,
+   should be passed by reference.  Return true if so and update
+   ARG accordingly.  */
+
+bool
+apply_pass_by_reference_rules (CUMULATIVE_ARGS *ca, function_arg_info )
+{
+  if (pass_by_reference (ca, arg))
+{
+  arg.type = build_pointer_type (arg.type);
+  arg.mode = TYPE_MODE (arg.type);
+  return true;
+}
+  return false;
+}
+
 /* Return true if ARG, which is passed by reference, should be callee
copied instead of caller copied.  */
 
Index: gcc/config/c6x/c6x.c
===
--- gcc/config/c6x/c6x.c2019-08-19 15:58:58.001863604 +0100
+++ gcc/config/c6x/c6x.c2019-08-19 15:59:09.805778189 +0100
@@ -1088,8 +1088,6 @@ c6x_call_saved_register_used (tree call_
   cumulative_args_t cum;
   HARD_REG_SET call_saved_regset;
   tree parameter;
-  machine_mode mode;
-  tree type;
   rtx parm_rtx;
   int i;
 
@@ -1107,19 +1105,9 @@ c6x_call_saved_register_used (tree call_
   if (TREE_CODE (parameter) == ERROR_MARK)
return true;
 
-  type = TREE_TYPE (parameter);
-  gcc_assert (type);
+  function_arg_info arg (TREE_TYPE (parameter), /*named=*/true);
+  apply_pass_by_reference_rules (_v, arg);
 
-  mode = TYPE_MODE (type);
-  gcc_assert (mode);
-
-  if (pass_by_reference (_v, function_arg_info (type, /*named=*/true)))
-   {
- mode = Pmode;
- type = build_pointer_type (type);
-   }
-
-   function_arg_info arg (type, mode, /*named=*/false);
parm_rtx = c6x_function_arg (cum, arg);
 
c6x_function_arg_advance (cum, arg);
Index: gcc/config/rs6000/rs6000-call.c
===
--- gcc/config/rs6000/rs6000-call.c 2019-08-19 15:59:04.285818131 +0100
+++ gcc/config/rs6000/rs6000-call.c 2019-08-19 15:59:09.805778189 +0100
@@ -2170,7 +2170,6 @@ rs6000_pass_by_reference (cumulative_arg
 static bool
 rs6000_parm_needs_stack (cumulative_args_t args_so_far, tree type)
 {
-  machine_mode mode;
   int unsignedp;
   rtx entry_parm;
 
@@ -2193,16 +2192,14 @@ rs6000_parm_needs_stack (cumulative_args
 type = TREE_TYPE (first_field (type));
 
   /* See if this arg was passed by invisible reference.  */
-  if (pass_by_reference (get_cumulative_args (args_so_far),
-function_arg_info (type, /*named=*/true)))
-type = build_pointer_type (type);
+  function_arg_info arg (type, /*named=*/true);
+  apply_pass_by_reference_rules (get_cumulative_args (args_so_far), arg);
 
   /* Find mode as it is passed by the ABI.  */
   unsignedp = TYPE_UNSIGNED (type);
-  mode = promote_mode (type, TYPE_MODE (type), );
+  arg.mode = promote_mode (arg.type, arg.mode, );
 
   /* If we must pass 

[09/13] Use function_arg_info for TARGET_MUST_PASS_IN_STACK

2019-08-19 Thread Richard Sandiford
Use function_arg_info for TARGET_MUST_PASS_IN_STACK.

The hook is passed the promoted mode instead of the original type mode.

The expr.h reference in the documentation is no longer correct, but
pointing to calls.h or calls.c doesn't help much either.  I just left
this as-is since it's not related to the point of the series.

After previous changes, most places already pass arg.mode and arg.type.
Only i386 and mcore needed to construct a new one out of nothing.
rs6000 needs to construct one slightly earlier than before.


2019-08-19  Richard Sandiford  

gcc/
* target.def (must_pass_in_stack): Take a function_arg_info instead
of a mode and a type.
* doc/tm.texi: Regenerate.
* calls.h (must_pass_in_stack_var_size): Take a function_arg_info
instead of a mode and a type.
(must_pass_in_stack_var_size_or_pad): Likewise.
* calls.c (must_pass_in_stack_var_size): Likewise.
(must_pass_in_stack_var_size_or_pad): Likewise.
(initialize_argument_information): Update call to
targetm.calls.must_pass_in_stack.
(must_pass_va_arg_on_stack): Likewise.
* function.c (assign_parm_find_entry_rtl): Likewise.
* targhooks.c (hook_pass_by_reference_must_pass_in_stack): Likewise.
* config/alpha/alpha.c (alpha_function_arg): Likewise.
(alpha_function_arg_advance): Likewise.
* config/cr16/cr16.c (cr16_function_arg): Likewise.
(cr16_function_arg_advance): Likewise.
* config/cris/cris.c (cris_pass_by_reference): Likewise.
(cris_arg_partial_bytes): Likewise.
* config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise.
* config/lm32/lm32.c (lm32_function_arg): Likewise.
* config/mcore/mcore.c (mcore_num_arg_regs): Likewise.
(mcore_function_arg, mcore_arg_partial_bytes): Likewise.
* config/mips/mips.c (mips_pass_by_reference): Likewise.
* config/mmix/mmix.c (mmix_function_arg_advance): Likewise.
(mmix_function_arg_1, mmix_pass_by_reference): Likewise.
* config/sh/sh.c (sh_pass_by_reference): Likewise.
* config/stormy16/stormy16.c (xstormy16_function_arg): Likewise.
* config/xtensa/xtensa.c (xtensa_function_arg_advance): Likewise.
* config/arm/arm.c (arm_must_pass_in_stack): Take a function_arg_info
instead of a mode and a type.
* config/fr30/fr30.c (fr30_must_pass_in_stack): Likewise.
(fr30_num_arg_regs): Likewise.
(fr30_setup_incoming_varargs): Update calls accordingly.
(fr30_arg_partial_bytes, fr30_function_arg): Likewise.
(fr30_function_arg_advance): Likewise.
* config/frv/frv.c (frv_must_pass_in_stack): Take a function_arg_info
instead of a mode and a type.
* config/gcn/gcn.c (num_arg_regs): Likewise.
(gcn_function_arg, gcn_function_arg_advance): Update calls to
num_arg_regs and targetm.calls.must_pass_in_stack.
(gcn_arg_partial_bytes): Likewise.
* config/i386/i386.c (ix86_must_pass_in_stack): Take a
function_arg_info instead of a mode and a type.
(classify_argument): Update call accordingly.
* config/nds32/nds32.c (nds32_must_pass_in_stack): Take a
function_arg_info instead of a mode and a type.
* config/rs6000/rs6000-internal.h (rs6000_must_pass_in_stack):
Likewise.
* config/rs6000/rs6000-call.c (rs6000_must_pass_in_stack): Likewise.
(rs6000_parm_needs_stack): Update call accordingly.
(setup_incoming_varargs): Likewise.

Index: gcc/target.def
===
--- gcc/target.def  2019-08-19 15:58:58.017863486 +0100
+++ gcc/target.def  2019-08-19 15:59:04.289818104 +0100
@@ -4630,11 +4630,11 @@ false.",
Need audit to verify that this is the case.  */
 DEFHOOK
 (must_pass_in_stack,
- "This target hook should return @code{true} if we should not pass 
@var{type}\n\
+ "This target hook should return @code{true} if we should not pass @var{arg}\n\
 solely in registers.  The file @file{expr.h} defines a\n\
 definition that is usually appropriate, refer to @file{expr.h} for 
additional\n\
 documentation.",
- bool, (machine_mode mode, const_tree type),
+ bool, (const function_arg_info ),
  must_pass_in_stack_var_size_or_pad)
 
 /* Return true if type TYPE, mode MODE, which is passed by reference,
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi 2019-08-19 15:58:58.013863514 +0100
+++ gcc/doc/tm.texi 2019-08-19 15:59:04.289818104 +0100
@@ -4012,8 +4012,8 @@ defined, the argument will be computed i
 a register.
 @end deftypefn
 
-@deftypefn {Target Hook} bool TARGET_MUST_PASS_IN_STACK (machine_mode 
@var{mode}, const_tree @var{type})
-This target hook should return @code{true} if we should not pass @var{type}
+@deftypefn {Target Hook} bool TARGET_MUST_PASS_IN_STACK (const 
function_arg_info @var{})
+This 

[08/13] Use function_arg_info for TARGET_CALLEE_COPIES

2019-08-19 Thread Richard Sandiford
Use function_arg_info for TARGET_CALLEE_COPIES.

The hook is passed the unpromoted type mode instead of the promoted mode.

The aarch64 definition is redundant, but worth keeping for emphasis.


2019-08-19  Richard Sandiford  

gcc/
* target.def (callee_copies): Take a function_arg_info instead
of a mode, type and named flag.
* doc/tm.texi: Regenerate.
* targhooks.h (hook_callee_copies_named): Take a function_arg_info
instead of a mode, type and named flag.
(hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete.
(hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise.
(hook_bool_CUMULATIVE_ARGS_arg_info_true): New function.
* targhooks.c (hook_callee_copies_named): Take a function_arg_info
instead of a mode, type and named flag.
(hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete.
(hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise.
(hook_bool_CUMULATIVE_ARGS_arg_info_true): New function.
* calls.h (reference_callee_copied): Take a function_arg_info
instead of a mode, type and named flag.
* calls.c (reference_callee_copied): Likewise.
(initialize_argument_information): Update call accordingly.
(emit_library_call_value_1): Likewise.
* function.c (gimplify_parameters): Likewise.
* config/aarch64/aarch64.c (TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_false instead of
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false.
* config/c6x/c6x.c (c6x_callee_copies): Delete.
(TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_true instead.
* config/epiphany/epiphany.c (TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.
* config/mips/mips.c (mips_callee_copies): Take a function_arg_info
instead of a mode, type and named flag.
* config/mmix/mmix.c (TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.
* config/mn10300/mn10300.c (TARGET_CALLEE_COPIES): Likewise.
* config/msp430/msp430.c (msp430_callee_copies): Delete.
(TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_true instead.
* config/pa/pa.c (pa_callee_copies): Take a function_arg_info
instead of a mode, type and named flag.
* config/sh/sh.c (sh_callee_copies): Likewise.
* config/v850/v850.c (TARGET_CALLEE_COPIES): Define to
hook_bool_CUMULATIVE_ARGS_arg_info_true instead of
hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true.

Index: gcc/target.def
===
--- gcc/target.def  2019-08-19 15:58:50.345918999 +0100
+++ gcc/target.def  2019-08-19 15:58:58.017863486 +0100
@@ -4653,8 +4653,8 @@ not be generated.\n\
 \n\
 The default version of this hook always returns false.",
  bool,
- (cumulative_args_t cum, machine_mode mode, const_tree type, bool named),
- hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false)
+ (cumulative_args_t cum, const function_arg_info ),
+ hook_bool_CUMULATIVE_ARGS_arg_info_false)
 
 /* Return zero for arguments passed entirely on the stack or entirely
in registers.  If passed in both, return the number of bytes passed
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi 2019-08-19 15:58:50.341919030 +0100
+++ gcc/doc/tm.texi 2019-08-19 15:58:58.013863514 +0100
@@ -4080,7 +4080,7 @@ The pointer is passed in whatever way is
 to that type.
 @end deftypefn
 
-@deftypefn {Target Hook} bool TARGET_CALLEE_COPIES (cumulative_args_t 
@var{cum}, machine_mode @var{mode}, const_tree @var{type}, bool @var{named})
+@deftypefn {Target Hook} bool TARGET_CALLEE_COPIES (cumulative_args_t 
@var{cum}, const function_arg_info @var{})
 The function argument described by the parameters to this hook is
 known to be passed by reference.  The hook should return true if the
 function argument should be copied by the callee instead of copied
Index: gcc/targhooks.h
===
--- gcc/targhooks.h 2019-08-19 15:58:50.345918999 +0100
+++ gcc/targhooks.h 2019-08-19 15:58:58.017863486 +0100
@@ -67,7 +67,7 @@ extern tree default_cxx_get_cookie_size
 extern bool hook_pass_by_reference_must_pass_in_stack
   (cumulative_args_t, const function_arg_info &);
 extern bool hook_callee_copies_named
-  (cumulative_args_t ca, machine_mode, const_tree, bool);
+  (cumulative_args_t ca, const function_arg_info &);
 
 extern void default_print_operand (FILE *, rtx, int);
 extern void default_print_operand_address (FILE *, machine_mode, rtx);
@@ -135,12 +135,10 @@ extern void default_goacc_reduction (gca
 extern bool 

[07/13] Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCE

2019-08-19 Thread Richard Sandiford
Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCE.

There seems to be a bit of confusion around this one.  Almost all
callers pass the same arguments as TARGET_FUNCTION_ARG, meaning
that the mode is the promoted mode rather than the type mode.
But the calls.c handling for normal typed arguments instead passes
the unpromoted TYPE_MODE (despite passing the promoted mode to
TARGET_FUNCTION_ARG).  I've kept this behaviour with a ??? comment.

(The calls.c handling of libgcc functions does pass the promoted
mode though, as does the function.c handling of incoming arguments.)

Also, a couple of the arm callers don't seem to be using the hook
correctly.  Again I kept the current choices and added a ??? comment.


2019-08-19  Richard Sandiford  

gcc/
* target.def (function_arg_advance): Take a function_arg_info instead
of a mode, type and named flag.
* doc/tm.texi: Regenerate.
* targhooks.h (default_function_arg_advance): Take a function_arg_info
instead of a mode, type and named flag.
* targhooks.c (default_function_arg_advance): Likewise.
* calls.c (initialize_argument_information): Update call to
targetm.calls.function_arg_advance.
(emit_library_call_value_1): Likewise.
* dse.c (get_call_args): Likewise.
* expr.c (block_move_libcall_safe_for_call_parm): Likewise.
* function.c (assign_parms, gimplify_parameters): Likewise.
* var-tracking.c (prepare_call_arguments): Likewise.
* config/aarch64/aarch64.c (aarch64_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(aarch64_setup_incoming_varargs): Update call accordingly.
* config/alpha/alpha.c (alpha_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(alpha_setup_incoming_varargs): Update call accordingly.
* config/arc/arc.c (arc_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(arc_setup_incoming_varargs): Update call accordingly.
* config/arm/arm.c (arm_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(cmse_func_args_or_return_in_stack): Update call accordingly.
(arm_function_ok_for_sibcall): Likewise.
(cmse_nonsecure_call_clear_caller_saved): Likewise.
* config/avr/avr.c (avr_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
* config/bfin/bfin.c (bfin_function_arg_advance): Likewise.
* config/c6x/c6x.c (c6x_function_arg_advance): Likewise.
(c6x_call_saved_register_used): Update call accordingly.
* config/cr16/cr16.c (cr16_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
* config/cris/cris.c (cris_function_arg_advance): Likewise.
* config/csky/csky.c (csky_function_arg_advance): Likewise.
(csky_setup_incoming_varargs): Update call accordingly.
* config/epiphany/epiphany.c (epiphany_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
* config/fr30/fr30.c (fr30_function_arg_advance): Likewise.
* config/frv/frv.c (frv_function_arg_advance): Likewise.
* config/ft32/ft32.c (ft32_function_arg_advance): Likewise.
* config/gcn/gcn.c (gcn_function_arg_advance): Likewise.
* config/h8300/h8300.c (h8300_function_arg_advance): Likewise.
* config/i386/i386.c (ix86_function_arg_advance): Likewise.
(ix86_setup_incoming_varargs): Update call accordingly.
* config/ia64/ia64.c (ia64_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(ia64_setup_incoming_varargs): Update call accordingly.
* config/iq2000/iq2000.c (iq2000_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(iq2000_expand_prologue): Update call accordingly.
* config/lm32/lm32.c (lm32_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
* config/m32c/m32c.c (m32c_function_arg_advance): Likewise.
* config/m32r/m32r.c (m32r_function_arg_advance): Likewise.
* config/m68k/m68k.c (m68k_function_arg_advance): Likewise.
* config/mcore/mcore.c (mcore_function_arg_advance): Likewise.
* config/microblaze/microblaze.c (microblaze_function_arg_advance):
Likewise.
(microblaze_expand_prologue): Update call accordingly.
* config/mips/mips.c (mips_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
(mips_setup_incoming_varargs): Update call accordingly.
(mips_output_args_xfer): Likewise.
* config/mmix/mmix.c (mmix_function_arg_advance): Take a
function_arg_info instead of a mode, type and named flag.
  

[06/13] Use function_arg_info for TARGET_FUNCTION_(INCOMING_)ARG

2019-08-19 Thread Richard Sandiford
This patch makes both TARGET_FUNCTION_ARG and
TARGET_FUNCTION_INCOMING_ARG take a function_arg_info.
They have to be done together since many targets use the
same function for both.

The hooks are passed the promoted mode instead of the original type mode.


2019-08-19  Richard Sandiford  

gcc/
* target.def (function_arg, function_incoming_arg): Take a
function_arg_info instead of a mode, tree and named flag.
* doc/tm.texi: Regenerate.
* targhooks.h (default_function_arg): Take a function_arg_info
instead of a mode, tree and named flag.
(default_function_incoming_arg): Likewise.
* targhooks.c (default_function_arg): Likewise.
(default_function_incoming_arg): Likewise.
* calls.h (function_arg_info::end_marker_p): New function.
(function_arg_info::end_marker): Likewise.
* calls.c (prepare_call_address, initialize_argument_information)
(expand_call, emit_library_call_value_1): Update calls to
targetm.calls.function_arg and targetm.calls.function_incoming_arg.
* dse.c: Include calls.h.
(get_call_args): Update call to targetm.calls.function_arg.
* expr.c (block_move_libcall_safe_for_call_parm): Likewise.
* var-tracking.c (prepare_call_arguments): Likewise.
* function.c (assign_parm_find_entry_rtl): Update call to
targetm.calls.function_incoming_arg.
* config/aarch64/aarch64.c (aarch64_function_arg): Take a
function_arg_info instead of a mode, tree and named flag.
* config/alpha/alpha.c (alpha_function_arg): Likewise.
* config/arc/arc.c (arc_function_arg): Likewise.
* config/arm/arm.c (arm_function_arg): Likewise.
(cmse_func_args_or_return_in_stack): Update call accordingly.
(arm_function_ok_for_sibcall): Likewise.
(cmse_nonsecure_call_clear_caller_saved): Likewise.
* config/avr/avr.c (avr_function_arg): Take a function_arg_info
instead of a mode, tree and named flag.
* config/bfin/bfin.c (bfin_function_arg): Likewise.
* config/c6x/c6x.c (c6x_function_arg): Likewise.
(c6x_call_saved_register_used): Update call accordingly.
* config/cr16/cr16.c (cr16_function_arg): Take a function_arg_info
instead of a mode, tree and named flag.
* config/cris/cris.c (cris_function_arg, cris_function_incoming_arg)
(cris_function_arg_1): Likewise.
* config/csky/csky.c (csky_function_arg): Likewise.
* config/epiphany/epiphany.c (epiphany_function_arg): Likewise.
* config/fr30/fr30.c (fr30_function_arg): Likewise.
* config/frv/frv.c (frv_function_arg, frv_function_incoming_arg)
(frv_function_arg_1): Likewise.
* config/ft32/ft32.c (ft32_function_arg): Likewise.
* config/gcn/gcn.c (gcn_function_arg): Likewise.
* config/h8300/h8300.c (h8300_function_arg): Likewise.
* config/i386/i386.c (ix86_function_arg): Likewise.
* config/ia64/ia64.c (ia64_function_arg, ia64_function_incoming_arg)
(ia64_function_arg_1): Likewise.
* config/iq2000/iq2000.c (iq2000_function_arg): Likewise.
(iq2000_expand_prologue, iq2000_pass_by_reference): Update call
accordingly.
* config/lm32/lm32.c (lm32_function_arg): Take a function_arg_info
instead of a mode, tree and named flag.
* config/m32c/m32c.c (m32c_function_arg): Likewise.
* config/m32r/m32r.c (m32r_function_arg): Likewise.
* config/m68k/m68k.c (m68k_function_arg): Likewise.
* config/mcore/mcore.c (mcore_function_arg): Likewise.
* config/microblaze/microblaze.c (microblaze_function_arg): Likewise.
(microblaze_expand_prologue): Update call accordingly.
* config/mips/mips.c (mips_function_arg): Take a function_arg_info
instead of a mode, tree and named flag.
* config/mmix/mmix.c (mmix_function_incoming_arg, mmix_function_arg)
(mmix_function_arg_1): Likewise.
* config/mn10300/mn10300.c (mn10300_function_arg): Likewise.
* config/moxie/moxie.c (moxie_function_arg): Likewise.
* config/msp430/msp430.c (msp430_function_arg): Likewise.
* config/nds32/nds32.c (nds32_function_arg): Likewise.
* config/nios2/nios2.c (nios2_function_arg): Likewise.
* config/nvptx/nvptx.c (nvptx_function_arg): Likewise.
(nvptx_function_incoming_arg): Likewise.
* config/or1k/or1k.c (or1k_function_arg): Likewise.
* config/pa/pa.c (pa_function_arg): Likewise.
* config/pdp11/pdp11.c (pdp11_function_arg): Likewise.
* config/pru/pru.c (pru_function_arg): Likewise.
* config/riscv/riscv.c (riscv_function_arg): Likewise.
* config/rl78/rl78.c (rl78_function_arg): Likewise.
* config/rs6000/rs6000-internal.h (rs6000_function_arg): Likewise.
* config/rs6000/rs6000-call.c (rs6000_function_arg): Likewise.
(rs6000_parm_needs_stack): 

[05/13] Use function_arg_info for TARGET_SETUP_INCOMING_ARGS

2019-08-19 Thread Richard Sandiford
Use function_arg_info for TARGET_SETUP_INCOMING_ARGS.

The hook is passed the promoted mode instead of the original type mode.


2019-08-19  Richard Sandiford  

gcc/
* target.def (setup_incoming_varargs): Take a function_arg_info
instead of a mode and tree.
* doc/tm.texi: Regenerate.
* targhooks.h (default_setup_incoming_varargs): Take a
function_arg_info instead of a mode and tree.
* targhooks.c (default_setup_incoming_varargs): Likewise.
* config/aarch64/aarch64.c (aarch64_setup_incoming_varargs): Likewise.
* config/alpha/alpha.c (alpha_setup_incoming_varargs): Likewise.
* config/arc/arc.c (arc_setup_incoming_varargs): Likewise.
* config/arm/arm.c (arm_setup_incoming_varargs): Likewise.
* config/bfin/bfin.c (setup_incoming_varargs): Likewise.
* config/cris/cris.c (cris_setup_incoming_varargs): Likewise.
* config/csky/csky.c (csky_setup_incoming_varargs): Likewise.
* config/epiphany/epiphany.c (epiphany_setup_incoming_varargs):
Likewise.
* config/fr30/fr30.c (fr30_setup_incoming_varargs): Likewise.
* config/frv/frv.c (frv_setup_incoming_varargs): Likewise.
* config/ft32/ft32.c (ft32_setup_incoming_varargs): Likewise.
* config/i386/i386.c (ix86_setup_incoming_varargs): Likewise.
* config/ia64/ia64.c (ia64_setup_incoming_varargs): Likewise.
* config/iq2000/iq2000.c (iq2000_setup_incoming_varargs): Likewise.
* config/lm32/lm32.c (lm32_setup_incoming_varargs): Likewise.
* config/m32r/m32r.c (m32r_setup_incoming_varargs): Likewise.
* config/mcore/mcore.c (mcore_setup_incoming_varargs): Likewise.
* config/mips/mips.c (mips_setup_incoming_varargs): Likewise.
* config/mmix/mmix.c (mmix_setup_incoming_varargs): Likewise.
* config/moxie/moxie.c (moxie_setup_incoming_varargs): Likewise.
* config/nds32/nds32.c (nds32_setup_incoming_varargs): Likewise.
* config/nios2/nios2.c (nios2_setup_incoming_varargs): Likewise.
* config/riscv/riscv.c (riscv_setup_incoming_varargs): Likewise.
* config/rs6000/rs6000-internal.h (setup_incoming_varargs): Likewise.
* config/rs6000/rs6000-call.c (setup_incoming_varargs): Likewise.
* config/sh/sh.c (sh_setup_incoming_varargs): Likewise.
* config/spu/spu.c (spu_setup_incoming_varargs): Likewise.
* config/tilegx/tilegx.c (tilegx_setup_incoming_varargs): Likewise.
* config/tilepro/tilepro.c (tilepro_setup_incoming_varargs): Likewise.
* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
* function.c (assign_parms_setup_varargs): Update call to
targetm.calls.setup_incoming_varargs.

Index: gcc/target.def
===
--- gcc/target.def  2019-08-19 15:58:28.450077433 +0100
+++ gcc/target.def  2019-08-19 15:58:34.850031127 +0100
@@ -4486,8 +4486,8 @@ pass all their arguments on the stack.\n
 \n\
 The argument @var{args_so_far} points to the @code{CUMULATIVE_ARGS} data\n\
 structure, containing the values that are obtained after processing the\n\
-named arguments.  The arguments @var{mode} and @var{type} describe the\n\
-last named argument---its machine mode and its data type as a tree node.\n\
+named arguments.  The argument @var{arg} describes the last of these named\n\
+arguments.\n\
 \n\
 The target hook should do two things: first, push onto the stack all the\n\
 argument registers @emph{not} used for the named arguments, and second,\n\
@@ -4507,7 +4507,7 @@ arguments of the function are being anal
 happens for an inline function, which is not actually compiled until the\n\
 end of the source file.  The hook @code{TARGET_SETUP_INCOMING_VARARGS} 
should\n\
 not generate any instructions in this case.",
- void, (cumulative_args_t args_so_far, machine_mode mode, tree type,
+ void, (cumulative_args_t args_so_far, const function_arg_info ,
int *pretend_args_size, int second_time),
  default_setup_incoming_varargs)
 
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi 2019-08-19 15:58:28.450077433 +0100
+++ gcc/doc/tm.texi 2019-08-19 15:58:34.850031127 +0100
@@ -5202,7 +5202,7 @@ return value of this function should be
 to use as the return of @code{__builtin_saveregs}.
 @end deftypefn
 
-@deftypefn {Target Hook} void TARGET_SETUP_INCOMING_VARARGS (cumulative_args_t 
@var{args_so_far}, machine_mode @var{mode}, tree @var{type}, int 
*@var{pretend_args_size}, int @var{second_time})
+@deftypefn {Target Hook} void TARGET_SETUP_INCOMING_VARARGS (cumulative_args_t 
@var{args_so_far}, const function_arg_info @var{}, int 
*@var{pretend_args_size}, int @var{second_time})
 This target hook offers an alternative to using
 @code{__builtin_saveregs} and defining the hook
 @code{TARGET_EXPAND_BUILTIN_SAVEREGS}.  Use it to store the anonymous
@@ 

[04/13] Use function_arg_info for TARGET_PASS_BY_REFERENCE

2019-08-19 Thread Richard Sandiford
Use function_arg_info for TARGET_PASS_BY_REFERENCE.

The hook is passed the unpromoted type mode instead of the promoted mode.


2019-08-19  Richard Sandiford  

gcc/
* target.def (pass_by_reference): Take a function_arg_info instead
of a mode, type and named flag.
* doc/tm.texi: Regenerate.
* targhooks.h (hook_pass_by_reference_must_pass_in_stack): Update
accordingly.
(hook_bool_CUMULATIVE_ARGS_arg_info_false): Declare.
* targhooks.c (hook_pass_by_reference_must_pass_in_stack): Take a
function_arg_info instead of a mode, type and named flag.
(hook_bool_CUMULATIVE_ARGS_arg_info_false): New function.
* calls.h (pass_by_reference): Take a function_arg_info instead of a
mode, type and named flag.
* calls.c (pass_by_reference): Likewise.
(pass_va_arg_by_reference): Update call accordingly.
(initialize_argument_information): Likewise.
(emit_library_call_value_1): Likewise.
* function.c (assign_parm_find_data_types): Likewise.
* var-tracking.c (prepare_call_arguments): Likewise.
* stor-layout.c: Include calls.h.
(compute_record_mode): Update call to targetm.calls.pass_by_reference.
* config/aarch64/aarch64.c (aarch64_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/alpha/alpha.c (alpha_pass_by_reference): Likewise.
* config/arc/arc.c (arc_pass_by_reference): Likewise.
* config/arm/arm.c (arm_pass_by_reference): Likewise.
* config/bfin/bfin.c (bfin_pass_by_reference): Likewise.
* config/c6x/c6x.c (c6x_pass_by_reference): Likewise.
(c6x_call_saved_register_used): Update call to pass_by_reference.
* config/cris/cris.c (cris_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/epiphany/epiphany.c (epiphany_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
(epiphany_arg_partial_bytes): Update call accordingly.
* config/ft32/ft32.c (ft32_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
(ft32_arg_partial_bytes): Update call accordingly.
* config/i386/i386.c (ix86_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise.
* config/m32c/m32c.c (m32c_pass_by_reference): Likewise.
* config/m32r/m32r.c (m32r_pass_by_reference): Likewise.
(m32r_return_in_memory): Update call accordingly.
* config/mips/mips.c (mips_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/mmix/mmix.c (mmix_pass_by_reference): Likewise.
* config/mn10300/mn10300.c (mn10300_pass_by_reference): Likewise.
* config/moxie/moxie.c (moxie_pass_by_reference): Likewise.
(moxie_arg_partial_bytes): Update call accordingly.
* config/msp430/msp430.c (msp430_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/nvptx/nvptx.c (nvptx_pass_by_reference): Likewise.
* config/or1k/or1k.c (or1k_pass_by_reference): Likewise.
* config/pa/pa.c (pa_pass_by_reference): Likewise.
* config/riscv/riscv.c (riscv_pass_by_reference): Likewise.
(riscv_return_in_memory): Update call accordingly.
* config/rs6000/rs6000-internal.h (rs6000_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
* config/rs6000/rs6000-call.c (rs6000_pass_by_reference): Likewise.
(rs6000_parm_needs_stack): Update call to pass_by_reference.
* config/s390/s390.c (s390_pass_by_reference): Take a
function_arg_info instead of a mode, type and named flag.
(s390_call_saved_register_used): Update call accordingly.
* config/sh/sh.c (sh_pass_by_reference): Take a function_arg_info
instead of a mode, type and named flag.
* config/sparc/sparc.c (sparc_pass_by_reference): Likewise.
* config/spu/spu.c (spu_pass_by_reference): Likewise.
* config/tilegx/tilegx.c (tilegx_pass_by_reference): Likewise.
* config/tilepro/tilepro.c (tilepro_pass_by_reference): Likewise.
* config/v850/v850.c (v850_pass_by_reference): Likewise.
* config/visium/visium.c (visium_pass_by_reference): Likewise.

gcc/ada/
* gcc-interface/misc.c (default_pass_by_ref): Update call to
pass_by_reference.

Index: gcc/target.def
===
--- gcc/target.def  2019-08-19 15:58:21.746125942 +0100
+++ gcc/target.def  2019-08-19 15:58:28.450077433 +0100
@@ -4450,18 +4450,18 @@ or 3-byte structure is returned at the m
from __builtin_va_arg.  */
 DEFHOOK
 (pass_by_reference,
- "This 

[03/13] Use function_arg_info for TARGET_ARG_PARTIAL_BYTES

2019-08-19 Thread Richard Sandiford
This patch adds the function_arg_info class and uses it for
TARGET_ARG_PARTIAL_BYTES.

The hook is passed the promoted mode instead of the original type mode.

The arguments aren't mentioned in the documentation, which is why the
target.def change is so small.

The patch changes "true" to "arg.named" in:

  gcc_assert (!epiphany_pass_by_reference (cum, mode, type, /* named */ true));

but epiphany_pass_by_reference doesn't care about the named flag.


2019-08-19  Richard Sandiford  

gcc/
* target.def (arg_partial_bytes): Take a function_arg_info instead
of a mode, type and named flag.
* doc/tm.texi: Regenerate.
* target.h (function_arg_info): Declare.
* calls.h (function_arg_info): New class.
* targhooks.h (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete.
(hook_int_CUMULATIVE_ARGS_arg_info_0): Declare.
* targhooks.c (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete.
(hook_int_CUMULATIVE_ARGS_arg_info_0): New function.
* calls.c (initialize_argument_information): Update call to
targetm.calls.partial_bytes.
(emit_library_call_value_1): Likewise.
* expr.c (block_move_libcall_safe_for_call_parm): Likewise.
* function.c (assign_parm_find_entry_rtl): Likewise.
* config/alpha/alpha.c (alpha_arg_partial_bytes): Take a
function_arg_info instead of a mode, type and named flag.
* config/arc/arc.c (arc_arg_partial_bytes): Likewise.
* config/arm/arm.c (arm_arg_partial_bytes): Likewise.
(cmse_func_args_or_return_in_stack): Update accordingly.
* config/bfin/bfin.c (bfin_arg_partial_bytes): Take a
function_arg_info instead of a mode, type and named flag.
* config/cris/cris.c (cris_arg_partial_bytes): Likewise.
* config/csky/csky.c (csky_arg_partial_bytes): Likewise.
* config/epiphany/epiphany.c (epiphany_arg_partial_bytes): Likewise.
* config/fr30/fr30.c: Include calls.h.
(fr30_arg_partial_bytes): Take a function_arg_info instead of a mode,
type and named flag.
* config/frv/frv.c: Include calls.h.
(frv_arg_partial_bytes): Take a function_arg_info instead of a mode,
type and named flag.
* config/ft32/ft32.c (ft32_arg_partial_bytes): Likewise.
* config/gcn/gcn.c (gcn_arg_partial_bytes): Likewise.
* config/ia64/ia64.c (ia64_arg_partial_bytes): Likewise.
* config/iq2000/iq2000.c (iq2000_arg_partial_bytes): Likewise.
* config/m32r/m32r.c (m32r_arg_partial_bytes): Likewise.
* config/mcore/mcore.c (mcore_arg_partial_bytes): Likewise.
* config/microblaze/microblaze.c (function_arg_partial_bytes):
Likewise.
* config/mips/mips.c (mips_arg_partial_bytes): Likewise.
* config/mn10300/mn10300.c (mn10300_arg_partial_bytes): Likewise.
* config/moxie/moxie.c (moxie_arg_partial_bytes): Likewise.
* config/msp430/msp430.c (msp430_arg_partial_bytes): Likewise.
* config/nds32/nds32.c (nds32_arg_partial_bytes): Likewise.
* config/nios2/nios2.c (nios2_arg_partial_bytes): Likewise.
* config/pa/pa.c (pa_arg_partial_bytes): Likewise.
* config/pru/pru.c (pru_arg_partial_bytes): Likewise.
* config/riscv/riscv.c (riscv_arg_partial_bytes): Likewise.
* config/rs6000/rs6000-internal.h (rs6000_arg_partial_bytes): Likewise.
* config/rs6000/rs6000-call.c (rs6000_arg_partial_bytes): Likewise.
(rs6000_parm_needs_stack): Update call accordingly.
* config/sh/sh.c (sh_arg_partial_bytes): Take a
function_arg_info instead of a mode, type and named flag.
* config/sparc/sparc.c (sparc_arg_partial_bytes): Likewise.
* config/v850/v850.c (v850_arg_partial_bytes): Likewise.

Index: gcc/target.def
===
--- gcc/target.def  2019-08-15 15:26:09.232205170 +0100
+++ gcc/target.def  2019-08-19 15:58:21.746125942 +0100
@@ -4677,8 +4677,8 @@ compiler when this occurs, and how many
 @code{TARGET_FUNCTION_ARG} for these arguments should return the first\n\
 register to be used by the caller for this argument; likewise\n\
 @code{TARGET_FUNCTION_INCOMING_ARG}, for the called function.",
- int, (cumulative_args_t cum, machine_mode mode, tree type, bool named),
- hook_int_CUMULATIVE_ARGS_mode_tree_bool_0)
+ int, (cumulative_args_t cum, const function_arg_info ),
+ hook_int_CUMULATIVE_ARGS_arg_info_0)
 
 /* Update the state in CA to advance past an argument in the
argument list.  The values MODE, TYPE, and NAMED describe that
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi 2019-08-15 15:26:09.228205200 +0100
+++ gcc/doc/tm.texi 2019-08-19 15:58:21.746125942 +0100
@@ -4057,7 +4057,7 @@ Perform a target dependent initializatio
 This hook is called at the start of register allocation.
 @end deftypefn
 
-@deftypefn 

[02/13] Add must_pass_va_arg_in_stack

2019-08-19 Thread Richard Sandiford
This patch splits out another idiom from the va_arg gimplification
routines, so that there's only one place to update later.


2019-08-19  Richard Sandiford  

gcc/
* calls.h (must_pass_va_arg_in_stack): Declare.
* calls.c (must_pass_va_arg_in_stack): New function.
* config/alpha/alpha.c (alpha_gimplify_va_arg_1): Use it.
* config/sh/sh.c (sh_gimplify_va_arg_expr): Likewise.
* config/stormy16/stormy16.c (xstormy16_gimplify_va_arg_expr):
Likewise.
* config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.

Index: gcc/calls.h
===
--- gcc/calls.h 2019-08-19 15:58:10.742205564 +0100
+++ gcc/calls.h 2019-08-19 15:58:16.094166837 +0100
@@ -28,6 +28,7 @@ extern bool gimple_alloca_call_p (const
 extern bool alloca_call_p (const_tree);
 extern bool must_pass_in_stack_var_size (machine_mode, const_tree);
 extern bool must_pass_in_stack_var_size_or_pad (machine_mode, const_tree);
+extern bool must_pass_va_arg_in_stack (tree);
 extern rtx prepare_call_address (tree, rtx, rtx, rtx *, int, int);
 extern bool shift_return_value (machine_mode, bool, rtx);
 extern rtx expand_call (tree, rtx, int);
Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-19 15:58:10.742205564 +0100
+++ gcc/calls.c 2019-08-19 15:58:16.094166837 +0100
@@ -5900,5 +5900,14 @@ must_pass_in_stack_var_size_or_pad (mach
   return false;
 }
 
+/* Return true if TYPE must be passed on the stack when passed to
+   the "..." arguments of a function.  */
+
+bool
+must_pass_va_arg_in_stack (tree type)
+{
+  return targetm.calls.must_pass_in_stack (TYPE_MODE (type), type);
+}
+
 /* Tell the garbage collector about GTY markers in this source file.  */
 #include "gt-calls.h"
Index: gcc/config/alpha/alpha.c
===
--- gcc/config/alpha/alpha.c2019-08-19 15:58:10.750205506 +0100
+++ gcc/config/alpha/alpha.c2019-08-19 15:58:16.094166837 +0100
@@ -6243,7 +6243,7 @@ alpha_gimplify_va_arg_1 (tree type, tree
 
   /* If the type could not be passed in registers, skip the block
  reserved for the registers.  */
-  if (targetm.calls.must_pass_in_stack (TYPE_MODE (type), type))
+  if (must_pass_va_arg_in_stack (type))
 {
   t = build_int_cst (TREE_TYPE (offset), 6*8);
   gimplify_assign (offset,
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c  2019-08-13 22:35:11.793251783 +0100
+++ gcc/config/sh/sh.c  2019-08-19 15:58:16.098166809 +0100
@@ -7656,9 +7656,8 @@ sh_gimplify_va_arg_expr (tree valist, tr
   tree addr, lab_over = NULL, result = NULL;
   tree eff_type;
 
-  const bool pass_by_ref =
-!VOID_TYPE_P (type)
-&& targetm.calls.must_pass_in_stack (TYPE_MODE (type), type);
+  const bool pass_by_ref
+= !VOID_TYPE_P (type) && must_pass_va_arg_in_stack (type);
 
   if (pass_by_ref)
 type = build_pointer_type (type);
Index: gcc/config/stormy16/stormy16.c
===
--- gcc/config/stormy16/stormy16.c  2019-08-13 22:35:11.805251695 +0100
+++ gcc/config/stormy16/stormy16.c  2019-08-19 15:58:16.098166809 +0100
@@ -1342,7 +1342,7 @@ xstormy16_gimplify_va_arg_expr (tree val
   count = build3 (COMPONENT_REF, TREE_TYPE (f_count), valist, f_count,
  NULL_TREE);
 
-  must_stack = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type);
+  must_stack = must_pass_va_arg_in_stack (type);
   size_tree = round_up (size_in_bytes (type), UNITS_PER_WORD);
   gimplify_expr (_tree, pre_p, NULL, is_gimple_val, fb_rvalue);
 
Index: gcc/config/xtensa/xtensa.c
===
--- gcc/config/xtensa/xtensa.c  2019-08-19 15:58:10.766205389 +0100
+++ gcc/config/xtensa/xtensa.c  2019-08-19 15:58:16.098166809 +0100
@@ -3328,7 +3328,7 @@ xtensa_gimplify_va_arg_expr (tree valist
   array = create_tmp_var (ptr_type_node);
 
   lab_over = NULL;
-  if (!targetm.calls.must_pass_in_stack (TYPE_MODE (type), type))
+  if (!must_pass_va_arg_in_stack (type))
 {
   lab_false = create_artificial_label (UNKNOWN_LOCATION);
   lab_over = create_artificial_label (UNKNOWN_LOCATION);


[01/13] Add pass_va_arg_by_reference

2019-08-19 Thread Richard Sandiford
This patch splits out a common idiom from the va_arg gimplification
routines, so that there's only one place to update later.


2019-08-19  Richard Sandiford  

gcc/
* calls.h (pass_va_arg_by_reference): Declare.
* calls.c (pass_va_arg_by_reference): New function.
* config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it.
* config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise.
* config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise.
(mips_gimplify_va_arg_expr): Likewise.
* config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise.
* config/s390/s390.c (s390_gimplify_va_arg): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
* config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise.
* config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise.
* config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise.
* config/visium/visium.c (visium_gimplify_va_arg): Likewise.
* config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
* targhooks.c (std_gimplify_va_arg_expr): Likewise.

Index: gcc/calls.h
===
--- gcc/calls.h 2019-03-08 18:15:33.696751769 +
+++ gcc/calls.h 2019-08-19 15:58:10.742205564 +0100
@@ -35,6 +35,7 @@ extern void fixup_tail_calls (void);
 
 extern bool pass_by_reference (CUMULATIVE_ARGS *, machine_mode,
   tree, bool);
+extern bool pass_va_arg_by_reference (tree);
 extern bool reference_callee_copied (CUMULATIVE_ARGS *, machine_mode,
 tree, bool);
 extern void maybe_warn_alloc_args_overflow (tree, tree, tree[2], int[2]);
Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-13 22:35:04.921302360 +0100
+++ gcc/calls.c 2019-08-19 15:58:10.742205564 +0100
@@ -927,6 +927,15 @@ pass_by_reference (CUMULATIVE_ARGS *ca,
  type, named_arg);
 }
 
+/* Return true if TYPE should be passed by reference when passed to
+   the "..." arguments of a function.  */
+
+bool
+pass_va_arg_by_reference (tree type)
+{
+  return pass_by_reference (NULL, TYPE_MODE (type), type, false);
+}
+
 /* Return true if TYPE, which is passed by reference, should be callee
copied instead of caller copied.  */
 
Index: gcc/config/aarch64/aarch64.c
===
--- gcc/config/aarch64/aarch64.c2019-08-15 10:00:02.366735649 +0100
+++ gcc/config/aarch64/aarch64.c2019-08-19 15:58:10.746205533 +0100
@@ -14271,7 +14271,7 @@ aarch64_gimplify_va_arg_expr (tree valis
   HOST_WIDE_INT size, rsize, adjust, align;
   tree t, u, cond1, cond2;
 
-  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect_p = pass_va_arg_by_reference (type);
   if (indirect_p)
 type = build_pointer_type (type);
 
Index: gcc/config/alpha/alpha.c
===
--- gcc/config/alpha/alpha.c2019-08-13 22:35:11.721252311 +0100
+++ gcc/config/alpha/alpha.c2019-08-19 15:58:10.750205506 +0100
@@ -6330,7 +6330,7 @@ alpha_gimplify_va_arg (tree valist, tree
   t = fold_convert (build_nonstandard_integer_type (64, 0), offset_field);
   offset = get_initialized_tmp_var (t, pre_p, NULL);
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
 
   if (indirect)
 {
Index: gcc/config/gcn/gcn.c
===
--- gcc/config/gcn/gcn.c2019-08-13 22:35:11.733252223 +0100
+++ gcc/config/gcn/gcn.c2019-08-19 15:58:10.750205506 +0100
@@ -2493,7 +2493,7 @@ gcn_gimplify_va_arg_expr (tree valist, t
   tree t, u;
   bool indirect;
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
 {
   type = ptr;
Index: gcc/config/i386/i386.c
===
--- gcc/config/i386/i386.c  2019-08-19 15:57:56.338309784 +0100
+++ gcc/config/i386/i386.c  2019-08-19 15:58:10.754205475 +0100
@@ -4307,7 +4307,7 @@ ix86_gimplify_va_arg (tree valist, tree
   ovf = build3 (COMPONENT_REF, TREE_TYPE (f_ovf), valist, f_ovf, NULL_TREE);
   sav = build3 (COMPONENT_REF, TREE_TYPE (f_sav), valist, f_sav, NULL_TREE);
 
-  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect_p = pass_va_arg_by_reference (type);
   if (indirect_p)
 

[00/13] Pass an argument descriptor to target hooks

2019-08-19 Thread Richard Sandiford
For the SVE calling conventions, function_arg and function_arg_advance
need to know whether an argument is being passed by reference or not.
The simplest way of providing that information would have been to add a
new parameter, or convert the "named" parameter into a bitmask.  But it
seemed cleaner to wrap the argument information in a struct/class instead.

The bulk of this series therefore adds a function_arg_info that
initially records the type, mode and named flag.  The final patch then
adds the pass-by-reference information as well, which becomes a small
change on its own.

The new struct/class inherits a couple of non-obvious points of the
current interface:

(a) For some hooks the mode is the mode of the type.  For others it's
the mode after promotion.  On targets that use argument promotion,
this affects the choice between the mode and the type when both
pieces of information are specified.

(a) Traditionally the type is null when calling libgcc support functions.
But I think the argument conceptually still has a type (most of the
functions are written in C after all).  It's just that the type is
inferred from the unpromoted mode rather than being specified directly.
So when we have access to the unpromoted mode, we can still query some
properties of the type even if we don't have access to the type itself.

(I remember it was said years ago that we should clean this up and
call libgcc functions like any other function.  But TBH I can't see
that ever happening.)

Of course, the ABI support is one of the most sensitive areas of the
compiler and it would be very easy to introduce a silent ABI break.
I've therefore tried to be conservative and stick to the following
changes:

(1) Replace uses of the old parameters with the corresponding fields
of the function_arg_info (which hold the same values as before).

(2) In cases where the mode is the unpromoted mode, replace the calculation:

  type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode)

with a new type_size_in_bytes (), which computes the same thing
in the same way.

[The name is based on (b) above -- every argument has a type,
even if we aren't given it explicitly.]

(3) In cases where the mode is the promoted mode, replace the calculation:

  mode == BLKmode ? int_size_in_bytes (type) : GET_MODE_SIZE (mode)

with a new promoted_size_in_bytes (), which computes the same thing
in the same way.

Not all the affected targets use argument promotion, but that's
what the calculation is logically providing in the affected contexts.

[The only case I found in which the calculation was used for an
unpromoted mode was aarch64_pass_by_reference.  Other targets use
the expression in (2) here, and the later:

  /* Aggregates are passed by reference based on their size.  */
  if (type && AGGREGATE_TYPE_P (type))
{
  size = int_size_in_bytes (type);
}

suggests that that might have been the intention for aarch64 too.
The series just leaves the aarch64 calculation as-is.]

(4) In cases where the mode is the promoted mode, replace the calculation:

  mode == BLKmode && type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode)

with promoted_size_in_bytes (), as for (3).  This means that the
compiler will now ICE (via a segfault) on the invalid combination:

  mode == BLKmode && !type

which I think is preferable to letting the error slip past.

(5) Replace the common test:

  type && AGGREGRATE_TYPE_P (type)

with a new aggregate_type_p (), which computes the same thing
in the same way.  This is again based on point (b) above.

(6) In function_arg only, replace:

  mode == VOIDmode

and

  type == void_type_node

(or both) with end_marker_p ().

Bootstrapped & regression-tested on aarch64-linux-gnu and x86_64-linux-gnu
(all languages for the latter).  I also tested each individual patch in
the series by compiling at least one target per CPU directory, checking
for no new warnings, and checking that there were no changes in assembly
output for gcc.c-torture, gcc.dg and g++.dg at -O0.

diffstat for series:

 66 files changed, 1676 insertions(+), 2246 deletions(-)

although admittedly a lot of that comes from culling out-of-date comments.

Richard


Re: [PATCH] Intrinsic documentation for DIM, MOD and MODULO.

2019-08-19 Thread Jeff Law
On 8/19/19 3:11 AM, Mark Eggleston wrote:
> The intrinsics DIM, MOD and MODULO can accept arguments of different
> kinds and return values with the larger of the two kinds. Notes to this
> effect have been added as they were missing from the documentation.
> 
> Please find attached the patch.
> 
> ChangeLog:
> 
> gcc/fortran/ChangeLog
> 
>     Mark Eggleston  
> 
>     PR fortran/89236
>     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
> 
Do we want to be more specific about what types are accepted as a GNU
extension for these operators?

jeff


Re: Special Memory Constraint [was Re: Indirect memory addresses vs. lra]

2019-08-19 Thread Segher Boessenkool
On Mon, Aug 19, 2019 at 09:14:22AM -0400, Vladimir Makarov wrote:
> On 2019-08-19 3:35 a.m., John Darrington wrote:
> >On Fri, Aug 16, 2019 at 10:50:13AM -0400, Vladimir Makarov wrote:
> >  No I meant something like that
> >  
> >  (define_special_memory_constraint "a" ...)
> >  (define_predicate "my_special_predicate" ...
> > 
> >   {
> > if (lra_in_progress_p)
> >   return REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER && 
> >   reg_renumber[REGNO(op)] < 0;
> > return true if memory with sp addressing;
> >  })
> >  
> >  I think LRA spills pseudo-register and it will be memory addressed 
> >  by sp
> >  at the end of LRA.
> >
> >What I've done is this:
> >
> >(define_predicate "my_special_predicate"
> > (match_operand 0 "memory_operand")
> >  {
> >debug_rtx (op);
> >gcc_assert (MEM_P (op));
> >op = XEXP (op, 0);
> >if (GET_CODE (op) == PLUS)
> >  op = XEXP (op, 0);
> >
> >if (lra_in_progress)
> >  {
> >fprintf (stderr, "%s:%d\n", __FILE__, __LINE__);
> >return REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER && 
> >reg_renumber[REGNO(op)] < 0;
> >  }
> >
> >
> >if (REG_P (op))
> >  {
> >int regno = REGNO (op);
> >return (regno == 10); // register is the stack pointer
> >  }
> >
> >return true;
> >  })
> >
> >  (and many variations)  Unfortunately, any moderately complicated input
> >  still results in a (mem (reg) ) insn repeatedly entering the
> >  lra_in_progress case and returning false, and eventually terminating with
> >  
> >  "internal compiler error: maximum number of generated reload insns per 
> >  insn achieved (90)"
> >
> >
> >Any other ideas?
>   As I remember there were a few other ideas from Richard Biener and 
> Segher Boessenkool.  I also proposed to add a new address register which 
> will be always a fixed stack memory slot at the end. Unfortunately I am 
> not familiar with the target and the port to say in details how to do 
> it.  But I think it is worth to try.

The m68hc11 port used the fake Z register approach, and I believe it had
some special machine pass to get rid of it right before assembler output.

(r171302 is when it was removed -- last version was
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/m68hc11/m68hc11.c;h=1e414102c3f1fed985e4fb8db7954342e965190b;hb=bae8bb65d842d7ffefe990c1f0ac004491f3c105#l4061
for the machine reorg stuff).

No idea how well it works...  But it's only needed if you are forced to
have a frame pointer IIUC?


Segher


  1   2   >