Re: [PATCH] Fix REG_EQUAL note in x86 -m8bit-idiv code

2017-09-30 Thread Uros Bizjak
On Fri, Sep 29, 2017 at 10:59 PM, Jakub Jelinek  wrote:
> Hi!
>
> While working on the following patch, I've discovered that the REG_EQUAL
> notes for DImode signed/unsigned division/modulo are wrong, there is
> e.g. (div:SI (reg:DI ...) (reg:DI ...)).
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2017-09-29  Jakub Jelinek  
>
> * config/i386/i386.c (ix86_split_idivmod): Use mode instead of
> always SImode for DIV and MOD in REG_EQUAL notes.

OK for mainline and release branches.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2017-09-28 20:35:14.0 +0200
> +++ gcc/config/i386/i386.c  2017-09-29 19:15:27.822267844 +0200
> @@ -21980,13 +21980,13 @@ ix86_split_idivmod (machine_mode mode, r
>
>if (signed_p)
>  {
> -  div = gen_rtx_DIV (SImode, operands[2], operands[3]);
> -  mod = gen_rtx_MOD (SImode, operands[2], operands[3]);
> +  div = gen_rtx_DIV (mode, operands[2], operands[3]);
> +  mod = gen_rtx_MOD (mode, operands[2], operands[3]);
>  }
>else
>  {
> -  div = gen_rtx_UDIV (SImode, operands[2], operands[3]);
> -  mod = gen_rtx_UMOD (SImode, operands[2], operands[3]);
> +  div = gen_rtx_UDIV (mode, operands[2], operands[3]);
> +  mod = gen_rtx_UMOD (mode, operands[2], operands[3]);
>  }
>
>/* Extract remainder from AH.  */
>
> Jakub


Re: [PATCH] Improve x86-64 32-bit div/mod followed by zero-extension to 64-bit (PR target/82361)

2017-09-30 Thread Uros Bizjak
On Fri, Sep 29, 2017 at 11:05 PM, Jakub Jelinek  wrote:
> Hi!
>
> The following patch adds patterns and splitters for {,u}divmodsi4 followed
> by zero-extension, similarly to other 32-bit operand instructions divl and
> idivl zero extends both results to 64-bit, so there is no need to extend it
> again.  The REE pass ignores instructions that have more than one SET, but
> at least the combiner doesn't.  The patch adds both patterns/splitters that
> zero extend the quotient and patterns/splttiers that zero extend the modulo
> (the combiner wants in that case the modulo to be the first operation).
> I have a patch which I'll attach to the PR, which also has patterns for
> both results zero extended, but as neither combiner nor anything else is
> able to match them right now, I'm not including it here.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-09-29  Jakub Jelinek  
>
> PR target/82361
> * config/i386/i386.md
> (TARGET_USE_8BIT_IDIV zext divmodsi4 splitter): New define_split.
> (divmodsi4_zext_1, divmodsi4_zext_2, *divmodsi4_zext_1,
> *divmodsi4_zext_2): New define_insn_and_split.
> (*divmodsi4_noext_zext_1, *divmodsi4_noext_zext_2): New define_insn.
> (TARGET_USE_8BIT_IDIV zext udivmodsi4 splitter): New define_split.
> (udivmodsi4_zext_1, udivmodsi4_zext_2, *udivmodsi4_zext_1,
> *udivmodsi4_zext_2, *udivmodsi4_pow2_zext_1, *udivmodsi4_pow2_zext_2):
> New define_insn_and_split.
> (*udivmodsi4_noext_zext_1, *udivmodsi4_noext_zext_2): New define_insn.
> * config/i386/i386.c (ix86_split_idivmod): Handle operands[0] or
> operands[1] having DImode when mode is SImode.
>
> * gcc.target/i386/pr82361-1.c: New test.
> * gcc.target/i386/pr82361-2.c: New test.

OK, although this is quite some work for relatively small gain. The
reason that zext for divisions was not implemented was that a zext was
relatviely cheap comparing to idiv insn, so it was not a pressing
issue,

Thanks,
Uros.

> --- gcc/config/i386/i386.md.jj  2017-09-29 09:19:42.0 +0200
> +++ gcc/config/i386/i386.md 2017-09-29 19:19:34.795293575 +0200
> @@ -7635,6 +7635,36 @@ (define_split
>[(const_int 0)]
>"ix86_split_idivmod (mode, operands, true); DONE;")
>
> +(define_split
> +  [(set (match_operand:DI 0 "register_operand")
> +   (zero_extend:DI
> + (div:SI (match_operand:SI 2 "register_operand")
> + (match_operand:SI 3 "nonimmediate_operand"
> +   (set (match_operand:SI 1 "register_operand")
> +   (mod:SI (match_dup 2) (match_dup 3)))
> +   (clobber (reg:CC FLAGS_REG))]
> +  "TARGET_USE_8BIT_IDIV
> +   && TARGET_QIMODE_MATH
> +   && can_create_pseudo_p ()
> +   && !optimize_insn_for_size_p ()"
> +  [(const_int 0)]
> +  "ix86_split_idivmod (SImode, operands, true); DONE;")
> +
> +(define_split
> +  [(set (match_operand:DI 1 "register_operand")
> +   (zero_extend:DI
> + (mod:SI (match_operand:SI 2 "register_operand")
> + (match_operand:SI 3 "nonimmediate_operand"
> +   (set (match_operand:SI 0 "register_operand")
> +   (div:SI  (match_dup 2) (match_dup 3)))
> +   (clobber (reg:CC FLAGS_REG))]
> +  "TARGET_USE_8BIT_IDIV
> +   && TARGET_QIMODE_MATH
> +   && can_create_pseudo_p ()
> +   && !optimize_insn_for_size_p ()"
> +  [(const_int 0)]
> +  "ix86_split_idivmod (SImode, operands, true); DONE;")
> +
>  (define_insn_and_split "divmod4_1"
>[(set (match_operand:SWI48 0 "register_operand" "=a")
> (div:SWI48 (match_operand:SWI48 2 "register_operand" "0")
> @@ -7670,6 +7700,79 @@ (define_insn_and_split "divmod4_1"
>[(set_attr "type" "multi")
> (set_attr "mode" "")])
>
> +(define_insn_and_split "divmodsi4_zext_1"
> +  [(set (match_operand:DI 0 "register_operand" "=a")
> +   (zero_extend:DI
> + (div:SI (match_operand:SI 2 "register_operand" "0")
> + (match_operand:SI 3 "nonimmediate_operand" "rm"
> +   (set (match_operand:SI 1 "register_operand" "=&d")
> +   (mod:SI (match_dup 2) (match_dup 3)))
> +   (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
> +   (clobber (reg:CC FLAGS_REG))]
> +  "TARGET_64BIT"
> +  "#"
> +  "reload_completed"
> +  [(parallel [(set (match_dup 1)
> +  (ashiftrt:SI (match_dup 4) (match_dup 5)))
> + (clobber (reg:CC FLAGS_REG))])
> +   (parallel [(set (match_dup 0)
> +  (zero_extend:DI (div:SI (match_dup 2) (match_dup 3
> + (set (match_dup 1)
> +  (mod:SI (match_dup 2) (match_dup 3)))
> + (use (match_dup 1))
> + (clobber (reg:CC FLAGS_REG))])]
> +{
> +  operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
> +
> +  if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
> +operands[4] = operands[2];
> +  else
> +{
> +  /* Avoid use of cltd in favor of a mov+shift.  */
> +  emit_move_insn (operands[1], operands[2]);
> +  

Re: patch to fix PR81481

2017-09-30 Thread Richard Sandiford
Vladimir Makarov  writes:
> The following patch fixes
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81481
>
> The patch was bootstrapped and tested on x86-64.
>
> Committed as rev. 253300.
>
>
> Index: ira-costs.c
> ===
> --- ira-costs.c (revision 253253)
> +++ ira-costs.c (working copy)
> @@ -1471,7 +1471,10 @@ scan_one_insn (rtx_insn *insn)
>&& targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)),
>  XEXP (note, 0))
>&& REG_N_SETS (REGNO (SET_DEST (set))) == 1))
> -  && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set
> +  && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set)))
> +  /* LRA does not use equiv with a symbol for PIC code.  */
> +  && (! ira_use_lra_p || ! pic_offset_table_rtx
> + || ! contains_symbol_ref_p (XEXP (note, 0
>   {
> enum reg_class cl = GENERAL_REGS;
> rtx reg = SET_DEST (set);

I don't think this is the right test for PICness.  Most targets have
an unconditional pic_offset_table_rtx.

Richard


[Patch, fortran] PR 82312 - [7/8 Regression] Pointer assignment to component of class variable results wrong vptr for the variable

2017-09-30 Thread Paul Richard Thomas
Greetings to all,

This patch fixes a bug where the pointer assignment to the derived
component of a class entity was resulting in the base entity's vptr
being set to the vtable of the target. This resulted in the wrong
typebound procedure being called.

The patch corrects the logic in resolve code that determines when
regular assignment is used for class pointer assignment and breaks out
some codeto handle function targets from trans_pointer_assignment so
that function targets are correctly handled.

Bootstraps and regtests on FC23/x86_64 - OK for trunk and 7 branch?

Cheers

Paul

2017-09-30  Paul Thomas  

PR fortran/82312
* resolve.c (gfc_resolve_code): Simplify condition for class
pointer assignments becoming regular assignments by asserting
that only class valued targets are permitted.
* trans-expr.c (trans_class_pointer_fcn): New function using a
block of code from gfc_trans_pointer_assignment.
(gfc_trans_pointer_assignment): Call the new function. Tidy up
a minor whitespace issue.

2017-09-30  Paul Thomas  

PR fortran/82312
* gfortran.dg/typebound_proc_36.f90 : New test.
Index: gcc/fortran/resolve.c
===
*** gcc/fortran/resolve.c   (revision 253268)
--- gcc/fortran/resolve.c   (working copy)
*** start:
*** 9,11129 
  
/* Assigning a class object always is a regular assign.  */
if (code->expr2->ts.type == BT_CLASS
&& !CLASS_DATA (code->expr2)->attr.dimension
-   && !(UNLIMITED_POLY (code->expr2)
-&& code->expr1->ts.type == BT_DERIVED
-&& (code->expr1->ts.u.derived->attr.sequence
-|| code->expr1->ts.u.derived->attr.is_bind_c))
&& !(gfc_expr_attr (code->expr1).proc_pointer
 && code->expr2->expr_type == EXPR_VARIABLE
 && code->expr2->symtree->n.sym->attr.flavor
--- 9,11126 
  
/* Assigning a class object always is a regular assign.  */
if (code->expr2->ts.type == BT_CLASS
+   && code->expr1->ts.type == BT_CLASS
&& !CLASS_DATA (code->expr2)->attr.dimension
&& !(gfc_expr_attr (code->expr1).proc_pointer
 && code->expr2->expr_type == EXPR_VARIABLE
 && code->expr2->symtree->n.sym->attr.flavor
Index: gcc/fortran/trans-expr.c
===
*** gcc/fortran/trans-expr.c(revision 253268)
--- gcc/fortran/trans-expr.c(working copy)
*** pointer_assignment_is_proc_pointer (gfc_
*** 8207,8212 
--- 8207,8245 
  }
  
  
+ /* Do everything that is needed for a CLASS function expr2.  */
+ 
+ static tree
+ trans_class_pointer_fcn (stmtblock_t *block, gfc_se *lse, gfc_se *rse,
+gfc_expr *expr1, gfc_expr *expr2)
+ {
+   tree expr1_vptr = NULL_TREE;
+   tree tmp;
+ 
+   gfc_conv_function_expr (rse, expr2);
+   rse->expr = gfc_evaluate_now (rse->expr, &rse->pre);
+ 
+   if (expr1->ts.type != BT_CLASS)
+   rse->expr = gfc_class_data_get (rse->expr);
+   else
+ {
+   expr1_vptr = trans_class_vptr_len_assignment (block, expr1,
+   expr2, rse,
+   NULL, NULL);
+   gfc_add_block_to_block (block, &rse->pre);
+   tmp = gfc_create_var (TREE_TYPE (rse->expr), "ptrtemp");
+   gfc_add_modify (&lse->pre, tmp, rse->expr);
+ 
+   gfc_add_modify (&lse->pre, expr1_vptr,
+ fold_convert (TREE_TYPE (expr1_vptr),
+ gfc_class_vptr_get (tmp)));
+   rse->expr = gfc_class_data_get (tmp);
+ }
+ 
+   return expr1_vptr;
+ }
+ 
+ 
  tree
  gfc_trans_pointer_assign (gfc_code * code)
  {
*** gfc_trans_pointer_assignment (gfc_expr *
*** 8224,8229 
--- 8257,8263 
stmtblock_t block;
tree desc;
tree tmp;
+   tree expr1_vptr = NULL_TREE;
bool scalar, non_proc_pointer_assign;
gfc_ss *ss;
  
*** gfc_trans_pointer_assignment (gfc_expr *
*** 8257,8263 
gfc_conv_expr (&lse, expr1);
gfc_init_se (&rse, NULL);
rse.want_pointer = 1;
!   gfc_conv_expr (&rse, expr2);
  
if (non_proc_pointer_assign && expr1->ts.type == BT_CLASS)
{
--- 8291,8300 
gfc_conv_expr (&lse, expr1);
gfc_init_se (&rse, NULL);
rse.want_pointer = 1;
!   if (expr2->expr_type == EXPR_FUNCTION && expr2->ts.type == BT_CLASS)
!   trans_class_pointer_fcn (&block, &lse, &rse, expr1, expr2);
!   else
!   gfc_conv_expr (&rse, expr2);
  
if (non_proc_pointer_assign && expr1->ts.type == BT_CLASS)
{
*** gfc_trans_pointer_assignment (gfc_expr *
*** 8269,8280 
if (expr1->symtree->n.sym->attr.proc_pointer
  && expr1->symtree->n.sym->attr.dumm

Re: Statement Frontier Notes, Location Views, and Inlined Entry Point Markers

2017-09-30 Thread Alexandre Oliva
On Aug 31, 2017, Alexandre Oliva  wrote:

> On Aug 23, 2017, Richard Biener  wrote:
>> Just separating the boilerplate changes out from the "meat" of the change
>> into a separate patch for easier reviewing would be nice.

> I've broken up the patch into a patchset with 10 patches.  I've already
> posted the one that makes -g options negatable the other day;

That one was approved and checked in.

> I'll post the other 9 as a follow up to this message.

I've refreshed and retested the others.  There was a conflict in
find_bb_boundaries, and the changes for compare-debug made there seem to
have obviated what was in the patchset, so I dropped mine.

I'm posting the refreshed patchset as a followup to this message.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu, tested with -O1 (*1),
-O2 and -O3 (*2), with and without -fcompare-debug (*3).  Ok to install?

(*1) -O1 required this initializer to silence a warning:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index d4d9490..38e87b7 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6598,7 +6598,7 @@ ix86_option_override_internal (bool main_args_p,
 {
   char *p = ASTRDUP (opts->x_ix86_recip_name);
   char *q;
-  unsigned int mask, i;
+  unsigned int mask = 0, i;
   bool invert;
 
   while ((q = strtok (p, ",")) != NULL)


(*2) -O3 required this initializer to silence a warning:

diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index 22fdb88..4e87e42 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -4325,7 +4325,7 @@ allocno_reload_assign (ira_allocno_t a, HARD_REG_SET 
forbidden_regs)
   int hard_regno;
   enum reg_class aclass;
   int regno = ALLOCNO_REGNO (a);
-  HARD_REG_SET saved[2];
+  HARD_REG_SET saved[2] = {};
   int i, n;
 
   n = ALLOCNO_NUM_OBJECTS (a);


(*3) bootstrap-debug works, but bootstrap-debug-lean fails compare,
because stage2 gets '-fcompare-debug= ' in the producer string, whereas
stage3 gets '-fcompare-debug=-gtoggle -frandom-seed=0x... '.  it is the
compiler driver that supplies the same -frandom-seed for both
-fcompare-debug compilations that take place in stage3 under
bootstrap-debug-lean.  This used to work, but now that we add them to
the producer string, it fails.  I'm inclined to change
gen_producer_string to ignore -fcompare-debug and -frandom-seed, but
dropping the latter is probably not a good idea if it was explicitly
added by the user.  Perhaps we should only drop it from the producer if
it follows the -fcompare-debug option?  Or should we use the stripping
logic from contrib/compare-debug under bootstrap-debug-lean too?

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


[PATCH 1/9] [SFN] adjust RTL insn-walking API

2017-09-30 Thread Alexandre Oliva
This patch removes unused RTL functions, introduces alternate ones for
use in a later SFN patch, and regroups other related functions so that
they appear in a more consistent order.

for  gcc/ChangeLog

* emit-rtl.c (next_nondebug_insn, prev_nondebug_insn): Reorder.
(next_nonnote_nondebug_insn, prev_nonnote_nondebug_insn): Reorder.
(next_nonnote_nondebug_insn_bb): New.
(prev_nonnote_nondebug_insn_bb): New.
(prev_nonnote_insn_bb, next_nonnote_insn_bb): Remove.
* rtl.h (prev_nonnote_insn_bb, next_nonnote_insn_bb): Remove decls.
(prev_nonnote_nondebug_insn_bb): Declare.
(next_nonnote_nondebug_insn_bb): Declare.
* cfgbuild.c (find_bb_boundaries): Adjust to skip debug insns.
* cfgrtl.c (get_last_bb_insn): Likewise.
* lra.c (push_insns): Likewise.
---
 gcc/cfgbuild.c |  2 +-
 gcc/cfgrtl.c   |  4 ++--
 gcc/emit-rtl.c | 69 --
 gcc/lra.c  |  2 +-
 gcc/rtl.h  |  4 ++--
 5 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 62956b2..76c21d7 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -512,7 +512,7 @@ find_bb_boundaries (basic_block bb)
 the middle of a BB.  We need to split it in the same manner as
 if the barrier were preceded by a control_flow_insn_p insn.  */
  if (!flow_transfer_insn)
-   flow_transfer_insn = prev_nonnote_insn_bb (insn);
+   flow_transfer_insn = prev_nonnote_nondebug_insn_bb (insn);
}
 
   if (control_flow_insn_p (insn))
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 6ef47b7..bce56b4 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2274,11 +2274,11 @@ get_last_bb_insn (basic_block bb)
 end = table;
 
   /* Include any barriers that may follow the basic block.  */
-  tmp = next_nonnote_insn_bb (end);
+  tmp = next_nonnote_nondebug_insn_bb (end);
   while (tmp && BARRIER_P (tmp))
 {
   end = tmp;
-  tmp = next_nonnote_insn_bb (end);
+  tmp = next_nonnote_nondebug_insn_bb (end);
 }
 
   return end;
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index e790cbc..68c1f11 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3355,20 +3355,17 @@ next_nonnote_insn (rtx_insn *insn)
   return insn;
 }
 
-/* Return the next insn after INSN that is not a NOTE, but stop the
-   search before we enter another basic block.  This routine does not
-   look inside SEQUENCEs.  */
+/* Return the next insn after INSN that is not a DEBUG_INSN.  This
+   routine does not look inside SEQUENCEs.  */
 
 rtx_insn *
-next_nonnote_insn_bb (rtx_insn *insn)
+next_nondebug_insn (rtx_insn *insn)
 {
   while (insn)
 {
   insn = NEXT_INSN (insn);
-  if (insn == 0 || !NOTE_P (insn))
+  if (insn == 0 || !DEBUG_INSN_P (insn))
break;
-  if (NOTE_INSN_BASIC_BLOCK_P (insn))
-   return NULL;
 }
 
   return insn;
@@ -3390,67 +3387,70 @@ prev_nonnote_insn (rtx_insn *insn)
   return insn;
 }
 
-/* Return the previous insn before INSN that is not a NOTE, but stop
-   the search before we enter another basic block.  This routine does
-   not look inside SEQUENCEs.  */
+/* Return the previous insn before INSN that is not a DEBUG_INSN.
+   This routine does not look inside SEQUENCEs.  */
 
 rtx_insn *
-prev_nonnote_insn_bb (rtx_insn *insn)
+prev_nondebug_insn (rtx_insn *insn)
 {
-
   while (insn)
 {
   insn = PREV_INSN (insn);
-  if (insn == 0 || !NOTE_P (insn))
+  if (insn == 0 || !DEBUG_INSN_P (insn))
break;
-  if (NOTE_INSN_BASIC_BLOCK_P (insn))
-   return NULL;
 }
 
   return insn;
 }
 
-/* Return the next insn after INSN that is not a DEBUG_INSN.  This
-   routine does not look inside SEQUENCEs.  */
+/* Return the next insn after INSN that is not a NOTE nor DEBUG_INSN.
+   This routine does not look inside SEQUENCEs.  */
 
 rtx_insn *
-next_nondebug_insn (rtx_insn *insn)
+next_nonnote_nondebug_insn (rtx_insn *insn)
 {
   while (insn)
 {
   insn = NEXT_INSN (insn);
-  if (insn == 0 || !DEBUG_INSN_P (insn))
+  if (insn == 0 || (!NOTE_P (insn) && !DEBUG_INSN_P (insn)))
break;
 }
 
   return insn;
 }
 
-/* Return the previous insn before INSN that is not a DEBUG_INSN.
-   This routine does not look inside SEQUENCEs.  */
+/* Return the next insn after INSN that is not a NOTE nor DEBUG_INSN,
+   but stop the search before we enter another basic block.  This
+   routine does not look inside SEQUENCEs.  */
 
 rtx_insn *
-prev_nondebug_insn (rtx_insn *insn)
+next_nonnote_nondebug_insn_bb (rtx_insn *insn)
 {
   while (insn)
 {
-  insn = PREV_INSN (insn);
-  if (insn == 0 || !DEBUG_INSN_P (insn))
+  insn = NEXT_INSN (insn);
+  if (insn == 0)
+   break;
+  if (DEBUG_INSN_P (insn))
+   continue;
+  if (!NOTE_P (insn))
break;
+  if (NOTE_INSN_BASIC_BLOCK_P (insn))
+   return NULL;
 }
 
   return insn;
 }
 
-/* Return 

[PATCH 5/9] [SFN] Introduce -gstatement-frontiers option, enable debug markers

2017-09-30 Thread Alexandre Oliva
Introduce a command line option to enable statement frontiers, enabled
by default in optimized builds with DWARF2+ debug information.

This patch depends on an earlier patch that completed the
infrastructure for debug markers, and on another patch that turns -g
into a negatable option prefix.

gcc/ChangeLog

* common.opt (gstatement-frontiers): New, setting
debug_nonbind_markers_p.
* rtl.h (MAY_HAVE_DEBUG_MARKER_INSNS): Activate.
* toplev.c (process_options): Autodetect value for debug statement
frontiers option.
* tree.h (MAY_HAVE_DEBUG_MARKER_STMTS): Activate.
* doc/invoke.texi (gstatement-frontiers, gno-statement-frontiers): New.
---
 gcc/common.opt  |  4 
 gcc/doc/invoke.texi | 12 
 gcc/rtl.h   |  2 +-
 gcc/toplev.c|  4 
 gcc/tree.h  |  2 +-
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index dfde6ad..a12c11c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2889,6 +2889,10 @@ gstabs+
 Common Driver JoinedOrMissing Negative(gvms)
 Generate debug information in extended STABS format.
 
+gstatement-frontiers
+Common Driver Var(debug_nonbind_markers_p) Init(2)
+Emit progressive recommended breakpoint locations.
+
 gstrict-dwarf
 Common Driver Report Var(dwarf_strict) Init(0)
 Don't emit DWARF additions beyond selected version.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 108d730..85e41e4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -346,6 +346,7 @@ Objective-C and Objective-C++ Dialects}.
 -ggdb  -grecord-gcc-switches  -gno-record-gcc-switches @gol
 -gstabs  -gstabs+  -gstrict-dwarf  -gno-strict-dwarf @gol
 -gcolumn-info  -gno-column-info @gol
+-gstatement-frontiers  -gno-statement-frontiers @gol
 -gvms  -gxcoff  -gxcoff+  -gz@r{[}=@var{type}@r{]} @gol
 -fdebug-prefix-map=@var{old}=@var{new}  -fdebug-types-section @gol
 -fno-eliminate-unused-debug-types @gol
@@ -7040,6 +7041,17 @@ Emit location column information into DWARF debugging 
information, rather
 than just file and line.
 This option is disabled by default.
 
+@item -gstatement-frontiers
+@item -gno-statement-frontiers
+@opindex gstatement-frontiers
+@opindex gno-statement-frontiers
+This option causes GCC to create markers in the internal representation
+at the beginning of statements, and to keep them roughly in place
+throughout compilation, using them to guide the output of @code{is_stmt}
+markers in the line number table.  This is enabled by default when
+compiling with optimization (@option{-Os}, @option{-O}, @option{-O2},
+@dots{}), and outputting DWARF 2 debug information at the normal level.
+
 @item -gz@r{[}=@var{type}@r{]}
 @opindex gz
 Produce compressed debug sections in DWARF format, if that is supported.
diff --git a/gcc/rtl.h b/gcc/rtl.h
index c79a277..a0c27fc 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -816,7 +816,7 @@ struct GTY(()) rtvec_def {
 #define NONDEBUG_INSN_P(X) (INSN_P (X) && !DEBUG_INSN_P (X))
 
 /* Nonzero if DEBUG_MARKER_INSN_P may possibly hold.  */
-#define MAY_HAVE_DEBUG_MARKER_INSNS 0 /* debug_nonbind_markers_p */
+#define MAY_HAVE_DEBUG_MARKER_INSNS debug_nonbind_markers_p
 /* Nonzero if DEBUG_BIND_INSN_P may possibly hold.  */
 #define MAY_HAVE_DEBUG_BIND_INSNS flag_var_tracking_assignments
 /* Nonzero if DEBUG_INSN_P may possibly hold.  */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index bee79d3..0ef46da 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1514,6 +1514,10 @@ process_options (void)
 warning_at (UNKNOWN_LOCATION, 0,
"var-tracking-assignments changes selective scheduling");
 
+  if (debug_nonbind_markers_p == AUTODETECT_VALUE)
+debug_nonbind_markers_p = optimize && debug_info_level >= 
DINFO_LEVEL_NORMAL
+  && (write_symbols == DWARF2_DEBUG || write_symbols == 
VMS_AND_DWARF2_DEBUG);
+
   if (flag_tree_cselim == AUTODETECT_VALUE)
 {
   if (HAVE_conditional_move)
diff --git a/gcc/tree.h b/gcc/tree.h
index 62a85ea..8c3bda1 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1127,7 +1127,7 @@ extern void omp_clause_range_check_failed (const_tree, 
const char *, int,
   ((int)TREE_INT_CST_LOW (VL_EXP_CHECK (NODE)->exp.operands[0]))
 
 /* Nonzero if gimple_debug_nonbind_marker_p() may possibly hold.  */
-#define MAY_HAVE_DEBUG_MARKER_STMTS 0 /* debug_nonbind_markers_p */
+#define MAY_HAVE_DEBUG_MARKER_STMTS debug_nonbind_markers_p
 /* Nonzero if gimple_debug_bind_p() (and thus
gimple_debug_source_bind_p()) may possibly hold.  */
 #define MAY_HAVE_DEBUG_BIND_STMTS flag_var_tracking_assignments
-- 
2.9.5



[PATCH 2/9] [SFN] boilerplate changes in preparation to introduce nonbind markers

2017-09-30 Thread Alexandre Oliva
This patch introduces a number of new macros and functions that will
be used to distinguish between different kinds of debug stmts, insns
and notes, namely, preexisting debug bind ones and to-be-introduced
nonbind markers.

In a seemingly mechanical way, it adjusts several uses of the macros
and functions, so that they refer to narrower categories when
appropriate.

These changes, by themselves, should not have any visible effect in
the compiler behavior, since the upcoming debug markers are never
created with this patch alone.

for  gcc/ChangeLog

* gimple.h (enum gimple_debug_subcode): Add
GIMPLE_DEBUG_BEGIN_STMT.
(gimple_debug_begin_stmt_p): New.
(gimple_debug_nonbind_marker_p): New.
* tree.h (MAY_HAVE_DEBUG_MARKER_STMTS): New.
(MAY_HAVE_DEBUG_BIND_STMTS): Renamed from
(MAY_HAVE_DEBUG_STMTS): ... this.  Check both.
* insn-notes.def (BEGIN_STMT): New.
* rtl.h (MAY_HAVE_DEBUG_MARKER_INSNS): New.
(MAY_HAVE_DEBUG_BIND_INSNS): Renamed from
(MAY_HAVE_DEBUG_INSNS): ... this.  Check both.
(NOTE_MARKER_LOCATION, NOTE_MARKER_P): New.
(DEBUG_BIND_INSN_P, DEBUG_MARKER_INSN_P): New.
(INSN_DEBUG_MARKER_KIND): New.
(INSN_VAR_LOCATION): Check for VAR_LOCATION.
(INSN_VAR_LOCATION_PTR): New.
* cfgexpand.c (expand_debug_locations): Handle debug bind insns
only.
(expand_gimple_basic_block): Likewise.  Emit debug temps for TER
deps only if debug bind insns are enabled.
(pass_expand::execute): Avoid deep TER and expand
debug locations for debug bind insns only.
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Narrow
debug stmts special handling down to debug bind stmts.
* combine.c (try_combine): Narrow debug insns special handling
down to debug bind insns.
* cse.c (delete_trivially_dead_insns): Handle debug bindings.
Narrow debug insns preexisting special handling down to debug
bind insns.
* dce.c (rest_of_handle_ud_dce): Narrow debug insns special
handling down to debug bind insns.
* function.c (instantiate_virtual_regs): Skip debug markers,
adjust handling of debug binds.
* gimple-ssa-backprop.c (backprop::prepare_change): Try debug
temp insertion iff MAY_HAVE_DEBUG_BIND_STMTS.
* haifa-sched.c (schedule_insn): Narrow special handling of debug
insns to debug bind insns.
* ipa-prop.c (ipa_modify_call_arguments): Narrow special
handling of debug insns to debug bind insns.
* ipa-split.c (split_function): Likewise.
* ira.c (combine_and_move_insns): Adjust debug bind insns only.
* loop-unroll.c (apply_opt_in_copies): Adjust tests on bind
debug insns.
* reg-stack.c (convert_regs_1): Use DEBUG_BIND_INSN_P.
* regrename.c (build_def_use): Likewise.
* regcprop.c (copyprop_hardreg_forward_1): Likewise.
(pass_cprop_hardreg): Narrow special casing of debug insns to
debug bind insns.
* regstat.c (regstat_init_n_sets_and_refs): Likewise.
* reload1.c (reload): Likewise.
* sese.c (sese_build_liveouts): Narrow special casing of debug
stmts to debug bind stmts.
* shrink-wrap.c (move_insn_for_shrink_wrap): Likewise.
* ssa-iterators.h (num_imm_uses): Likewise.
* tree-cfg.c (gimple_merge_blocks): Narrow special casing of
debug stmts to debug bind stmts.
* tree-inline.c (tree_function_versioning): Narrow special casing
of debug stmts to debug bind stmts.
* tree-loop-distribution.c (generate_loops_for_partition):
Narrow special casing of debug stmts to debug bind stmts.
* tree-sra.c (analyze_access_subtree): Narrow special casing
of debug stmts to debug bind stmts.
* tree-ssa-dce.c (remove_dead_stmt): Narrow special casing of debug
stmts to debug bind stmts.
* tree-ssa-loop-ivopt.c (remove_unused_ivs): Narrow special
casing of debug stmts to debug bind stmts.
* tree-ssa-reassoc.c (reassoc_remove_stmt): Likewise.
* tree-ssa-tail-merge.c (tail_merge_optimize): Narrow special
casing of debug stmts to debug bind stmts.
* tree-ssa-threadedge.c (propagate_threaded_block_debug_info):
Likewise.
* tree-ssa.c (flush_pending_stmts): Narrow special casing of
debug stmts to debug bind stmts.
(gimple_replace_ssa_lhs): Likewise.
(insert_debug_temp_for_var_def): Likewise.
(insert_debug_temps_for_defs): Likewise.
(reset_debug_uses): Likewise.
* tree-ssanames.c (release_ssa_name_fn): Likewise.
* tree-vect-loop-manip.c (adjust_debug_stmts_now): Likewise.
(adjust_debug_stmts): Likewise.
(adjust_phi_and_debug_stmts): Likewise.
(vect_do_peeling): Likewise.
* tree-vect-loop.c (vect_transform_loop): Like

[PATCH 4/9] [SFN] introduce statement frontier notes, still disabled

2017-09-30 Thread Alexandre Oliva
This patch completes the infrastructure for the introduction of
statement frontiers in C-family languages.

It brings in all the code remaining code needed to introduce and
transform begin stmt trees, gimple stmts, insns and notes, and
ultimately use them to generate the is_stmt column in DWARF2+ line
number tables/programs, however none of it is activated: the option
that would do so will be introduced in a subsequent patch.

This patch depends on an earlier patch with not-quite-boilerplate
changes towards SFN.

for  gcc/c-family/ChangeLog

* c-semantics.c (pop_stmt_list): Move begin stmt marker into
subsequent statement list.

for  gcc/c/ChangeLog

* c-objc-common.h (LANG_HOOKS_EMITS_BEGIN_STMT): Redefine as true.
* c-parser.c (add_debug_begin_stmt): New.
(c_parser_declaration_or_fndef): Call it.
(c_parser_compound_statement_nostart): Likewise.
(c_parser_statement_after_labels): Likewise.
* c-typeck (c_finish_stmt_expr): Skip begin stmts markers.

for  gcc/cp/ChangeLog

* constexpr.c (build_data_member_initialization): Skip begin stmt
markers.
(check_constexpr_ctor_body_1): Likewise.
(build_constexpr_constructor_member_initializers): Likewise.
(constexpr_fn_retval): Likewise.
(cxx_eval_statement_list): Likewise.
(potential_constant_expression_1): Likewise.
* cp-array-notation.c (stmt_location): New.
(cp_expand_cond_array_notations): Use it.
* cp-objcp-common.h (LANG_HOOKS_EMITS_BEGIN_STMT): Redefine as true.
* parser.c (add_debug_begin_stmt): New.
(cp_parser_statement): Call it.
* pt.c (tsubst_copy): Handle begin stmt markers.

for  gcc/ChangeLog

* cfgexpand.c (expand_gimple_basic_block): Handle begin stmt
markers.  Integrate source bind into debug stmt expand loop.
(pass_expand::execute): Check debug marker limit.  Avoid deep
TER and expand debug locations for debug bind insns only.
* cse.c (insn_live_p): Keep nonbind markers and debug bindings
followed by them.
* df-scan.c (df_insn_delete): Accept out-of-block debug insn.
* final.c (reemit_insn_block_notes): Take current block from
nonbind markers.  Declare note where it's first set.
(final_scan_insn): Handle begin stmt notes.  Emit is_stmt according to
begin stmt markers if enabled.
(notice_source_line): Handle nonbind markers.  Fail if their
location is unknown or that of builtins.
(rest_of_handle_final): Convert begin stmt markers to notes if
var-tracking didn't run.
(rest_of_clean_state): Skip begin stmt markers.
* gimple-pretty-print.c (dump_gimple_debug): Handle begin stmt
markers.
* function.c (allocate_struct_function): Set begin_stmt_markers.
* function.h (struct function): Add debug_marker_count counter
and debug_nonbind_markers flag.
* gimple-iterator.c (gsi_remove): Adjust debug_marker_count.
* gimple-low.c (lower_function_body): Adjust
debug_nonbind_markers.
(lower_stmt): Drop or skip gimple debug stmts.
(lower_try_catch): Skip debug stmts.
* gimple.c (gimple_build_debug_begin_stmt): New.
(gimple_copy): Increment debug_marker_count if copying one.
* gimple.h (gimple_build_debug_begin_stmt): Declare.
* gimplify.c (rexpr_location): New.
(rexpr_has_location): New.
(warn_switch_unreachable_r): Handle gimple debug stmts.
(shortcut_cond_r): Call expr_location.
(find_goto): New.
(find_goto_label): New.
(shortcut_cond_expr): Call expr_has_location, expr_location, and
find_goto_label.
(gimplify_cond_expr): Call find_goto_label, expr_has_location, and
expr_location.
(gimplify_expr): Handle begin stmt markers.  Reject debug expr decls.
* langhooks-def.h (LANG_HOOKS_EMITS_BEGIN_STMT): New.  Add to...
(LANG_HOOKS_INITIALIZER): ... this.
* langhooks.h (struct lang_hooks): Add emits_begin_stmt.
* lra-contraints.c (inherit_reload_reg): Tolerate between-blocks
debug insns.
(update_ebb_live_info): Skip debug insn markers.
* lra.c (debug_insn_static_data): Rename to...
(debug_bind_static_data): ... this.
(debug_marker_static_data): New.
(lra_set_insn_recog_data): Select one of the above depending
on debug insn kind.
(lra_update_isn_regno_info): Don't assume debug insns have
freqs.
(push_insns): Skip debug insns.
* lto-streamer-in.c (input_function): Drop debug stmts
depending on active options.  Adjust debug_nonbind_markers.
* params.def (PARAM_MAX_DEBUG_MARKER_COUNT): New.
* print-rtl.c (rtx_writer::print_rtx_operand_code_0): Handle
begin stmt marker notes.
(print_insn): Likewise.
* recog.c (extract_insn): Recogn

[PATCH 6/9] [LVU] Allow final_start_function to skip initial insns

2017-09-30 Thread Alexandre Oliva
This API change will enable final_start_function() to "consume"
initial insns, and choose the first insn to be passed to final().

Many ports call final_start_function() and final() when creating
thunks and whatnot, so they needed adjusting.

for  gcc/ChangeLog

* output.h (final_start_function): Adjust.
* final.c (final_start_function): Take pointer to FIRST.
(rest_of_handle_final): Adjust.
* config/aarch64/aarch64.c (aarch64_output_mi_thunk): Adjust.
* config/alpha/alpha.c (alpha_output_mi_thunk_osf): Likewise.
* config/arm/arm.c (arm_thumb1_mi_thunk): Likewise.
(arm32_output_mi_thunk): Likewise.
* config/cris/cris.c (cris_asm_output_mi_thunk): Likewise.
* config/i386/i386.c (ix86_code_end): Likewise.
(x86_output_mi_thunk): Likewise.
* config/ia64/ia64.c (ia64_output_mi_thunk): Likewise.
* config/m68k/m68k.c (m68k_output_mi_thunk): Likewise.
* config/microblaze/microblaze.c (microblaze_asm_output_mi_thunk):
Likewise.
* config/mips/mips.c (mips_output_mi_thunk): Likewise.
* config/nds32/nds32.c (nds32_asm_output_mi_thunk): Likewise.
* config/nios2/nios2.c (nios2_asm_output_mi_thunk): Likewise.
* config/pa/pa.c (pa_asm_output_mi_thunk): Likewise.
* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise.
(rs6000_code_end): Likewise.
* config/s390/s390.c (s390_output_mi_thunk): Likewise.
* config/sh/sh.c (sh_output_mi_thunk): Likewise.
* config/sparc/sparc.c (sparc_output_mi_thunk): Likewise.
* config/spu/spu.c (spu_output_mi_thunk): Likewise.
* config/tilegx/tilegx.c (tilegx_output_mi_thunk): Likewise.
* config/tilepro/tilepro.c (tilepro_asm_output_mi_thunk): Likewise.
---
 gcc/config/aarch64/aarch64.c   | 2 +-
 gcc/config/alpha/alpha.c   | 2 +-
 gcc/config/arm/arm.c   | 5 +++--
 gcc/config/cris/cris.c | 3 ++-
 gcc/config/i386/i386.c | 5 +++--
 gcc/config/ia64/ia64.c | 2 +-
 gcc/config/m68k/m68k.c | 2 +-
 gcc/config/microblaze/microblaze.c | 2 +-
 gcc/config/mips/mips.c | 2 +-
 gcc/config/nds32/nds32.c   | 3 ++-
 gcc/config/nios2/nios2.c   | 2 +-
 gcc/config/pa/pa.c | 3 ++-
 gcc/config/rs6000/rs6000.c | 5 +++--
 gcc/config/s390/s390.c | 3 ++-
 gcc/config/sh/sh.c | 2 +-
 gcc/config/sparc/sparc.c   | 2 +-
 gcc/config/spu/spu.c   | 3 ++-
 gcc/config/tilegx/tilegx.c | 2 +-
 gcc/config/tilepro/tilepro.c   | 2 +-
 gcc/final.c| 9 ++---
 gcc/output.h   | 2 +-
 21 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 23f5aff..73872dd 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3961,7 +3961,7 @@ aarch64_output_mi_thunk (FILE *file, tree thunk 
ATTRIBUTE_UNUSED,
 
   insn = get_insns ();
   shorten_branches (insn);
-  final_start_function (insn, file, 1);
+  final_start_function (&insn, file, 1);
   final (insn, file, 1);
   final_end_function ();
 
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 41f3e3a..56b6f04 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -8480,7 +8480,7 @@ alpha_output_mi_thunk_osf (FILE *file, tree thunk_fndecl 
ATTRIBUTE_UNUSED,
  assemble_start_function and assemble_end_function.  */
   insn = get_insns ();
   shorten_branches (insn);
-  final_start_function (insn, file, 1);
+  final_start_function (&insn, file, 1);
   final (insn, file, 1);
   final_end_function ();
 }
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4cddf3b..9301d58 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -26410,7 +26410,8 @@ arm_thumb1_mi_thunk (FILE *file, tree, HOST_WIDE_INT 
delta,
   if (mi_delta < 0)
 mi_delta = - mi_delta;
 
-  final_start_function (emit_barrier (), file, 1);
+  rtx_insn *first = emit_barrier ();
+  final_start_function (&first, file, 1);
 
   if (TARGET_THUMB1)
 {
@@ -26587,7 +26588,7 @@ arm32_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT 
delta,
 
   insn = get_insns ();
   shorten_branches (insn);
-  final_start_function (insn, file, 1);
+  final_start_function (&insn, file, 1);
   final (insn, file, 1);
   final_end_function ();
 
diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index fe80a27..3581d2d 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -2755,7 +2755,8 @@ cris_asm_output_mi_thunk (FILE *stream,
  tree funcdecl)
 {
   /* Make sure unwind info is emitted for the thunk if needed.  */
-  final_start_function (emit_barrier (), stream, 1);
+  rtx_insn *first = emit_barrier ();
+  final_start_function (&first, stream, 1);
 
   if (delta > 0)
 fprintf (stream, "\tadd%s " HOST_WIDE_INT_PRINT_

[PATCH 3/9] [SFN] not-quite-boilerplate changes in preparation to introduce nonbind markers

2017-09-30 Thread Alexandre Oliva
This patch adjusts numerous parts of the compiler that would
malfunction should they find debug markers at points where they may be
introduced.  The changes purport to allow the compiler to pass
bootstrap-debug-lean (-fcompare-debug in stage3) at various
optimization levels, as well as bootstrap-debug-lib (-fcompare-debug
for target libraries), even after the compiler is changed so that
debug markers are introduced in code streams at spots where earlier
debug stmts, insns and notes wouldn't normally appear.

This patch depends on an earlier SFN boilerplate patch, and on another
SFN patch that introduces new RTL insn-walking functions.

for  gcc/ChangeLog

* cfgcleanup.c (delete_unreachable_blocks): Use alternate
block removal order if MAY_HAVE_DEBUG_BIND_INSNS.
* cfgexpand.c (label_rtx_for_bb): Skip debug insns.
* cfgrtl.c (try_redirect_by_replacing_jump): Skip debug insns.
(rtl_tidy_fallthru_edge): Likewise.
(rtl_verify_fallthru): Likewise.
(rtl_verify_bb_layout): Likewise.
(skip_insns_after_block): Likewise.
(duplicate_insn_chain): Use DEBUG_BIND_INSN_P.
* dwarf2out.c: Include print-rtl.h.
(dwarf2out_next_real_insn): New.
(dwarf2out_var_location): Call it.  Disregard begin stmt markers.
Dump debug binds in asm comments.
* gimple-iterator.c (gimple_find_edge_insert_loc): Skip debug stmts.
* gimple-iterator.h (gsi_start_bb_nondebug): Remove; adjust
callers to use gsi_start_nondebug_bb instead.
(gsi_after_labels): Skip gimple debug stmts.
(gsi_start_nondebug): New.
* gimple-low.c (gimple_seq_may_fallthru): Take last nondebug stmt.
* gimple.h (gimple_seq_last_nondebug_stmt): New.
* gimplify.c (last_stmt_in_scope): Skip debug stmts.
(collect_fallthrough_labels): Likewise.
(should_warn_for_implicit_fallthrough): Likewise.
(warn_implicit_fallthrough_r): Likewise.
(expand_FALLTHROUGH_r): Likewise.
* graphite-isl-ast-to-gimple.c (gsi_insert_earliest): Adjust.
(rename_uses): Skip nonbind markers.
* graphite-scop-detection.c (trivially_empty_bb_p): Call
is_gimple_debug in test.
* haifa-sched.c (sched_extend_bb): Skip debug insns.
* ipa-icf-gimple.c (func_checker::compare_bb): Adjust.
* jump.c (clean_barriers): Skip debug insns.
* omp-expand.c (expand_parallel_call): Skip debug insns.
(expand_cilk_for_call): Likewise.
(expand_task_call): Likewise.
(remove_exit_barrier): Likewise.
(expand_omp_taskreg): Likewise.
(expand_omp_for_init_counts): Likewise.
(expand_omp_for_generic): Likewise.
(expand_omp_for_static_nochunk): Likewise.
(expand_omp_for_static_chunk): Likewise.
(expand_cilk_for): Likewise.
(expand_omp_simd): Likewise.
(expand_omp_taskloop_for_outer): Likewise.
(expand_omp_taskloop_for_inner): Likewise.
(expand_oacc_for): Likewise.
(expand_omp_sections): Likewise.
(expand_omp_single): Likewise.
(expand_omp_synch): Likewise.
(expand_omp_atomic_load): Likewise.
(expand_omp_atomic_store): Likewise.
(expand_omp_atomic_fetch_op): Likewise.
(expand_omp_atomic_pipeline): Likewise.
(expand_omp_atomic_mutex): Likewise.
(expand_omp_target): Likewise.
(grid_expand_omp_for_loop): Likewise.
(grid_expand_target_grid_body): Likewise.
(build_omp_regions_1): Likewise.
* omp-low.c (check_combined_parallel): Skip debug stmts.
* postreload.c (fixup_debug_insns): Skip nonbind debug insns.
* regcprop.c (find_oldest_value_reg): Ensure REGNO is not a pseudo.
* tree-cfg.c (make_blobs_1): Skip debug stmts.
(make_edges): Likewise.
(cleanup_dead_labels): Likewise.
(gimple_can_merge_blocks_p): Likewise.
(stmt_starts_bb_p): Likewise.
(gimple_block_label): Likewise.
(gimple_redirect_edge_and_branch): Likewise.
* tree-cfgcleanup.c (remove_forwarder_block): Rearrange skipping
of debug stmts.
(execute_cleanup_cfg_post_optimizing): Dump enumerated decls with
TDF_SLIM.
* tree-pretty-print (print_declaration): Omit initializer in slim
dumps.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Mark begin stmt
markers.
(eliminate_unnecessary_stmts): Stabilize block removal order.
* tree-ssa-tail-merge.c (find_duplicate): Skip debug stmts.
* var-tracking.c (get_first_insn): New.
(vt_emit_notes): Call it.
(vt_initialize): Walk any insns before the first BB.
(delete_debug_insns): Likewise.
---
 gcc/cfgbuild.c   |   1 +
 gcc/cfgcleanup.c |  12 +--
 gcc/cfgexpand.c  |  24 +-
 gcc/cfgrtl.c |  18 +++--
 gcc/dwarf2out.c  |  3

[PATCH 8/9] [IEPM] Introduce debug hook for inline entry point markers

2017-09-30 Thread Alexandre Oliva
The inline_entry hook will be given a definition in a later patch.

for  gcc/ChangeLog

* debug.h (gcc_debug_hooks): Add inline_entry.
* dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise.
* debug.c (do_nothing_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
* dwarf2out.c (dwarf2_debug_hooks): Likewise.
(dwarf2_lineno_debug_hooks): Likewise.
---
 gcc/dbxout.c| 2 ++
 gcc/debug.c | 1 +
 gcc/debug.h | 3 +++
 gcc/dwarf2out.c | 2 ++
 gcc/sdbout.c| 1 +
 gcc/vmsdbgout.c | 1 +
 6 files changed, 10 insertions(+)

diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index ea7c97c..6ba0471 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -379,6 +379,7 @@ const struct gcc_debug_hooks dbx_debug_hooks =
   debug_nothing_rtx_code_label, /* label */
   dbxout_handle_pch,/* handle_pch */
   debug_nothing_rtx_insn,   /* var_location */
+  debug_nothing_tree,   /* inline_entry */
   debug_nothing_tree,   /* size_function */
   debug_nothing_void,/* switch_text_section */
   debug_nothing_tree_tree,  /* set_name */
@@ -421,6 +422,7 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
   debug_nothing_rtx_code_label, /* label */
   dbxout_handle_pch,/* handle_pch */
   debug_nothing_rtx_insn,   /* var_location */
+  debug_nothing_tree,   /* inline_entry */
   debug_nothing_tree,   /* size_function */
   debug_nothing_void,/* switch_text_section */
   debug_nothing_tree_tree,  /* set_name */
diff --git a/gcc/debug.c b/gcc/debug.c
index 4db94c3..c0bc667 100644
--- a/gcc/debug.c
+++ b/gcc/debug.c
@@ -55,6 +55,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
   debug_nothing_rtx_code_label, /* label */
   debug_nothing_int,/* handle_pch */
   debug_nothing_rtx_insn,   /* var_location */
+  debug_nothing_tree,   /* inline_entry */
   debug_nothing_tree,   /* size_function */
   debug_nothing_void,/* switch_text_section */
   debug_nothing_tree_tree,  /* set_name */
diff --git a/gcc/debug.h b/gcc/debug.h
index 915420b..8c888b6 100644
--- a/gcc/debug.h
+++ b/gcc/debug.h
@@ -176,6 +176,9 @@ struct gcc_debug_hooks
   /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note.  */
   void (* var_location) (rtx_insn *);
 
+  /* Called from final_scan_insn for any NOTE_INSN_INLINE_ENTRY note.  */
+  void (* inline_entry) (tree block);
+
   /* Called from finalize_size_functions for size functions so that their body
  can be encoded in the debug info to describe the layout of variable-length
  structures.  */
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6b19c4a..f435b5a 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -2773,6 +2773,7 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
   debug_nothing_rtx_code_label,/* label */
   debug_nothing_int,   /* handle_pch */
   dwarf2out_var_location,
+  debug_nothing_tree,  /* inline_entry */
   dwarf2out_size_function, /* size_function */
   dwarf2out_switch_text_section,
   dwarf2out_set_name,
@@ -2813,6 +2814,7 @@ const struct gcc_debug_hooks dwarf2_lineno_debug_hooks =
   debug_nothing_rtx_code_label, /* label */
   debug_nothing_int,/* handle_pch */
   debug_nothing_rtx_insn,   /* var_location */
+  debug_nothing_tree,   /* inline_entry */
   debug_nothing_tree,   /* size_function */
   debug_nothing_void,/* switch_text_section */
   debug_nothing_tree_tree,  /* set_name */
diff --git a/gcc/sdbout.c b/gcc/sdbout.c
index acd25a3..ba64432 100644
--- a/gcc/sdbout.c
+++ b/gcc/sdbout.c
@@ -309,6 +309,7 @@ const struct gcc_debug_hooks sdb_debug_hooks =
   sdbout_label, /* label */
   debug_nothing_int,/* handle_pch */
   debug_nothing_rtx_insn,   /* var_location */
+  debug_nothing_tree,   /* inline_entry */
   debug_nothing_tree,   /* size_function */
   debug_nothing_void,/* switch_text_section */
   debug_nothing_tree_tree,  /* set_name */
diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
index 580dd28..83ba2ae 100644
--- a/gcc/vmsdbgout.c
+++ b/gcc/vmsdbgout.c
@@ -205,6 +205,7 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks
debug_nothing_rtx_code_label,  /* label */
debug_nothing_int,/* handle_pch */
debug_nothing_rtx_insn,   /* var_location */
+   debug_nothing_tree,   /* inline_entry */
debug_nothing_tree,   /* size_function */
debug_nothing_void,/* switch_text_section */
 

[PATCH 7/9] [LVU] Introduce location views

2017-09-30 Thread Alexandre Oliva
This patch introduces an option to enable the generation of location
views along with location lists.  The exact format depends on the
DWARF version: it can be a separate attribute (DW_AT_GNU_locviews) or
(DW_LLE_view_pair) entries in DWARF5+ loclists.

Line number tables are also affected.  If the assembler is found, at
compiler build time, to support .loc views, we use them and
assembler-computed view labels, otherwise we output compiler-generated
line number programs with conservatively-computed view labels.  In
either case, we output view information next to line number changes
when verbose assembly output is requested.

This patch requires an LVU patch that modifies the exported API of
final_scan_insn.  It also expects the entire SFN patchset to be
installed first, although SFN is not a requirement for LVU.

for  include/ChangeLog

* dwarf2.def (DW_AT_GNU_locviews): New.
* dwarf2.h (enum dwarf_location_list_entry_type): Add
DW_LLE_GNU_view_pair.
(DW_LLE_view_pair): Define.

for  gcc/ChangeLog

* common.opt (gvariable-location-views): New.
* config.in: Rebuilt.
* configure: Rebuilt.
* configure.ac: Test assembler for view support.
* dwarf2asm.c (dw2_asm_output_symname_uleb128): New.
* dwarf2asm.h (dw2_asm_output_symname_uleb128): Declare.
* dwarf2out.c (var_loc_view): New typedef.
(struct dw_loc_list_struct): Add vl_symbol, vbegin, vend.
(dwarf2out_locviews_in_attribute): New.
(dwarf2out_locviews_in_loclist): New.
(dw_val_equal_p): Compare val_view_list of dw_val_class_view_lists.
(enum dw_line_info_opcode): Add LI_adv_address.
(struct dw_line_info_table): Add view.
(RESET_NEXT_VIEW, RESETTING_VIEW_P): New macros.
(DWARF2_ASM_VIEW_DEBUG_INFO): Define default.
(zero_view_p): New variable.
(ZERO_VIEW_P): New macro.
(output_asm_line_debug_info): New.
(struct var_loc_node): Add view.
(add_AT_view_list, AT_loc_list): New.
(add_var_loc_to_decl): Add view param.  Test it against last.
(new_loc_list): Add view params.  Record them.
(AT_loc_list_ptr): Handle loc and view lists.
(view_list_to_loc_list_val_node): New.
(print_dw_val): Handle dw_val_class_view_list.
(size_of_die): Likewise.
(value_format): Likewise.
(loc_list_has_views): New.
(gen_llsym): Set vl_symbol too.
(maybe_gen_llsym, skip_loc_list_entry): New.
(dwarf2out_maybe_output_loclist_view_pair): New.
(output_loc_list): Output view list or entries too.
(output_view_list_offset): New.
(output_die): Handle dw_val_class_view_list.
(output_dwarf_version): New.
(output_compilation_unit_header): Use it.
(output_skeleton_debug_sections): Likewise.
(output_rnglists, output_line_info): Likewise.
(output_pubnames, output_aranges): Update version comments.
(output_one_line_info_table): Output view numbers in asm comments.
(dw_loc_list): Determine current endview, pass it to new_loc_list.
Call maybe_gen_llsym.
(loc_list_from_tree_1): Adjust.
(add_AT_location_description): Create view list attribute if
needed, check it's absent otherwise.
(convert_cfa_to_fb_loc_list): Adjust.
(maybe_emit_file): Call output_asm_line_debug_info for test.
(dwarf2out_var_location): Reset views as needed.  Precompute
add_var_loc_to_decl args.  Call get_attr_min_length only if we have the
attribute.  Set view.
(new_line_info_table): Reset next view.
(set_cur_line_info_table): Call output_asm_line_debug_info for test.
(dwarf2out_source_line): Likewise.  Output view resets and labels to
the assembler, or select appropriate line info opcodes.
(prune_unused_types_walk_attribs): Handle dw_val_class_view_list.
(optimize_string_length): Catch it.  Adjust.
(resolve_addr): Copy vl_symbol along with ll_symbol.  Handle
dw_val_class_view_list, and remove it if no longer needed.
(hash_loc_list): Hash view numbers.
(loc_list_hasher::equal): Compare them.
(optimize_location_lists): Check whether a view list symbol is
needed, and whether the locview attribute is present, and
whether they match.  Remove the locview attribute if no longer
needed.
(index_location_lists): Call skip_loc_list_entry for test.
(dwarf2out_finish): Call output_asm_line_debug_info for test.
Use output_dwarf_version.
* dwarf2out.h (enum dw_val_class): Add dw_val_class_view_list.
(struct dw_val_node): Add val_view_list.
* final.c: Include langhooks.h.
(SEEN_NEXT_VIEW): New.
(set_next_view_needed): New.
(clear_next_view_needed): New.
(maybe_output_next_view): New.
(final_start_function): Rename to...
(fi

[PATCH 9/9] [IEPM] Introduce inline entry point markers

2017-09-30 Thread Alexandre Oliva
Output DW_AT_entry_pc based on markers.

Introduce DW_AT_GNU_entry_view as a DWARF extension.

If views are enabled are we're not in strict compliance mode, output
DW_AT_GNU_entry_view if it might be nonzero.

This patch depends on SFN and LVU patchsets, and on the IEPM patch that
introduces the inline_entry debug hook.

for  include/ChangeLog

* dwarf2.def (DW_AT_GNU_entry_view): New.

for  gcc/ChangeLog

* cfgexpand.c (expand_gimple_basic_block): Handle inline entry
markers.
* dwarf2out.c (dwarf2_debug_hooks): Enable inline_entry hook.
(BLOCK_INLINE_ENTRY_LABEL): New.
(dwarf2out_var_location): Disregard inline entry markers.
(inline_entry_data): New struct.
(inline_entry_data_hasher): New hashtable type.
(inline_entry_data_hasher::hash): New.
(inline_entry_data_hasher::equal): New.
(inline_entry_data_table): New variable.
(add_high_low_attributes): Add DW_AT_entry_pc and
DW_AT_GNU_entry_view attributes if a pending entry is found
in inline_entry_data_table.  Add old entry_pc attribute only
if debug nonbinding markers are disabled.
(gen_inlined_subroutine_die): Set BLOCK_DIE if nonbinding
markers are enabled.
(block_within_block_p, dwarf2out_inline_entry): New.
(dwarf2out_finish): Check that no entries remained in
inline_entry_data_table.
* final.c (reemit_insn_block_notes): Handle inline entry notes.
(final_scan_insn, notice_source_line): Likewise.
(rest_of_clean_state): Skip inline entry markers.
* gimple-pretty-print.c (dump_gimple_debug): Handle inline entry
markers.
* gimple.c (gimple_build_debug_inline_entry): New.
* gimple.h (enum gimple_debug_subcode): Add
GIMPLE_DEBUG_INLINE_ENTRY.
(gimple_build_debug_inline_entry): Declare.
(gimple_debug_inline_entry_p): New.
(gimple_debug_nonbind_marker_p): Adjust.
* insn-notes.def (INLINE_ENTRY): New.
* print-rtl.c (rtx_writer::print_rtx_operand_code_0): Handle
inline entry marker notes.
(print_insn): Likewise.
* rtl.h (NOTE_MARKER_P): Add INLINE_ENTRY support.
(INSN_DEBUG_MARKER_KIND): Likewise.
* tree-inline.c (expand_call_inline): Build and insert
debug_inline_entry stmt.
* tree-ssa-live.c (remove_unused_scope_block_p): Preserve
inline entry blocks early, if nonbind markers are enabled.
(dump_scope_block): Dump fragment info.
* var-tracking.c (reemit_marker_as_note): Handle inline entry note.
* doc/gimple.texi (gimple_debug_inline_entry_p): New.
(gimple_build_debug_inline_entry): New.
* doc/invoke.texi (gstatement-frontiers, gno-statement-frontiers):
Enable/disable inline entry points too.
* doc/rtl.texi (NOTE_INSN_INLINE_ENTRY): New.
(DEBUG_INSN): Describe inline entry markers.
---
 gcc/cfgexpand.c   |   9 +++
 gcc/doc/gimple.texi   |  18 +
 gcc/doc/rtl.texi  |  24 --
 gcc/dwarf2out.c   | 186 +-
 gcc/final.c   |  26 +++
 gcc/gimple-pretty-print.c |  13 
 gcc/gimple.c  |  21 ++
 gcc/gimple.h  |  18 -
 gcc/insn-notes.def|   4 +
 gcc/print-rtl.c   |   5 ++
 gcc/rtl.h |   5 +-
 gcc/tree-inline.c |   7 ++
 gcc/tree-ssa-live.c   |  27 +--
 gcc/var-tracking.c|   1 +
 include/dwarf2.def|   1 +
 15 files changed, 349 insertions(+), 16 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index c854ffd..8ccdafd 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -5691,6 +5691,15 @@ expand_gimple_basic_block (basic_block bb, bool 
disable_tail_calls)
goto delink_debug_stmt;
  else if (gimple_debug_begin_stmt_p (stmt))
val = gen_rtx_DEBUG_MARKER (VOIDmode);
+ else if (gimple_debug_inline_entry_p (stmt))
+   {
+ tree block = gimple_block (stmt);
+
+ if (block)
+   val = gen_rtx_DEBUG_MARKER (BLKmode);
+ else
+   goto delink_debug_stmt;
+   }
  else
gcc_unreachable ();
 
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 6c9c4789..af39d75 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -836,6 +836,11 @@ Return true if g is a @code{GIMPLE_DEBUG} that marks the 
beginning of
 a source statement.
 @end deftypefn
 
+@deftypefn {GIMPLE function} gimple_debug_inline_entry_p (gimple g)
+Return true if g is a @code{GIMPLE_DEBUG} that marks the entry
+point of an inlined function.
+@end deftypefn
+
 @deftypefn {GIMPLE function} gimple_debug_nonbind_marker_p (gimple g)
 Return true if g is a @code{GIMPLE_DEBUG} that marks a program location,
 without any variable binding.
@@ -1539,6 +15

Re: [PATCH gfortran v2] PR 61450: ICE in gfc_global_used()

2017-09-30 Thread Dominique d'Humières
As noticed by Thomas on IRC, the FX's patch may not be translator friendly. I 
have now tested the following

--- ../_clean/gcc/fortran/parse.c   2017-09-01 19:00:10.0 +0200
+++ gcc/fortran/parse.c 2017-09-28 17:55:14.0 +0200
@@ -5742,16 +5742,28 @@ gfc_global_used (gfc_gsymbol *sym, locus
   name = "MODULE";
   break;
 default:
-  gfc_internal_error ("gfc_global_used(): Bad type");
   name = NULL;
 }
 
-  if (sym->binding_label)
-gfc_error ("Global binding name %qs at %L is already being used as a %s "
-  "at %L", sym->binding_label, where, name, &sym->where);
+  if (name)
+{
+  if (sym->binding_label)
+   gfc_error ("Global binding name %qs at %L is already being used "
+  "as a %s at %L", sym->binding_label, where, name,
+  &sym->where);
+  else
+   gfc_error ("Global name %qs at %L is already being used as "
+  "a %s at %L", sym->name, where, name, &sym->where);
+}
   else
-gfc_error ("Global name %qs at %L is already being used as a %s at %L",
-  sym->name, where, name, &sym->where);
+{
+  if (sym->binding_label)
+   gfc_error ("Global binding name %qs at %L is already being used "
+  "at %L", sym->binding_label, where, &sym->where);
+  else
+   gfc_error ("Global name %qs at %L is already being used at %L",
+  sym->name, where, &sym->where);
+}
 }
 
 I have also tried to avoid the nested IFs following the Thomas’ suggestion to 
use

label = sym->binding_label ? sym->binding_label : sym->name;

but this does not handle "Global binding name "/"Global name ».

Dominique

> Le 24 sept. 2017 à 16:13, Dominique d'Humières  a écrit :
> 
> Rebased FX’s patch.
> 
> Tested on x86_64-apple-darwin16.Is it OK with the proper log entries added?
> 
> TIA
> 
> Dominique



Re: patch to fix PR81481

2017-09-30 Thread Vladimir Makarov



On 09/30/2017 04:15 AM, Richard Sandiford wrote:

Vladimir Makarov  writes:

The following patch fixes

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

The patch was bootstrapped and tested on x86-64.

Committed as rev. 253300.


Index: ira-costs.c
===
--- ira-costs.c (revision 253253)
+++ ira-costs.c (working copy)
@@ -1471,7 +1471,10 @@ scan_one_insn (rtx_insn *insn)
&& targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)),
  XEXP (note, 0))
&& REG_N_SETS (REGNO (SET_DEST (set))) == 1))
-  && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set
+  && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set)))
+  /* LRA does not use equiv with a symbol for PIC code.  */
+  && (! ira_use_lra_p || ! pic_offset_table_rtx
+ || ! contains_symbol_ref_p (XEXP (note, 0
   {
 enum reg_class cl = GENERAL_REGS;
 rtx reg = SET_DEST (set);

I don't think this is the right test for PICness.  Most targets have
an unconditional pic_offset_table_rtx.


Thank you, Richard, for checking the patch.

Yes, the test might be not right for PICness.  The actual patch goal was 
to sync IRA and LRA which uses the same code to analyze when an equiv 
can be used.  So if we need less conservative code, we should change the 
code in the both places.


[Patch, fortran] PR77296 - [F03] Compiler Error with allocatable string and associate

2017-09-30 Thread Paul Richard Thomas
The attached patch fixes the PR and most of the remaining, if not all,
problems associated with deferred string length targets in the
associate construct.

Bootstraps and regtests on FC23/x86_64 - OK for trunk?

Paul

2017-09-29  Paul Thomas  

PR fortran/77296
* resolve.c (resolve_assoc_var): Deferred character type
associate names must not receive an integer conatant length.
* symbol.c (gfc_is_associate_pointer): Deferred character
length functions also require an associate pointer.
* trans-decl.c (gfc_get_symbol_decl): Deferred character
length functions or derived type components require the assoc
name to have variable string length.
* trans-stmt.c (trans_associate_var): Set the string length of
deferred string length associate names. The address expression
is not needed for allocatable, pointer or dummy targets. Change
the comment about defered string length targets.

2017-09-29  Paul Thomas  

PR fortran/77296
* gfortran.dg/associate_32.f03 : New test.
Index: gcc/fortran/resolve.c
===
*** gcc/fortran/resolve.c   (revision 253101)
--- gcc/fortran/resolve.c   (working copy)
*** resolve_assoc_var (gfc_symbol* sym, bool
*** 8530,8536 
if (!sym->ts.u.cl)
sym->ts.u.cl = target->ts.u.cl;

!   if (!sym->ts.u.cl->length)
sym->ts.u.cl->length
  = gfc_get_int_expr (gfc_default_integer_kind,
  NULL, target->value.character.length);
--- 8530,8536 
if (!sym->ts.u.cl)
sym->ts.u.cl = target->ts.u.cl;

!   if (!sym->ts.u.cl->length && !sym->ts.deferred)
sym->ts.u.cl->length
  = gfc_get_int_expr (gfc_default_integer_kind,
  NULL, target->value.character.length);
Index: gcc/fortran/symbol.c
===
*** gcc/fortran/symbol.c(revision 253101)
--- gcc/fortran/symbol.c(working copy)
*** gfc_is_associate_pointer (gfc_symbol* sy
*** 5054,5059 
--- 5054,5065 
if (sym->ts.type == BT_CLASS)
  return true;

+   if (sym->ts.type == BT_CHARACTER
+   && sym->ts.deferred
+   && sym->assoc->target
+   && sym->assoc->target->expr_type == EXPR_FUNCTION)
+ return true;
+
if (!sym->assoc->variable)
  return false;

Index: gcc/fortran/trans-decl.c
===
*** gcc/fortran/trans-decl.c(revision 253101)
--- gcc/fortran/trans-decl.c(working copy)
*** gfc_get_symbol_decl (gfc_symbol * sym)
*** 1695,1700 
--- 1695,1708 
if (sym->ts.type == BT_CHARACTER)
  {
if (sym->attr.associate_var
+ && sym->ts.deferred
+ && sym->assoc && sym->assoc->target
+ && ((sym->assoc->target->expr_type == EXPR_VARIABLE
+  && sym->assoc->target->symtree->n.sym->ts.type != BT_CHARACTER)
+ || sym->assoc->target->expr_type == EXPR_FUNCTION))
+   sym->ts.u.cl->backend_decl = NULL_TREE;
+
+   if (sym->attr.associate_var
  && sym->ts.u.cl->backend_decl
  && VAR_P (sym->ts.u.cl->backend_decl))
length = gfc_index_zero_node;
Index: gcc/fortran/trans-stmt.c
===
*** gcc/fortran/trans-stmt.c(revision 253101)
--- gcc/fortran/trans-stmt.c(working copy)
*** trans_associate_var (gfc_symbol *sym, gf
*** 1533,1538 
--- 1533,1539 
bool need_len_assign;
bool whole_array = true;
gfc_ref *ref;
+   symbol_attribute attr;

gcc_assert (sym->assoc);
e = sym->assoc->target;
*** trans_associate_var (gfc_symbol *sym, gf
*** 1592,1597 
--- 1593,1609 

gfc_conv_expr_descriptor (&se, e);

+   if (sym->ts.type == BT_CHARACTER
+ && sym->ts.deferred
+ && !sym->attr.select_type_temporary
+ && VAR_P (sym->ts.u.cl->backend_decl)
+ && se.string_length != sym->ts.u.cl->backend_decl)
+   {
+ gfc_add_modify (&se.pre, sym->ts.u.cl->backend_decl,
+ fold_convert (gfc_charlen_type_node,
+   se.string_length));
+   }
+
/* If we didn't already do the pointer assignment, set associate-name
 descriptor to the one generated for the temporary.  */
if ((!sym->assoc->variable && !cst_array_ctor)
*** trans_associate_var (gfc_symbol *sym, gf
*** 1758,1765 
  need_len_assign = need_len_assign && sym->ts.type == BT_CHARACTER;
}

!   tmp = TREE_TYPE (sym->backend_decl);
!   tmp = gfc_build_addr_expr (tmp, se.expr);
gfc_add_modify (&se.pre, sym->backend_decl, tmp);

gfc_add_init_cleanup (block, gfc_finish_block( &se.pre),
--- 1770,1804 
  need_len_assign = need_len_assign && sym->ts.type == BT_CHARACTER;
}

Re: isl scheduler and spatial locality (Re: [PATCH][GRAPHITE] More TLC)

2017-09-30 Thread Richard Biener
On September 29, 2017 9:58:41 PM GMT+02:00, Sebastian Pop  
wrote:
>On Fri, Sep 29, 2017 at 2:37 PM, Sven Verdoolaege
> wrote:
>> [Sorry for the resend; I used the wrong email address to CC Alex]
>>
>> On Wed, Sep 27, 2017 at 02:18:51PM +0200, Richard Biener wrote:
>>> Ah, so I now see why we do not perform interchange on trivial cases
>like
>>>
>>> double A[1024][1024], B[1024][1024];
>>>
>>> void foo(void)
>>> {
>>>   for (int i = 0; i < 1024; ++i)
>>> for (int j = 0; j < 1024; ++j)
>>>   A[j][i] = B[j][i];
>>> }
>>
>> I didn't see you mentioning _why_ you expect an interchange here.
>> Are you prehaps interested in spatial locality?
>> If so, then there are several approaches for taking
>> that into account.
>> - pluto performs an intra-tile loop interchange to
>>   improve temporal and/or spatial locality.  It shouldn't
>>   be too hard to do something similar on an isl generated
>>   schedule
>> - Alex (Oleksandr) has been working on an extension of
>>   the isl scheduler that takes into account spatial locality.
>>   I'm not sure if it's publicly available.
>> - I've been working on a special case of spatial locality
>>   (consecutivity).  The current version is available in
>>   the consecutivity branch.  Note that it may get rebased and
>>   it may not necessarily get merged into master.
>>
>> There are also other approaches, but they may not be that
>> easy to combine with the isl scheduler.
>
>Would the following work?
>Add to the proximity relation the array accesses from two
>successive iterations of the innermost loop:
>A[j][i] -> A[j][i+1] and B[j][i] -> B[j][i+1]
>With these two extra relations in the proximity map,
>isl should be able to interchange the above loop.

Can anyone give a hint on how to do that in ISL terms? 

Richard. 

>Sebastian



Re: [PATCH] Add netbsd-stdint.h to several netbsd targets

2017-09-30 Thread Krister Walfridsson
On Sun, Sep 3, 2017 at 5:16 PM, Maya Rashish  wrote:
> grouping netbsd.h netbsd-stdint.h netbsd-elf.h as "nbsd_tm_file",
> similar to freebsd.

I found a small bug in the patch -- the NetBSD stdint.h have different
definitions for 8- and 16-bit "fast" types than what is in the
netbsd-stditn.h, so the vax-*-netbsdelf* need to work around that.
The patch is also missing to update m68k*-*-netbsdelf*.

I have fixed those two issues, and committed the attached patch.

   /Krister


r253323.patch
Description: Binary data


[PATCH] cpp: Correctly handle filenames with newlines

2017-09-30 Thread Rasmus Villemoes
2017-10-01  Rasmus Villemoes  

PR preprocessor/64965
* gcc.c-torture/compile/pr64965.c: New test.

If the current filename contains a newline character, __FILE__ would
expand to a string literal containing an actual embedded newline,
which is of course illegal. Similarly, even in the absence of __FILE__
in the source file, gcc -E produces broken #line directives, making
the preprocessed output unsuitable for subsequent processing (though
compiling directly does work). Fix it by also escaping newline
characters.

[I'm not sure supporting newlines in file names actually makes the
world a better place.]

Signed-off-by: Rasmus Villemoes 
---
 gcc/testsuite/gcc.c-torture/compile/pr64695.c |  2 ++
 libcpp/macro.c| 10 --
 2 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr64695.c

diff --git gcc/testsuite/gcc.c-torture/compile/pr64695.c 
gcc/testsuite/gcc.c-torture/compile/pr64695.c
new file mode 100644
index 000..f31a031377c
--- /dev/null
+++ gcc/testsuite/gcc.c-torture/compile/pr64695.c
@@ -0,0 +1,2 @@
+#line 1 "new\nline"
+const char f[] = __FILE__;
diff --git libcpp/macro.c libcpp/macro.c
index 147fcf53a88..ef0d766cc00 100644
--- libcpp/macro.c
+++ libcpp/macro.c
@@ -493,8 +493,9 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node,
 }
 
 /* Copies SRC, of length LEN, to DEST, adding backslashes before all
-   backslashes and double quotes. DEST must be of sufficient size.
-   Returns a pointer to the end of the string.  */
+   backslashes and double quotes, and replacing newline characters
+   with \n.  DEST must be of sufficient size.  Returns a pointer to
+   the end of the string.  */
 uchar *
 cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
 {
@@ -507,6 +508,11 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned 
int len)
  *dest++ = '\\';
  *dest++ = c;
}
+  else if (c == '\n')
+   {
+ *dest++ = '\\';
+ *dest++ = 'n';
+   }
   else
  *dest++ = c;
 }
-- 
2.11.0



Re: [PING][patch] PR81794: have "would be stringified in traditional C" warning in libcpp/macro.c be controlled by -Wtraditional

2017-09-30 Thread Eric Gallager
On Fri, Sep 29, 2017 at 11:15 AM, David Malcolm  wrote:
> On Sun, 2017-09-17 at 20:00 -0400, Eric Gallager wrote:
>> Attached is a version of
>> https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00481.html that
>> contains
>> a combination of both the fix and the testcase update, as requested
>> in
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81794#c2
>>
>> I had to use a different computer than I usually use to send this
>> email, as the hard drive that originally had this patch is currently
>> unresponsive. Since it's also the one with my ssh keys on it, I can't
>> commit with it. Sorry if the ChangeLogs get mangled.
>
> Thanks for putting this together; sorry about the delay in reviewing
> it.
>
> The patch mostly looks good.
>
> Did you perform a full bootstrap and run of the testsuite with this
> patch?  If so, it's best to state this in the email, so that we know
> that the patch has survived this level of testing.

Yes, I bootstrapped with it, but I haven't done a full run of the
testsuite with it yet; just the one testcase I updated.

>
> Some nits below:
>
>> libcpp/ChangeLog:
>>
>> 2017-03-24  Eric Gallager  
>>
>>  * macro.c (check_trad_stringification): Have warning be
>> controlled by
>>  -Wtraditional.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2017-09-17  Eric Gallager  
>>
>> PR preprocessor/81794
>> * gcc.dg/pragma-diag-7.c: Update to include check for
>> stringification.
>>
>> On Sat, May 6, 2017 at 11:33 AM, Eric Gallager 
>> wrote:
>> > Pinging this: https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01325.h
>> > tml
>> >
>> > On 3/24/17, Eric Gallager  wrote:
>> > > It seemed odd to me that gcc was issuing a warning about
>> > > compatibility
>> > > with traditional C that I couldn't turn off by pushing/popping
>> > > -Wtraditional over the problem area, so I made the attached
>> > > (minor)
>> > > patch to fix it. Survives bootstrap, but the only testing I've
>> > > done
>> > > with it has been compiling the one file that was giving me issues
>> > > previously, which I'd need to reduce further to turn it into a
>> > > proper
>> > > test case.
>> > >
>> > > Thanks,
>> > > Eric Gallager
>> > >
>> > > libcpp/ChangeLog:
>> > >
>> > > 2017-03-24  Eric Gallager  
>> > >
>> > >   * macro.c (check_trad_stringification): Have warning be
>> > > controlled by
>> > >   -Wtraditional.
>> > >
>> >
>> > So I did the reducing I mentioned above and now have a testcase for
>> > it; it was pretty similar to the one from here:
>> > https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01319.html
>> > so I combined them into a single testcase and have attached the
>> > combined version. I can confirm that the testcase passes with my
>> > patch
>> > applied.
>
> [...]
>
>> diff --git a/gcc/testsuite/gcc.dg/pragma-diag-7.c 
>> b/gcc/testsuite/gcc.dg/pragma-diag-7.c
>> index 402ee56..e06c410 100644
>> --- a/gcc/testsuite/gcc.dg/pragma-diag-7.c
>> +++ b/gcc/testsuite/gcc.dg/pragma-diag-7.c
>> @@ -7,3 +7,16 @@ unsigned long bad = 1UL; /* { dg-warning "suffix" } */
>>  /* Note the extra space before the pragma on this next line: */
>>   #pragma GCC diagnostic pop
>>  unsigned long ok_again = 2UL; /* { dg-bogus "suffix" } */
>> +
>> +/* Redundant with the previous pop, but just shows that it fails to stop the
>> + * following warning with an unpatched GCC: */
>> +#pragma GCC diagnostic ignored "-Wtraditional"
>> +
>> +/* { dg-bogus "would be stringified" .+1 } */
>
> As far as I can tell, this dg-bogus line doesn't actually get matched;
> when I run the testsuite without the libcpp fix, I get:
>
>   FAIL: gcc.dg/pragma-diag-7.c (test for excess errors)
>
> If I update the dg-bogus line to read:
>
>   /* { dg-bogus "would be stringified" "" { target *-*-* } .+1 } */
>
> then it's matched, and I get:
>
>   FAIL: gcc.dg/pragma-diag-7.c  (test for bogus messages, line 16)
>
> I believe that as written the ".+1" 2nd argument is interpreted as a
> human-readable description of the problem, rather than as a line
> offset; I believe you would need to add positional args for the
> description and filter so that the line offset is argument 4.
>
> That said, I think the dg-bogus here is unnecessary: if the warning is
> erroneously emitted, we get:
>
>   FAIL: gcc.dg/pragma-diag-7.c (test for excess errors)
>
> (where "errors" really means "excess errors, warnings and extraneous
> gunk that isn't a note").
>
> So this testcase hunk is good without the dg-bogus line.

OK, the line can be removed when committing.

>
>> +#define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \
>> +  do {  
>>  \
>> +  unw_rlen = rlen;  
>>  \
>> +  *(int *)arg = body;\
>> +  printf("%s:%s(rlen=%lu)\n",   
>>  \
>> + fmt, (body ? "body" : "prologue"), (unsigned long)rlen);   
>>  \
>> +  } while (0)
>> diff --git a/l

RE: [PING][PATCH][Aarch64] Improve int<->FP conversions

2017-09-30 Thread Michael Collison
Sorry. Here is the patch.

-Original Message-
From: James Greenhalgh [mailto:james.greenha...@arm.com] 
Sent: Friday, September 29, 2017 3:57 PM
To: Michael Collison 
Cc: GCC Patches ; nd 
Subject: Re: [PING][PATCH][Aarch64] Improve int<->FP conversions

On Fri, Sep 29, 2017 at 10:42:14PM +0100, Michael Collison wrote:
> Ping. Original patch posted here:
> 
> https://gcc.gnu.org/ml/gcc-patches/2017-09/msg00808.html

I don't see a patch attached there to review, nor can I see an earlier mail 
threaded to it with the patch attached. Can you help?

Thanks,
James



pr6527.patch
Description: pr6527.patch


[PATCH] Add anitizer_linux_x86_64.lo if __x86_64__ is defined by $CC

2017-09-30 Thread H.J. Lu
Since size of "void *" is 4 bytes for x32, check if __x86_64__ is defined
by $CC, instead of

if test x$ac_cv_sizeof_void_p = x8; then

to decide wether anitizer_linux_x86_64.lo should be used.

I am testing this on i686 and x86-64.  OK for trunk and GCC 7 branch if
there are no regression?  Please upstream it for me if appropriate.

Thanks.


H.J.
---
PR sanitizer/82379
* configure.tgt (ANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS): Set
to anitizer_linux_x86_64.lo if __x86_64__ is defined by $CC.
---
 libsanitizer/configure.tgt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index 82e8a5513c5..573e3b482e9 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -27,6 +27,8 @@ case "${target}" in
TSAN_SUPPORTED=yes
LSAN_SUPPORTED=yes
TSAN_TARGET_DEPENDENT_OBJECTS=tsan_rtl_amd64.lo
+   fi
+   if echo "int x = __x86_64__;" | $CC -c -x c -o /dev/null - > /dev/null 
2>&1; then

SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS=sanitizer_linux_x86_64.lo
fi
;;
-- 
2.13.6