public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jeff Law <law@redhat.com>, Alan Modra <amodra@gmail.com>,
	       Jason Merrill <jason@redhat.com>,
	       Richard Biener <richard.guenther@gmail.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [SFN+LVU+IEPM v4 9/9] [IEPM] Introduce inline entry point markers
Date: Sat, 10 Feb 2018 00:56:00 -0000	[thread overview]
Message-ID: <orzi4hek6z.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <20180209211000.GN5867@tucnak> (Jakub Jelinek's message of "Fri,	9 Feb 2018 22:10:00 +0100")

On Feb  9, 2018, Jakub Jelinek <jakub@redhat.com> wrote:

> On Fri, Feb 09, 2018 at 07:01:25PM -0200, Alexandre Oliva wrote:
>> So, as discussed on IRC, I'm trying to use a target hook to allow
>> targets to indicate that their length attrs have been assessed for this
>> purpose, and a param to make that overridable, but I'm having trouble
>> initializing the param from the target hook.  How does one do that?

> Better in the default version of the target hook check the param
> whether it should return true or false, and for analyzed targets
> just use an always true (or false, depending on what the hook is)
> as the hook.

I want it to be overridable, so here's what I ended up with.
Testing underway; ok to install if it succeeds?


We need accurate length information to be able to optimize away
locviews that would contain only zero-numbered views, and even to
output correct view numbers.  E.g., if we assume an insn has length
nonzero, i.e., that it will advance PC, we conclude the view number
after it is zero.  If the assumption turns out to be false, the
assembler view zero assert will catch the mistake, but only if we're
using a view-capable assembler.  Otherwise, view numbers will silently
go out of sync between the compiler and the assembler, and thus the
debug info consumer.

Unfortunately, a number of targets seem to fail the essential property
for this to work, namely, that get_min_attr_length() be zero for every
insn that might have length zero.

We thus introduce a target hook that indicates whether we can rely on
the length attribute for this purpose, and a param that can be used to
override it, for testing purposes or to work around errors.

for  gcc/ChangeLog

	* params.def (PARAM_USE_ATTR_LENGTH_IN_VIEW_COUNTING): New.
	* target.def (attr_length_reliable_for_view_count): New.
	* dwarf2out.c: Include params.h.
	(unreliable_attr_length_p): New.
	(dwarf2out_var_location): Use it.
	* doc/tm.texi.in (TARGET_ATTR_LENGTH_RELIABLE_FOR_VIEW_COUNT):
	New.
	* doc/tm.texi: Rebuilt.
---
 gcc/doc/tm.texi    |   13 +++++++++++++
 gcc/doc/tm.texi.in |    2 ++
 gcc/dwarf2out.c    |   28 +++++++++++++++++++++++++++-
 gcc/params.def     |    5 +++++
 gcc/target.def     |   14 ++++++++++++++
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index ddf48cb4b4d2..50fa0d387f32 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -9986,6 +9986,19 @@ following it should not be run.  Usually true only for virtual assembler
 targets.
 @end deftypevr
 
+@deftypevr {Target Hook} bool TARGET_ATTR_LENGTH_RELIABLE_FOR_VIEW_COUNT
+TRUE if get_min_attr_length returns
+zero for any non-asm insn that might have length zero, during final.
+It's ok if it's conservative and always returns zero.
+If, in addition to the essential property, when an insn is known to have
+nonzero length, get_min_attr_length returns a positive number, that will
+enable loclist optimizations.  There is little point in making this TRUE
+otherwise.  Enabling this when the essential property is not met while
+using GNU as 2.30 or newer may cause the assembler to detect the errors
+and fail to assemble; other assemblers will silently let the errors
+through, with incorrect view numbers in debug information.
+@end deftypevr
+
 @defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
 A C statement to issue assembly directives that create a difference
 @var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 0aab45f4992c..26b32db77f74 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -6929,6 +6929,8 @@ tables, and hence is desirable if it works.
 
 @hook TARGET_NO_REGISTER_ALLOCATION
 
+@hook TARGET_ATTR_LENGTH_RELIABLE_FOR_VIEW_COUNT
+
 @defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
 A C statement to issue assembly directives that create a difference
 @var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 749c7e3b9bbc..c48c117c8a16 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -96,6 +96,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "stringpool.h"
 #include "attribs.h"
 #include "file-prefix-map.h" /* remap_debug_filename()  */
+#include "params.h"
 
 static void dwarf2out_source_line (unsigned int, unsigned int, const char *,
 				   int, bool);
@@ -26860,6 +26861,30 @@ dwarf2out_next_real_insn (rtx_insn *loc_note)
   return next_real;
 }
 
