Re: [PATCH 0/2] add unique_ptr class

2017-08-13 Thread Ville Voutilainen
>Good point. "gnutools" might be more accurate, but people might object
>to adding 10 extra characters for "gnutools::".

>Naming is important, especially for a whole namespace (not just a
>single type) so I do think it's worth spending time getting it right.

>But I could live with gtl as long as nobody ever says "GTL is the GNU
>STL" or mentions "gtl" and STL in the same breath :-)

I wonder why such things wouldn't live in a namespace called 'gcc'.


[Updated, PATCH] i386: Avoid stack realignment if possible

2017-08-13 Thread H.J. Lu
On Mon, Aug 07, 2017 at 08:58:49AM -0700, H.J. Lu wrote:
> On Tue, Jul 25, 2017 at 7:54 AM, Uros Bizjak  wrote:
> > On Tue, Jul 25, 2017 at 3:52 PM, H.J. Lu  wrote:
> >> On Fri, Jul 14, 2017 at 4:46 AM, H.J. Lu  wrote:
> >>> On Fri, Jul 7, 2017 at 5:56 PM, H.J. Lu  wrote:
>  On Fri, Jul 07, 2017 at 09:58:42AM -0700, H.J. Lu wrote:
> > On Fri, Dec 20, 2013 at 8:06 AM, Jakub Jelinek  wrote:
> > > Hi!
> > >
> > > Honza recently changed the i?86 backend, so that it often doesn't
> > > do -maccumulate-outgoing-args by default on x86_64.
> > > Unfortunately, on some of the here included testcases this regressed
> > > quite a bit the generated code.  As AVX vectors are used, the dynamic
> > > realignment code needs to assume e.g. that some of them will need to 
> > > be
> > > spilled, and for -mno-accumulate-outgoing-args the code needs to set
> > > need_drap early as well.  But in when emitting the prologue/epilogue,
> > > if need_drap is set, we don't perform the optimization for leaf 
> > > functions
> > > which have zero size stack frame, thus we end up with uselessly doing
> > > dynamic stack realignment, setting up DRAP that nothing uses and 
> > > later on
> > > restore everything back.
> > >
> > > This patch improves it, if the DRAP register isn't live at the start 
> > > of
> > > entry bb successor and we aren't going to realign the stack, we don't
> > > need DRAP at all, and even if we need DRAP register, that can't be 
> > > the sole
> > > reason for doing stack realignment, the prologue code is able to set 
> > > up DRAP
> > > even without dynamic stack realignment.
> > >
> > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > >
> > > 2013-12-20  Jakub Jelinek  
> > >
> > > PR target/59501
> > > * config/i386/i386.c (ix86_save_reg): Don't return true for 
> > > drap_reg
> > > if !crtl->stack_realign_needed.
> > > (ix86_finalize_stack_realign_flags): If drap_reg isn't live 
> > > on entry
> > > and stack_realign_needed will be false, clear drap_reg and 
> > > need_drap.
> > > Optimize leaf functions that don't need stack frame even if
> > > crtl->need_drap.
> > >
> > > * gcc.target/i386/pr59501-1.c: New test.
> > > * gcc.target/i386/pr59501-1a.c: New test.
> > > * gcc.target/i386/pr59501-2.c: New test.
> > > * gcc.target/i386/pr59501-2a.c: New test.
> > > * gcc.target/i386/pr59501-3.c: New test.
> > > * gcc.target/i386/pr59501-3a.c: New test.
> > > * gcc.target/i386/pr59501-4.c: New test.
> > > * gcc.target/i386/pr59501-4a.c: New test.
> > > * gcc.target/i386/pr59501-5.c: New test.
> > > * gcc.target/i386/pr59501-6.c: New test.
> >
> > LGTM, assuming Jakub is OK with the patch.
> >
> > Thanks,
> > Uros.
> 
> Jakub, can you take a look at this:
> 
> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00400.html
> 

Here is the updated patch to fix

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81769

OK for trunk?

Thanks.

H.J.
---
ix86_finalize_stack_frame_flags has been extended to eliminate frame
pointer when the new stack frame isn't needed with and without
-maccumulate-outgoing-args as well as -fomit-frame-pointer.  Since stack
access with larger alignment may be optimized out, to decide if stack
realignment is needed, we need to not only check for stack frame access,
but also verify the alignment of stack frame access.  Since alignment of
memory access via arg_pointer is set up by caller, not by callee, we
should find the maximum stack alignment from the stack frame access
instructions via stack pointer and frame pointrer to avoid stack
realignment when stack alignment needed is less than incoming stack
boundary.

gcc/

PR target/59501
PR target/81624
PR target/81769
* config/i386/i386.c (ix86_finalize_stack_frame_flags): Don't
realign stack if stack alignment needed is less than incoming
stack boundary.

gcc/testsuite/

PR target/59501
PR target/81624
PR target/81769
* gcc.target/i386/pr59501-4a.c: Remove xfail.
* gcc.target/i386/pr81769-1a.c: New test.
* gcc.target/i386/pr81769-1b.c: Likewise.
* gcc.target/i386/pr81769-2.c: Likewise.
---
 gcc/config/i386/i386.c | 143 ++---
 gcc/testsuite/gcc.target/i386/pr59501-4a.c |   2 +-
 gcc/testsuite/gcc.target/i386/pr81769-1a.c |  21 +
 gcc/testsuite/gcc.target/i386/pr81769-1b.c |   7 ++
 gcc/testsuite/gcc.target/i386/pr81769-2.c  |  21 +
 5 files changed, 138 insertions(+), 56 deletions(-)
 create mode 100644 

Re: [PATCH, rs6000] More diagnostic cleanup, addressing PR79845

2017-08-13 Thread Martin Sebor