+/* Return TRUE if we should NOT use ATTR_length to optimize locview
+   lists, and FALSE otherwise.
+
+   If ATTR_length is always zero for insns that could have length
+   zero, we can use it, then we'll know when we're guaranteed to have
+   a PC change that implies a view reset.  locview lists whose views
+   are all zero can be optimized out completely.
+
+   However, if we enable these optimizations based on unreliable data,
+   we might get errors from the assembler (binutils 2.30+) when it
+   notices we have incorrectly assumed a view would be zero, or
+   silently get incorrect locview lists otherwise.  */
+
+static bool
+unreliable_attr_length_p (void)
+{
+  int parm = PARAM_VALUE (PARAM_USE_ATTR_LENGTH_IN_VIEW_COUNTING);
+
+  if (parm != -1)
+    return !parm;
+  else
+    return !targetm.attr_length_reliable_for_view_count;
+}
+
 /* Called by the final INSN scan whenever we see a var location.  We
    use it to drop labels in the right places, and throw the location in
    our lookup table.  */
@@ -26921,7 +26946,8 @@ dwarf2out_var_location (rtx_insn *loc_note)
 	gcc_unreachable ();
       else if (JUMP_TABLE_DATA_P (loc_note))
 	RESET_NEXT_VIEW (cur_line_info_table->view);