--- gcc/config/rs6000/rs6000-c.c(revision 250965)
+++ gcc/config/rs6000/rs6000-c.c(working copy)
@@ -5812,7 +5812,7 @@ altivec_resolve_overloaded_builtin (location_t loc
 types.  */
   if (nargs != 2)
{
- error ("vec_mul only accepts 2 arguments");
+ error ("builtin %qs only accepts 2 arguments", "vec_mul");


I don' meant to nit-pick too much but it has been drilled into me
that the term is built-in, not builtin.  There are a number of
deviations from this preferred spelling in GCC messages already
(mainly though not exclusively in the rs600 back-end) but I think
it would be nice to converge on the preferred spelling.

https://gcc.gnu.org/codingconventions.html#Spelling

Martin



Re: [PATCH] Add libgcc support for cache clearing on ARM VxWorks

2017-08-13 Thread Olivier Hainque
Hi Richard,

> I'm not going to object to this patch - it's ok at a GCC level; but I'm
> not sure that architecturally this is going to work.  The implementation
> of cache clearing is very specific to the implementation and I don't
> think it is possible to write a portable single implementation.
> 
> I must admit, that not being a kernel expert, I'm not completely
> familiar with all the details of cache maintenance, but I don't think a
> single sequence like this will work in general.
> 
> Your code seems to focus only on the Data cache clearing.  Documentation
> in extend.texi seems to suggest that __builtin___clear_cache is supposed
> to clear the _instruction_ cache (which may of course involve also
> synchronizing the Dcache to memory first).  Similar comments in md.texi
> refer to the clear_cache instruction pattern flushing the Icache.  Note
> that arm processors of any architecture revision do not automatically
> synchronize I and D caches.
> 
> Before ARMv7 cache maintenance operations were not available in user
> mode (I don't know if vxworks is expected to run only in a privileged mode).
> 
> On a system without caches the instructions will just abort
> 
> I believe that on v7 you also need ISB and DMB operations at the end of
> the sequence.  But such instructions aren't available on older
> architectures.
> 
> I will not object to this being committed (it's your port); but I'd
> strongly recommend that you don't at this stage.

Thanks a lot for your comments, always very appreciated.

I'll discuss the details with the persons who wrote the
function body. It is quite possible that some aspects were
considered and not implemented eventually just because 
we had something that appeared to work after a number of
experiments with the particular hardware+os configurations
we have at hand. I'm sure that the change observably "fixed"
several problems in these configurations. It's a progress
from this perspective, but I can see that maybe some programs
that would have worked in some configurations before now would
abort. It's quite possible that VxWorks doesn't support such
configurations - to be double checked.

I'll see what matter we have or can gather to go at least a
bit further, and I'll get back to you then :)

Thanks again,

Olivier



Re: [PATCH] i386: Replace frame pointer with stack pointer in debug insns

2017-08-13 Thread Uros Bizjak
On Sun, Aug 13, 2017 at 7:35 PM, H.J. Lu  wrote:
> On Sun, Aug 13, 2017 at 9:15 AM, Uros Bizjak  wrote:
>> On Sat, Aug 12, 2017 at 3:32 AM, H.J. Lu  wrote:
>>> When we eliminate frame pointer, we should also replace frame pointer
>>> with stack pointer - UNITS_PER_WORD in debug insns.  This patch fixed:
>>>
>>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b1 == 9
>>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b2 == 73
>>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b3 == 585
>>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b4 == 4681
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.f == 5.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.g == 6.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s2.g == 6.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.f == 5.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.g == 6.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.f == 5.0
>>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.g == 6.0
>>>
>>> on Linux/i386.
>>>
>>> Tested on i686 and x86-64.  OK for trunk?

OK wit ha small comment adjustment below.

Thanks,
Uros.

>>> H.J.
>>> ---
>>>
>>> PR target/81820
>>> * config/i386/i386.c (ix86_finalize_stack_frame_flags): Replace
>>> frame pointer with stack pointer - UNITS_PER_WORD in debug insns.
>>> ---
>>>  gcc/config/i386/i386.c | 36 
>>>  1 file changed, 36 insertions(+)
>>>
>>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>>> index b04321a8d40..0094f2c4441 100644
>>> --- a/gcc/config/i386/i386.c
>>> +++ b/gcc/config/i386/i386.c
>>> @@ -14281,6 +14281,42 @@ ix86_finalize_stack_frame_flags (void)
>>>df_scan_blocks ();
>>>df_compute_regs_ever_live (true);
>>>df_analyze ();
>>> +
>>> +  if (flag_var_tracking)
>>> +   {
>>> + /* Since frame pointer is no longer needed, replace it with
>>> +stack pointer - UNITS_PER_WORD in debug insns.  */

... Since frame pointer is no longer available, ...

>>> + df_ref ref, next;
>>> + for (ref = DF_REG_USE_CHAIN (HARD_FRAME_POINTER_REGNUM);
>>> +  ref; ref = next)
>>> +   {
>>> + rtx_insn *insn = DF_REF_INSN (ref);
>>> + /* Make sure the next ref is for a different instruction,
>>> +so that we're not affected by the rescan.  */
>>> + next = DF_REF_NEXT_REG (ref);
>>> + while (next && DF_REF_INSN (next) == insn)
>>> +   next = DF_REF_NEXT_REG (next);
>>
>> Can you please explain why the above loop is needed?
>>
>
> After df_insn_rescan below is called, DF_REF_NEXT_REG (ref)
> may point to the current debug instruction we just updated.
> gcc.dg/guality/pr58791-5.c is such an example.  If I take out the loop:
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 0094f2c4441..cef3a6e4816 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -14294,8 +14294,6 @@ ix86_finalize_stack_frame_flags (void)
>  /* Make sure the next ref is for a different instruction,
>so that we're not affected by the rescan.  */
>  next = DF_REF_NEXT_REG (ref);
> -while (next && DF_REF_INSN (next) == insn)
> - next = DF_REF_NEXT_REG (next);
>
>  if (DEBUG_INSN_P (insn))
>   {
>
> I got:
>
> [hjl@gnu-tools-1 gcc]$ ./xgcc -B./ -m32 -Os -g
> /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c
> during RTL pass: pro_and_epilogue
> /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c:
> In function ‘foo’:
> /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c:22:1:
> internal compiler error: Segmentation fault
>  }
>  ^
> 0xf0cae1 crash_signal
> /export/gnu/import/git/sources/gcc/gcc/toplev.c:341
> 0x1329df6 ix86_finalize_stack_frame_flags
> /export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:14293
> 0x132a5be ix86_expand_prologue()
> /export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:14440
> 0x165edaf gen_prologue()
> /export/gnu/import/git/sources/gcc/gcc/config/i386/i386.md:12464
> 0x130c25d target_gen_prologue
> /export/gnu/import/git/sources/gcc/gcc/config/i386/i386.md:18659
> 0xb30b5e make_prologue_seq
> /export/gnu/import/git/sources/gcc/gcc/function.c:5835
> 0xb30d3e thread_prologue_and_epilogue_insns()
> /export/gnu/import/git/sources/gcc/gcc/function.c:5952
> 0xb31d46 rest_of_handle_thread_prologue_and_epilogue
> /export/gnu/import/git/sources/gcc/gcc/function.c:6443
> 0xb31dc8 execute
> /export/gnu/import/git/sources/gcc/gcc/function.c:6485
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See  for instructions.
> 

*ping* [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character

2017-08-13 Thread Thomas Koenig



the attached patch fixes the PR by adding a dependency check
for the case of concatenation operators.

Regression-tested.  OK for trunk?


Ping?

Regards

Thomas


Re: [PATCH] i386: Replace frame pointer with stack pointer in debug insns

2017-08-13 Thread H.J. Lu
On Sun, Aug 13, 2017 at 9:15 AM, Uros Bizjak  wrote:
> On Sat, Aug 12, 2017 at 3:32 AM, H.J. Lu  wrote:
>> When we eliminate frame pointer, we should also replace frame pointer
>> with stack pointer - UNITS_PER_WORD in debug insns.  This patch fixed:
>>
>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b1 == 9
>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b2 == 73
>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b3 == 585
>> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b4 == 4681
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.f == 5.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.g == 6.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s2.g == 6.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.f == 5.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.g == 6.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.f == 5.0
>> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.g == 6.0
>>
>> on Linux/i386.
>>
>> Tested on i686 and x86-64.  OK for trunk?
>>
>> H.J.
>> ---
>>
>> PR target/81820
>> * config/i386/i386.c (ix86_finalize_stack_frame_flags): Replace
>> frame pointer with stack pointer - UNITS_PER_WORD in debug insns.
>> ---
>>  gcc/config/i386/i386.c | 36 
>>  1 file changed, 36 insertions(+)
>>
>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> index b04321a8d40..0094f2c4441 100644
>> --- a/gcc/config/i386/i386.c
>> +++ b/gcc/config/i386/i386.c
>> @@ -14281,6 +14281,42 @@ ix86_finalize_stack_frame_flags (void)
>>df_scan_blocks ();
>>df_compute_regs_ever_live (true);
>>df_analyze ();
>> +
>> +  if (flag_var_tracking)
>> +   {
>> + /* Since frame pointer is no longer needed, replace it with
>> +stack pointer - UNITS_PER_WORD in debug insns.  */
>> + df_ref ref, next;
>> + for (ref = DF_REG_USE_CHAIN (HARD_FRAME_POINTER_REGNUM);
>> +  ref; ref = next)
>> +   {
>> + rtx_insn *insn = DF_REF_INSN (ref);
>> + /* Make sure the next ref is for a different instruction,
>> +so that we're not affected by the rescan.  */
>> + next = DF_REF_NEXT_REG (ref);
>> + while (next && DF_REF_INSN (next) == insn)
>> +   next = DF_REF_NEXT_REG (next);
>
> Can you please explain why the above loop is needed?
>

After df_insn_rescan below is called, DF_REF_NEXT_REG (ref)
may point to the current debug instruction we just updated.
gcc.dg/guality/pr58791-5.c is such an example.  If I take out the loop:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 0094f2c4441..cef3a6e4816 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14294,8 +14294,6 @@ ix86_finalize_stack_frame_flags (void)
 /* Make sure the next ref is for a different instruction,
   so that we're not affected by the rescan.  */
 next = DF_REF_NEXT_REG (ref);
-while (next && DF_REF_INSN (next) == insn)
- next = DF_REF_NEXT_REG (next);

 if (DEBUG_INSN_P (insn))
  {

I got:

[hjl@gnu-tools-1 gcc]$ ./xgcc -B./ -m32 -Os -g
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c
during RTL pass: pro_and_epilogue
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c:
In function ‘foo’:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/guality/pr58791-5.c:22:1:
internal compiler error: Segmentation fault
 }
 ^
0xf0cae1 crash_signal
/export/gnu/import/git/sources/gcc/gcc/toplev.c:341
0x1329df6 ix86_finalize_stack_frame_flags
/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:14293
0x132a5be ix86_expand_prologue()
/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:14440
0x165edaf gen_prologue()
/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.md:12464
0x130c25d target_gen_prologue
/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.md:18659
0xb30b5e make_prologue_seq
/export/gnu/import/git/sources/gcc/gcc/function.c:5835
0xb30d3e thread_prologue_and_epilogue_insns()
/export/gnu/import/git/sources/gcc/gcc/function.c:5952
0xb31d46 rest_of_handle_thread_prologue_and_epilogue
/export/gnu/import/git/sources/gcc/gcc/function.c:6443
0xb31dc8 execute
/export/gnu/import/git/sources/gcc/gcc/function.c:6485
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
[hjl@gnu-tools-1 gcc]$


> Thanks,
> Uros.
>
>> + if (DEBUG_INSN_P (insn))
>> +   {
>> + bool changed = false;
>> + for (; ref != next; ref = DF_REF_NEXT_REG (ref))
>> +   {
>> + rtx *loc = DF_REF_LOC (ref);
>> + if (*loc == 

Re: [PATCH] i386: Replace frame pointer with stack pointer in debug insns

2017-08-13 Thread Uros Bizjak
On Sat, Aug 12, 2017 at 3:32 AM, H.J. Lu  wrote:
> When we eliminate frame pointer, we should also replace frame pointer
> with stack pointer - UNITS_PER_WORD in debug insns.  This patch fixed:
>
> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b1 == 9
> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b2 == 73
> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b3 == 585
> FAIL: gcc.dg/guality/pr58791-5.c   -Os  line pr58791-5.c:20 b4 == 4681
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.f == 5.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s1.g == 6.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:17 s2.g == 6.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.f == 5.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s1.g == 6.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.f == 5.0
> FAIL: gcc.dg/guality/pr59776.c   -Os  line pr59776.c:20 s2.g == 6.0
>
> on Linux/i386.
>
> Tested on i686 and x86-64.  OK for trunk?
>
> H.J.
> ---
>
> PR target/81820
> * config/i386/i386.c (ix86_finalize_stack_frame_flags): Replace
> frame pointer with stack pointer - UNITS_PER_WORD in debug insns.
> ---
>  gcc/config/i386/i386.c | 36 
>  1 file changed, 36 insertions(+)
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index b04321a8d40..0094f2c4441 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -14281,6 +14281,42 @@ ix86_finalize_stack_frame_flags (void)
>df_scan_blocks ();
>df_compute_regs_ever_live (true);
>df_analyze ();
> +
> +  if (flag_var_tracking)
> +   {
> + /* Since frame pointer is no longer needed, replace it with
> +stack pointer - UNITS_PER_WORD in debug insns.  */
> + df_ref ref, next;
> + for (ref = DF_REG_USE_CHAIN (HARD_FRAME_POINTER_REGNUM);
> +  ref; ref = next)
> +   {
> + rtx_insn *insn = DF_REF_INSN (ref);
> + /* Make sure the next ref is for a different instruction,
> +so that we're not affected by the rescan.  */
> + next = DF_REF_NEXT_REG (ref);
> + while (next && DF_REF_INSN (next) == insn)
> +   next = DF_REF_NEXT_REG (next);

Can you please explain why the above loop is needed?

Thanks,
Uros.

> + if (DEBUG_INSN_P (insn))
> +   {
> + bool changed = false;
> + for (; ref != next; ref = DF_REF_NEXT_REG (ref))
> +   {
> + rtx *loc = DF_REF_LOC (ref);
> + if (*loc == hard_frame_pointer_rtx)
> +   {
> + *loc = plus_constant (Pmode,
> +   stack_pointer_rtx,
> +   -UNITS_PER_WORD);
> + changed = true;
> +   }
> +   }
> + if (changed)
> +   df_insn_rescan (insn);
> +   }
> +   }
> +   }
> +
>recompute_frame_layout_p = true;
>  }
>
> --
> 2.13.4
>


[PATCH, i386]: Convert *load_tp_ and *add_tp_ to address space

2017-08-13 Thread Uros Bizjak
Hello!

Attached patch converts *load_tp_ and *add_tp_ to a load
from address 0 in DEFAULT_TLS_SEG_REG address space. The conversion is
done as a split after combine pass, so we still combine addresses,
before they are converted to a non-default address space.

2017-08-13  Uros Bizjak  

* config/i386/i386.md (*load_tp_): Redefine as
define_insn_and_split.  Split to a memory load from 0 in
DEFAULT_TLS_SEG_REG address space.  Merge with *load_tp_x32
using PTR mode iterator.
(*load_tp_x32_zext"): Redefine as define_insn_and_split.
Split to a memory load from 0 in DEFAULT_TLS_SEG_REG address space.
(*add_tp_): Redefine as define_insn_and_split.
Split to an add with a memory load from 0 in DEFAULT_TLS_SEG_REG
address space.  Merge with *add_tp_x32 using PTR mode iterator.
(*add_tp_x32_zext"): Redefine as define_insn_and_split.
Split to an add with a  memory load from 0 in
DEFAULT_TLS_SEG_REG address space.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 251053)
+++ config/i386/i386.md (working copy)
@@ -13773,57 +13773,59 @@
   (clobber (match_dup 5))
   (clobber (reg:CC FLAGS_REG))])])
 
-;; Segment register for the thread base ptr load
-(define_mode_attr tp_seg [(SI "gs") (DI "fs")])
-
 ;; Load and add the thread base pointer from %:0.
-(define_insn "*load_tp_x32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (unspec:SI [(const_int 0)] UNSPEC_TP))]
-  "TARGET_X32"
-  "mov{l}\t{%%fs:0, %0|%0, DWORD PTR fs:0}"
-  [(set_attr "type" "imov")
-   (set_attr "modrm" "0")
-   (set_attr "length" "7")
-   (set_attr "memory" "load")
-   (set_attr "imm_disp" "false")])
+(define_insn_and_split "*load_tp_"
+  [(set (match_operand:PTR 0 "register_operand" "=r")
+   (unspec:PTR [(const_int 0)] UNSPEC_TP))]
+  ""
+  "#"
+  ""
+  [(set (match_dup 0)
+   (match_dup 1))]
+{
+  addr_space_t as = DEFAULT_TLS_SEG_REG;
 
-(define_insn "*load_tp_x32_zext"
+  operands[1] = gen_const_mem (mode, const0_rtx);
+  set_mem_addr_space (operands[1], as);
+})
+
+(define_insn_and_split "*load_tp_x32_zext"
   [(set (match_operand:DI 0 "register_operand" "=r")
-   (zero_extend:DI (unspec:SI [(const_int 0)] UNSPEC_TP)))]
+   (zero_extend:DI
+ (unspec:SI [(const_int 0)] UNSPEC_TP)))]
   "TARGET_X32"
-  "mov{l}\t{%%fs:0, %k0|%k0, DWORD PTR fs:0}"
-  [(set_attr "type" "imov")
-   (set_attr "modrm" "0")
-   (set_attr "length" "7")
-   (set_attr "memory" "load")
-   (set_attr "imm_disp" "false")])
+  "#"
+  ""
+  [(set (match_dup 0)
+   (zero_extend:DI (match_dup 1)))]
+{
+  addr_space_t as = DEFAULT_TLS_SEG_REG;
 
-(define_insn "*load_tp_"
-  [(set (match_operand:P 0 "register_operand" "=r")
-   (unspec:P [(const_int 0)] UNSPEC_TP))]
-  "!TARGET_X32"
-  "mov{}\t{%%:0, %0|%0,  PTR :0}"
-  [(set_attr "type" "imov")
-   (set_attr "modrm" "0")
-   (set_attr "length" "7")
-   (set_attr "memory" "load")
-   (set_attr "imm_disp" "false")])
+  operands[1] = gen_const_mem (SImode, const0_rtx);
+  set_mem_addr_space (operands[1], as);
+})
 
-(define_insn "*add_tp_x32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (plus:SI (unspec:SI [(const_int 0)] UNSPEC_TP)
-(match_operand:SI 1 "register_operand" "0")))
+(define_insn_and_split "*add_tp_"
+  [(set (match_operand:PTR 0 "register_operand" "=r")
+   (plus:PTR
+ (unspec:PTR [(const_int 0)] UNSPEC_TP)
+ (match_operand:PTR 1 "register_operand" "0")))
(clobber (reg:CC FLAGS_REG))]
-  "TARGET_X32"
-  "add{l}\t{%%fs:0, %0|%0, DWORD PTR fs:0}"
-  [(set_attr "type" "alu")
-   (set_attr "modrm" "0")
-   (set_attr "length" "7")
-   (set_attr "memory" "load")
-   (set_attr "imm_disp" "false")])
+  ""
+  "#"
+  ""
+  [(parallel
+ [(set (match_dup 0)
+  (plus:PTR (match_dup 1) (match_dup 2)))
+  (clobber (reg:CC FLAGS_REG))])]
+{
+  addr_space_t as = DEFAULT_TLS_SEG_REG;
 
-(define_insn "*add_tp_x32_zext"
+  operands[2] = gen_const_mem (mode, const0_rtx);
+  set_mem_addr_space (operands[2], as);
+})
+
+(define_insn_and_split "*add_tp_x32_zext"
   [(set (match_operand:DI 0 "register_operand" "=r")
(zero_extend:DI
  (plus:SI (unspec:SI [(const_int 0)] UNSPEC_TP)
@@ -13830,25 +13832,19 @@
   (match_operand:SI 1 "register_operand" "0"
(clobber (reg:CC FLAGS_REG))]
   "TARGET_X32"
-  "add{l}\t{%%fs:0, %k0|%k0, DWORD PTR fs:0}"
-  [(set_attr "type" "alu")
-   (set_attr "modrm" "0")
-   (set_attr "length" "7")
-   (set_attr "memory" "load")
-   (set_attr "imm_disp" "false")])
+  "#"
+  ""
+  [(parallel
+ [(set (match_dup 0)
+  (zero_extend:DI
+(plus:SI (match_dup 1) (match_dup 2
+  (clobber (reg:CC FLAGS_REG))])]
+{
+  addr_space_t as = DEFAULT_TLS_SEG_REG;
 
-(define_insn 

[PATCH] Write dependency information (-M*) even if there are errors

2017-08-13 Thread Boris Kolpackov
Hi,

I've been instructed to resend this patch from the gcc mailing list:

Currently GCC does not write extracted header dependency information
if there are errors. However, this can be useful when dealing with
outdated generated headers that trigger errors which would have been
resolved if we could update it. A concrete example in our case is a
version check with #error.

The included (trivial) patch changes this behavior. Note also that
this is how Clang already behaves. I've tested the patch in build2
and everything works well (i.e., no invalid dependency output in the
face of various preprocessor errors such as #error, stray #else, etc).

While I don't foresee any backwards-compatibility issues with such
an unconditional change (after all, the compiler still exists with
an error status), if there are concerns, I could re-do it via an
option (e.g., -ME, analogous to -MG).

Joseph Myers  writes:

> I suppose a question for the present proposal would be making sure any 
> dependencies generated in this case do not include dependencies on files 
> that don't exist (so #include "some-misspelling.h" doesn't create any sort 
> of dependency on such a header).

Good point. I've tested this and I believe everything is in order:
unless -MG is specified, a non-existent header is treated as a fatal
error so we don't even get to writing the dependency info. And if -MG
is specified, then there is no error and we get the missing header in
the dependency output, as requested.

P.S. I have the paperwork necessary to contribute on file with FSF.

Thanks,
Boris
Index: gcc/c-family/ChangeLog
===
--- gcc/c-family/ChangeLog	(revision 250514)
+++ gcc/c-family/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2017-08-06  Boris Kolpackov 
+
+	* c-opts.c (c_common_finish): Write dependency information even if
+	there are errors.
+
 2017-07-14  David Malcolm  
 
 	* c-common.c (try_to_locate_new_include_insertion_point): New
Index: gcc/c-family/c-opts.c
===
--- gcc/c-family/c-opts.c	(revision 250514)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -1152,8 +1157,11 @@
 {
   FILE *deps_stream = NULL;
 
-  /* Don't write the deps file if there are errors.  */
-  if (cpp_opts->deps.style != DEPS_NONE && !seen_error ())
+  /* Note that we write the dependencies even if there are errors. This is
+ useful for handling outdated generated headers that now trigger errors
+ (for example, with #error) which would be resolved by re-generating
+ them. In a sense, this complements -MG.  */
+  if (cpp_opts->deps.style != DEPS_NONE)
 {
   /* If -M or -MM was seen without -MF, default output to the
 	 output stream.  */