-      else if (GET_CODE (loc_note) == USE
+      else if (unreliable_attr_length_p ()
+	       || GET_CODE (loc_note) == USE
 	       || GET_CODE (loc_note) == CLOBBER
 	       || GET_CODE (loc_note) == ASM_INPUT
 	       || asm_noperands (loc_note) >= 0)
diff --git a/gcc/params.def b/gcc/params.def
index 930b31820be9..12e217ed9da4 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -1331,6 +1331,11 @@ DEFPARAM(PARAM_AVOID_FMA_MAX_BITS,
 	 "Maximum number of bits for which we avoid creating FMAs.",
 	 0, 0, 512)
 
+DEFPARAM(PARAM_USE_ATTR_LENGTH_IN_VIEW_COUNTING,
+	 "use-attr-length-in-view-counting",
+	 "Optimize locview lists based on length attributes.",
+	 -1 /* targetm.attr_length_reliable_for_view_count */, 0, 1)
+
 /*
 
 Local variables:
diff --git a/gcc/target.def b/gcc/target.def
index aeb41df19454..a7fedb72fef2 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -6631,6 +6631,20 @@ following it should not be run.  Usually true only for virtual assembler\n\
 targets.",
 bool, false)
 
+DEFHOOKPOD
+(attr_length_reliable_for_view_count,
+"True if, during final, get_min_attr_length returns zero\n\
+for all non-asm insns that might have length zero.\n\
+It's ok if it's conservative and always returns zero.\n\
+If, in addition to the essential property, when an insn is known to have\n\
+nonzero length, get_min_attr_length returns a positive number, that will\n\
+enable loclist optimizations.  There is little point in making this true\n\
+otherwise.  Enabling this when the essential property is not met while\n\
+using GNU as 2.30 or newer may cause the assembler to detect the errors\n\
+and fail to assemble; other assemblers will silently let the errors\n\
+through, with incorrect view numbers in debug information.",
+bool, false)
+
 /* Leave the boolean fields at the end.  */
 
 /* Functions related to mode switching.  */


-- 
Alexandre Oliva, freedom fighter    http://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

  reply	other threads:[~2018-02-10  0:56 UTC|newest]

Thread overview: 156+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 23:21 Introduce Statement Frontier Notes and Location Views Alexandre Oliva
2017-07-13 13:17 ` Alexandre Oliva
2017-08-18 22:49   ` Statement Frontier Notes, Location Views, and Inlined Entry Point Markers (was: Re: Introduce Statement Frontier Notes and Location Views) Alexandre Oliva
2017-08-21 12:35     ` Richard Biener
2017-08-22 22:44       ` Statement Frontier Notes, Location Views, and Inlined Entry Point Markers Alexandre Oliva
2017-08-23 12:33         ` Richard Biener
2017-08-25 16:41           ` Alexandre Oliva
2017-09-07 21:44             ` Joseph Myers
2017-09-21  2:24               ` Alexandre Oliva
2017-08-22 22:44       ` Alexandre Oliva
2017-08-23 12:12         ` Richard Biener
2017-08-25 15:26           ` Alexandre Oliva
2017-08-28 12:41             ` Richard Biener
2017-08-25 19:22           ` Alexandre Oliva
2017-09-01  1:07           ` Alexandre Oliva
2017-09-01  1:15             ` [PATCH 5/9] [SFN] Introduce -gstatement-frontiers option, enable debug markers Alexandre Oliva
2017-09-01  1:15             ` [PATCH 1/9] [SFN] adjust RTL insn-walking API Alexandre Oliva
2017-09-01  1:15             ` [PATCH 2/9] [SFN] boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-09-01  1:16             ` [PATCH 9/9] [IEPM] Introduce inline entry point markers Alexandre Oliva
2017-09-01  1:16             ` [PATCH 8/9] [IEPM] Introduce debug hook for " Alexandre Oliva
2017-09-01  1:16             ` [PATCH 3/9] [SFN] not-quite-boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-09-01  1:16             ` [PATCH 4/9] [SFN] introduce statement frontier notes, still disabled Alexandre Oliva
2017-09-01  1:16             ` [PATCH 7/9] [LVU] Introduce location views Alexandre Oliva
2017-09-01  1:16             ` [PATCH 6/9] [LVU] Allow final_start_function to skip initial insns Alexandre Oliva
2017-09-30  9:04             ` Statement Frontier Notes, Location Views, and Inlined Entry Point Markers Alexandre Oliva
2017-09-30  9:09               ` [PATCH 6/9] [LVU] Allow final_start_function to skip initial insns Alexandre Oliva
2017-10-19 11:07                 ` Richard Biener
2017-10-31  5:10                   ` Jeff Law
2017-10-31  5:23                 ` Jeff Law
2017-11-01 18:20                   ` Alexandre Oliva
2017-11-02 13:00                     ` Richard Biener
2017-09-30  9:09               ` [PATCH 4/9] [SFN] introduce statement frontier notes, still disabled Alexandre Oliva
2017-10-09 13:11                 ` Richard Biener
2017-10-13  7:25                   ` Alexandre Oliva
2017-10-13  9:41                     ` Richard Biener
2017-10-17 22:06                       ` Alexandre Oliva
2017-10-24 18:11                 ` Jason Merrill
2017-11-01 19:14                   ` Alexandre Oliva
2017-11-01 19:49                     ` Jason Merrill
2017-09-30  9:09               ` [PATCH 1/9] [SFN] adjust RTL insn-walking API Alexandre Oliva
2017-10-09 13:24                 ` Richard Biener
2017-09-30  9:09               ` [PATCH 2/9] [SFN] boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-10-09 13:02                 ` Richard Biener
2017-09-30  9:09               ` [PATCH 5/9] [SFN] Introduce -gstatement-frontiers option, enable debug markers Alexandre Oliva
2017-10-09 13:12                 ` Richard Biener
2017-09-30  9:10               ` [PATCH 7/9] [LVU] Introduce location views Alexandre Oliva
2017-09-30  9:10               ` [PATCH 9/9] [IEPM] Introduce inline entry point markers Alexandre Oliva
2017-10-31  6:22                 ` Jeff Law
2017-11-01 18:36                   ` Alexandre Oliva
2017-11-09 16:30                     ` Jeff Law
2017-11-10  2:31                       ` Alexandre Oliva
2017-09-30  9:10               ` [PATCH 8/9] [IEPM] Introduce debug hook for " Alexandre Oliva
2017-10-31  5:58                 ` Jeff Law
2017-09-30  9:10               ` [PATCH 3/9] [SFN] not-quite-boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-10-09 13:07                 ` Richard Biener
2017-11-10  2:36               ` SFN+LVU+IEPM v4 (was: Re: Statement Frontier Notes, Location Views, and Inlined Entry Point Markers) Alexandre Oliva
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 5/9] [SFN] introduce statement frontier notes, still disabled Alexandre Oliva
2017-12-07 23:59                   ` Jeff Law
2017-12-12  2:41                     ` Alexandre Oliva
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 1/9] [SFN] adjust RTL insn-walking API Alexandre Oliva
2017-12-07 22:25                   ` Jeff Law
2017-12-12  3:10                     ` Alexandre Oliva
2017-12-14 11:55                       ` Alexandre Oliva
2017-12-14 12:07                         ` Jakub Jelinek
2017-12-14 18:25                           ` Alexandre Oliva
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 4/9] [SFN] stabilize find_bb_boundaries Alexandre Oliva
2017-12-07 22:46                   ` Jeff Law
2017-12-12  2:38                     ` Alexandre Oliva
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 3/9] [SFN] not-quite-boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-12-07 22:44                   ` Jeff Law
2017-12-12  2:31                     ` Alexandre Oliva
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 6/9] [SFN] Introduce -gstatement-frontiers option, enable debug markers Alexandre Oliva
2017-12-07 22:49                   ` Jeff Law
2017-12-12  2:42                     ` Alexandre Oliva
2017-12-12  9:16                       ` Christophe Lyon
2017-12-13  4:22                         ` Alexandre Oliva
2018-01-07 17:48                       ` H.J. Lu
2017-12-27  8:00                   ` [nvptx, committed] Disable -gstatement-frontiers for nvptx Tom de Vries
2017-12-29  4:12                     ` Alexandre Oliva
2017-12-29 11:42                       ` Tom de Vries
2017-12-31 20:05                         ` Alexandre Oliva
2018-01-11 10:12                           ` Tom de Vries
2017-11-10  2:36                 ` [SFN+LVU+IEPM v4 2/9] [SFN] boilerplate changes in preparation to introduce nonbind markers Alexandre Oliva
2017-12-07 22:27                   ` Jeff Law
2017-12-12  2:55                     ` Alexandre Oliva
2017-11-10  2:37                 ` [SFN+LVU+IEPM v4 8/9] [IEPM] Introduce debug hook for inline entry point markers Alexandre Oliva
2017-12-07 22:51                   ` Jeff Law
2017-12-12  2:44                     ` Alexandre Oliva
2017-11-10  5:05                 ` [SFN+LVU+IEPM v4 7/9] [LVU] Introduce location views Alexandre Oliva
2017-11-13 10:18                   ` Richard Biener
2017-11-15  3:59                     ` Alexandre Oliva
2017-12-11 23:12                   ` Jeff Law
2017-12-12  2:52                     ` Alexandre Oliva
2018-01-24 17:36                       ` Jakub Jelinek
2018-01-25 20:19                         ` Alexandre Oliva
2018-01-26 14:58                           ` Jakub Jelinek
2018-01-30 18:40                             ` Alexandre Oliva
2018-01-30 22:11                               ` Richard Sandiford
2018-02-07  4:14                                 ` Alexandre Oliva
2018-02-07  7:43                           ` Alexandre Oliva
2018-02-06 21:13                       ` Jason Merrill
2018-02-07  4:02                         ` Alexandre Oliva
2018-02-07 19:23                           ` Jason Merrill
2018-02-08 12:56                             ` Alexandre Oliva
2018-02-08 16:05                               ` Jason Merrill
2018-02-09  3:49                                 ` Alexandre Oliva
2018-02-07  7:35                         ` Alexandre Oliva
2018-02-07  7:36                         ` Alexandre Oliva
2018-02-08 19:58                           ` Jason Merrill
2018-02-09  3:20                             ` Alexandre Oliva
2018-02-11 19:04                               ` Andreas Schwab
2018-02-11 20:47                               ` Andreas Schwab
2018-02-12  7:46                                 ` Alexandre Oliva
2018-02-12  7:49                                 ` Alexandre Oliva
2018-02-12 10:11                                   ` Andreas Schwab
2018-02-13  5:47                                     ` Alexandre Oliva
2018-02-14  9:23                                       ` Andreas Schwab
2017-11-10  5:29                 ` [SFN+LVU+IEPM v4 9/9] [IEPM] Introduce inline entry point markers Alexandre Oliva
2017-12-12  2:54                   ` Alexandre Oliva
2017-12-21  5:18                     ` Jeff Law
2018-01-24  7:11                       ` Alexandre Oliva
2018-01-24 17:40                     ` Jakub Jelinek
2018-01-25 20:14                       ` Alexandre Oliva
2018-02-09  3:21                         ` Alexandre Oliva
2018-02-09  3:53                           ` Alan Modra
2018-02-09  4:13                             ` Jeff Law
2018-02-09 10:35                               ` Alexandre Oliva
2018-02-09 12:10                                 ` Alan Modra
2018-02-09 15:09                                 ` Jeff Law
2018-02-09 22:52                                   ` Joseph Myers
2018-02-10  1:36                                     ` Joseph Myers
2018-02-10 12:35                                       ` Alexandre Oliva
2018-02-10 18:19                                         ` Jeff Law
2018-02-11 15:29                                           ` Alexandre Oliva
2018-02-09 21:01                               ` Alexandre Oliva
2018-02-09 23:49                                 ` Jakub Jelinek
2018-02-10  0:56                                   ` Alexandre Oliva [this message]
2018-02-12  8:08                                     ` Alexandre Oliva
2018-02-13 13:52                                       ` Alexandre Oliva
2018-02-13 16:15                                         ` Jeff Law
2018-02-15 15:23                                         ` Szabolcs Nagy
2018-02-21 10:12                                           ` Alexandre Oliva
2018-02-21 12:08                                             ` Uros Bizjak
2018-02-22 15:22                                             ` Szabolcs Nagy
2018-02-28  6:17                                             ` Alexandre Oliva
2018-03-09  9:49                                               ` Bin.Cheng
2018-03-09  9:55                                                 ` Ramana Radhakrishnan
2018-03-09 11:35                                                 ` Jakub Jelinek
2018-03-07 19:43                                             ` Jeff Law
2018-02-10  4:39                                 ` Alexandre Oliva
2018-02-10  6:35                                   ` Jeff Law
2018-02-10 13:05                                     ` Alexandre Oliva
2018-02-10 16:36                                       ` Jeff Law
2018-02-21 10:33                       ` Alexandre Oliva
2018-02-26 12:47                         ` Richard Biener
2017-11-10 21:31                 ` SFN+LVU+IEPM v4 Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=orzi4hek6z.fsf@lxoliva.fsfla.org \
    --to=aoliva@redhat.com \
    --cc=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=law@redhat.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).