This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [SFN+LVU+IEPM v4 9/9] [IEPM] Introduce inline entry point markers


On Feb  9, 2018, Alexandre Oliva <aoliva@redhat.com> wrote:

> 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?

This patch supersedes the previous one.  Testing underway...  Ok if it
succeeds?

Sorry for combining so many not-entirely-related issues in a single
patch, but there would be lots of overlaps and conflicts otherwise, and
in the end they're all about allowing finer-tuning of markers and views,
so I hope tha's ok.  Well, not all: there are formatting fixes to docs
that are totally unrelated, but still overlapping.  Anyway...


[LVU, IEPM] several new controlling options

Given that the minimum insn length is not generally reliable to tell
whether an insn actually advances PC, this patch disables the locview
list optimizations that can only be done when can tell it.

The preexisting logic is retained, however, and can be enabled with
the newly-introduced -ginternal-reset-location-view.  This is now
enabled by default only if the target defines a hook that may override
or defer to the preexisting logic.  The negated command line option
can then be used should errors still be encountered.


We also introduce options to control whether to assume .loc and view
support in the assembler, and to control whether to output inline
entry points (and views) from markers.


This patch also fixes a number of documentation formatting errors,
namely using @item rather than @itemx for all but the first of several
options before a description.

for  gcc/ChangeLog

	* common.opt (gas-loc-support, gas-locview-support): New.
	(ginline-points, ginternal-reset-location-views): New.
	* doc/invoke.texi: Document them.  Use @itemx where intended.
	(gvariable-location-views): Adjust.
	* target.def (reset_location_view): New.
	* doc/tm.texi.in (DWARF2_ASM_VIEW_DEBUG_INFO): New.
	(TARGET_RESET_LOCATION_VIEW): New.
	* doc/tm.texi: Rebuilt.
	* dwarf2out.c (dwarf2out_default_as_loc_support): New.
	(dwarf2out_default_as_locview_support): New.
	(output_asm_line_debug_info): Use option variables.
	(dwarf2out_maybe_output_loclist_view_pair): Likewise.
	(output_loc_list): Likewise.
	(add_high_low_attributes): Check option variables.
	Don't output entry view attribute in strict mode.
	(gen_inlined_subroutine_die): Check option variables.
	(dwarf2out_inline_entry): Likewise.
	(init_sections_and_labels): Likewise.
	(dwarf2out_early_finish): Likewise.
	(maybe_reset_location_view): New, from...
	(dwarf2out_var_location): ... here.  Call it.
	* debug.h (dwarf2out_default_as_loc_support): Declare.
	(dwarf2out_default_as_locview_support): Declare.
	* hooks.c (hook_int_rtx_insn_0): New.
	* hooks.h (hook_int_rtx_insn_0): Declare.
	* toplev.c (process_options): Take -gas-loc-support and
	-gas-locview-support from dwarf2out.  Enable
	-gvariable-location-views by default only with locview
	assembler support.  Enable -ginternal-reset-location-views by
	default only if the target defines the corresponding hook.
	Enable -ginline-points by default if location views are
	enabled; force it disabled if statement frontiers are
	disabled.
	* tree-inline.c (expand_call_inline): Check option variables.
	* tree-ssa-live.c (remove_unused_scope_block_p): Likewise.
---
 gcc/common.opt      |   16 ++++
 gcc/debug.h         |    2 +
 gcc/doc/invoke.texi |  106 +++++++++++++++++++++++------
 gcc/doc/tm.texi     |   23 ++++++
 gcc/doc/tm.texi.in  |    9 ++
 gcc/dwarf2out.c     |  186 +++++++++++++++++++++++++++++++++------------------
 gcc/hooks.c         |    6 ++
 gcc/hooks.h         |    1 
 gcc/target.def      |   17 +++++
 gcc/toplev.c        |   45 +++++++++++-
 gcc/tree-inline.c   |    2 -
 gcc/tree-ssa-live.c |    4 +
 12 files changed, 324 insertions(+), 93 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 40ec0088c57e..e0bc4d1bb18d 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2880,6 +2880,14 @@ g
 Common Driver RejectNegative JoinedOrMissing
 Generate debug information in default format.
 
+gas-loc-support
+Common Driver Var(dwarf2out_as_loc_support) Init(2)
+Assume assembler support for (DWARF2+) .loc directives
+
+gas-locview-support
+Common Driver Var(dwarf2out_as_locview_support) Init(2)
+Assume assembler support for view in (DWARF2+) .loc directives
+
 gcoff
 Common Driver Ignore Warn(switch %qs no longer supported)
 Does nothing.  Preserved for backward compatibility.
@@ -2912,6 +2920,14 @@ ggdb
 Common Driver JoinedOrMissing
 Generate debug information in default extended format.
 
+ginline-points
+Common Driver Var(debug_inline_points) Init(2)
+Generate extended entry point information for inlined functions
+
+ginternal-reset-location-views
+Common Driver Var(debug_internal_reset_location_views) Init(2)
+Compute locview reset points based on insn length estimates
+
 gno-
 RejectNegative Joined Undocumented
 ; Catch the gno- prefix, so it doesn't backtrack to g<level>.
diff --git a/gcc/debug.h b/gcc/debug.h
index e1dfe4befaa1..126e56e8c8d7 100644
--- a/gcc/debug.h
+++ b/gcc/debug.h
@@ -248,6 +248,8 @@ extern bool dwarf2out_do_eh_frame (void);
 extern bool dwarf2out_do_frame (void);
 extern bool dwarf2out_do_cfi_asm (void);
 extern void dwarf2out_switch_text_section (void);
+extern bool dwarf2out_default_as_loc_support (void);
+extern bool dwarf2out_default_as_locview_support (void);
 
 /* For -fdump-go-spec.  */
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index df357bea7dc2..f45577e77b4e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -346,9 +346,13 @@ Objective-C and Objective-C++ Dialects}.
 @gccoptlist{-g  -g@var{level}  -gdwarf  -gdwarf-@var{version} @gol
 -ggdb  -grecord-gcc-switches  -gno-record-gcc-switches @gol
 -gstabs  -gstabs+  -gstrict-dwarf  -gno-strict-dwarf @gol
+-gas-loc-support  -gno-as-loc-support @gol
+-gas-locview-support  -gno-as-locview-support @gol
 -gcolumn-info  -gno-column-info @gol
 -gstatement-frontiers  -gno-statement-frontiers @gol
 -gvariable-location-views  -gno-variable-location-views @gol
+-ginternal-reset-location-views  -gno-internal-reset-location-views @gol
+-ginline-points  -gno-inline-points @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
@@ -4159,7 +4163,7 @@ result in false positives.
 
 @table @gcctabopt
 @item -Wformat-overflow
-@item -Wformat-overflow=1
+@itemx -Wformat-overflow=1
 @opindex Wformat-overflow
 @opindex Wno-format-overflow
 Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
@@ -4278,7 +4282,7 @@ logic @option{-Wformat-overflow}.
 
 @table @gcctabopt
 @item -Wformat-truncation
-@item -Wformat-truncation=1
+@itemx -Wformat-truncation=1
 @opindex Wformat-truncation
 @opindex Wno-format-overflow
 Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
@@ -5239,7 +5243,7 @@ Option @option{-Wstringop-overflow=2} is enabled by default.
 
 @table @gcctabopt
 @item -Wstringop-overflow
-@item -Wstringop-overflow=1
+@itemx -Wstringop-overflow=1
 @opindex Wstringop-overflow
 @opindex Wno-stringop-overflow
 The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
@@ -7214,7 +7218,7 @@ and on some objects @code{.debug_types} produces larger instead of smaller
 debugging information.
 
 @item -grecord-gcc-switches
-@item -gno-record-gcc-switches
+@itemx -gno-record-gcc-switches
 @opindex grecord-gcc-switches
 @opindex gno-record-gcc-switches
 This switch causes the command-line options used to invoke the
@@ -7237,8 +7241,38 @@ DWARF extensions from later standard versions is allowed.
 Allow using extensions of later DWARF standard version than selected with
 @option{-gdwarf-@var{version}}.
 
+@item -gas-loc-support
+@opindex gas-loc-support
+Inform the compiler that the assembler supports @code{.loc} directives.
+It may then use them for the assembler to generate DWARF2+ line number
+tables.
+
+This is generally desirable, because assembler-generated line-number
+tables are a lot more compact than those the compiler can generate
+itself.
+
+This option will be enabled by default if, at GCC configure time, the
+assembler was found to support such directives.
+
+@item -gno-as-loc-support
+@opindex gno-as-loc-support
+Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
+line number tables are to be generated.
+
+@item gas-locview-support
+@opindex gas-locview-support
+Inform the compiler that the assembler supports @code{view} assignment
+and reset assertion checking in @code{.loc} directives.
+
+This option will be enabled by default if, at GCC configure time, the
+assembler was found to support them.
+
+@item gno-as-locview-support
+Force GCC to assign view numbers internally, if
+@option{-gvariable-location-views} are explicitly requested.
+
 @item -gcolumn-info
-@item -gno-column-info
+@itemx -gno-column-info
 @opindex gcolumn-info
 @opindex gno-column-info
 Emit location column information into DWARF debugging information, rather
@@ -7246,7 +7280,7 @@ than just file and line.
 This option is enabled by default.
 
 @item -gstatement-frontiers
-@item -gno-statement-frontiers
+@itemx -gno-statement-frontiers
 @opindex gstatement-frontiers
 @opindex gno-statement-frontiers
 This option causes GCC to create markers in the internal representation
@@ -7257,8 +7291,8 @@ compiling with optimization (@option{-Os}, @option{-O}, @option{-O2},
 @dots{}), and outputting DWARF 2 debug information at the normal level.
 
 @item -gvariable-location-views
-@item -gvariable-location-views=incompat5
-@item -gno-variable-location-views
+@itemx -gvariable-location-views=incompat5
+@itemx -gno-variable-location-views
 @opindex gvariable-location-views
 @opindex gvariable-location-views=incompat5
 @opindex gno-variable-location-views
@@ -7272,9 +7306,15 @@ which generally makes them somewhat less compact.  The augmented line
 number tables and location lists are fully backward-compatible, so they
 can be consumed by debug information consumers that are not aware of
 these augmentations, but they won't derive any benefit from them either.
+
 This is enabled by default when outputting DWARF 2 debug information at
-the normal level, as long as @option{-fvar-tracking-assignments} is
-enabled and @option{-gstrict-dwarf} is not.
+the normal level, as long as there is assembler support,
+@option{-fvar-tracking-assignments} is enabled and
+@option{-gstrict-dwarf} is not.  When assembler support is not
+available, this may still be enabled, but it will force GCC to output
+internal line number tables, and if
+@option{-ginternal-reset-location-views} is not enabled, that will most
+certainly lead to silently mismatching location views.
 
 There is a proposed representation for view numbers that is not backward
 compatible with the location list format introduced in DWARF 5, that can
@@ -7284,6 +7324,30 @@ implementation of the proposed representation.  Debug information
 consumers are not expected to support this extended format, and they
 would be rendered unable to decode location lists using it.
 
+@item -ginternal-reset-location-views
+@itemx -gnointernal-reset-location-views
+@opindex ginternal-reset-location-views
+@opindex gno-internal-reset-location-views
+Attempt to determine location views that can be omitted from location
+view lists.  This requires the compiler to have very accurate insn
+length estimates, which isn't always the case, and it may cause
+incorrect view lists to be generated silently when using an assembler
+that does not support location view lists.  The GNU assembler will flag
+any such error as a @code{view number mismatch}.  This is only enabled
+on ports that define a reliable estimation function.
+
+@item -ginline-points
+@itemx -gno-inline-points
+@opindex ginline-points
+@opindex gno-inline-points
+Generate extended debug information for inlined functions.  Location
+view tracking markers are inserted at inlined entry points, so that
+address and view numbers can be computed and output in debug
+information.  This can be enabled independently of location views, in
+which case the view numbers won't be output, but it can only be enabled
+along with statement frontiers, and it is only enabled by default if
+location views are enabled.
+
 @item -gz@r{[}=@var{type}@r{]}
 @opindex gz
 Produce compressed debug sections in DWARF format, if that is supported.
@@ -10043,7 +10107,7 @@ also use other heuristics to decide whether if-conversion is likely to be
 profitable.
 
 @item max-rtl-if-conversion-predictable-cost
-@item max-rtl-if-conversion-unpredictable-cost
+@itemx max-rtl-if-conversion-unpredictable-cost
 RTL if-conversion will try to remove conditional branches around a block
 and replace them with conditionally executed instructions.  These parameters
 give the maximum permissible cost for the sequence that would be generated
@@ -10767,7 +10831,7 @@ parameters only when their cumulative size is less or equal to
 pointer parameter.
 
 @item sra-max-scalarization-size-Ospeed
-@item sra-max-scalarization-size-Osize
+@itemx sra-max-scalarization-size-Osize
 The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
 replace scalar parts of aggregates with uses of independent scalar
 variables.  These parameters control the maximum size, in storage units,
@@ -14544,7 +14608,7 @@ This erratum workaround is made at link time and this will only pass the
 corresponding flag to the linker.
 
 @item -mlow-precision-recip-sqrt
-@item -mno-low-precision-recip-sqrt
+@itemx -mno-low-precision-recip-sqrt
 @opindex mlow-precision-recip-sqrt
 @opindex mno-low-precision-recip-sqrt
 Enable or disable the reciprocal square root approximation.
@@ -14554,7 +14618,7 @@ precision of reciprocal square root results to about 16 bits for
 single precision and to 32 bits for double precision.
 
 @item -mlow-precision-sqrt
-@item -mno-low-precision-sqrt
+@itemx -mno-low-precision-sqrt
 @opindex -mlow-precision-sqrt
 @opindex -mno-low-precision-sqrt
 Enable or disable the square root approximation.
@@ -14565,7 +14629,7 @@ single precision and to 32 bits for double precision.
 If enabled, it implies @option{-mlow-precision-recip-sqrt}.
 
 @item -mlow-precision-div
-@item -mno-low-precision-div
+@itemx -mno-low-precision-div
 @opindex -mlow-precision-div
 @opindex -mno-low-precision-div
 Enable or disable the division approximation.
@@ -20193,7 +20257,7 @@ for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
 not intended for ordinary use in compiling user code.
 
 @item -minterlink-compressed
-@item -mno-interlink-compressed
+@itemx -mno-interlink-compressed
 @opindex minterlink-compressed
 @opindex mno-interlink-compressed
 Require (do not require) that code using the standard (uncompressed) MIPS ISA
@@ -20774,7 +20838,7 @@ Tell the MIPS assembler to not run its preprocessor over user
 assembler files (with a @samp{.s} suffix) when assembling them.
 
 @item -mfix-24k
-@item -mno-fix-24k
+@itemx -mno-fix-24k
 @opindex mfix-24k
 @opindex mno-fix-24k
 Work around the 24K E48 (lost data on stores during refill) errata.
@@ -21534,7 +21598,7 @@ into the small data or BSS sections instead of the normal data or BSS
 sections.  The default value of @var{num} is 8.
 
 @item -mgpopt=@var{option}
-@item -mgpopt
+@itemx -mgpopt
 @itemx -mno-gpopt
 @opindex mgpopt
 @opindex mno-gpopt
@@ -23093,7 +23157,7 @@ or 32 bits (@option{-m32bit-doubles}) in size.  The default is
 @option{-m32bit-doubles}.
 
 @item -msave-mduc-in-interrupts
-@item -mno-save-mduc-in-interrupts
+@itemx -mno-save-mduc-in-interrupts
 @opindex msave-mduc-in-interrupts
 @opindex mno-save-mduc-in-interrupts
 Specifies that interrupt handler functions should preserve the
@@ -26726,13 +26790,13 @@ comparisons.  These correctly handle the case where the result of a
 comparison is unordered.
 
 @item -m80387
-@item -mhard-float
+@itemx -mhard-float
 @opindex 80387
 @opindex mhard-float
 Generate output containing 80387 instructions for floating point.
 
 @item -mno-80387
-@item -msoft-float
+@itemx -msoft-float
 @opindex no-80387
 @opindex msoft-float
 Generate output containing library calls for floating point.
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index ddf48cb4b4d2..bd8b917ba829 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -9966,6 +9966,29 @@ line debug info sections.  This will result in much more compact line number
 tables, and hence is desirable if it works.
 @end defmac
 
+@defmac DWARF2_ASM_VIEW_DEBUG_INFO
+Define this macro to be a nonzero value if the assembler supports view
+assignment and verification in @code{.loc}.  If it does not, but the
+user enables location views, the compiler may have to fallback to
+internal line number tables.
+@end defmac
+
+@deftypefn {Target Hook} int TARGET_RESET_LOCATION_VIEW (rtx_insn *@var{})
+This hook, if defined, enables -ginternal-reset-location-views, and
+uses its result to override cases in which the estimated min insn
+length might be nonzero even when a PC advance (i.e., a view reset)
+cannot be taken for granted.
+
+If the hook is defined, it must return a positive value to indicate
+the insn definitely advances the PC, and so the view number can be
+safely assumed to be reset; a negative value to mean the insn
+definitely does not advance the PC, and os the view number must not
+be reset; or zero to decide based on the estimated insn length.
+
+If insn length is to be regarded as reliable, set the hook to
+@code{hook_int_rtx_insn_0}.
+@end deftypefn
+
 @deftypevr {Target Hook} bool TARGET_WANT_DEBUG_PUB_SECTIONS
 True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections should be emitted.  These sections are not used on most platforms, and in particular GDB does not use them.
 @end deftypevr
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 0aab45f4992c..b0207146e8c2 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -6921,6 +6921,15 @@ line debug info sections.  This will result in much more compact line number
 tables, and hence is desirable if it works.
 @end defmac
 
+@defmac DWARF2_ASM_VIEW_DEBUG_INFO
+Define this macro to be a nonzero value if the assembler supports view
+assignment and verification in @code{.loc}.  If it does not, but the
+user enables location views, the compiler may have to fallback to
+internal line number tables.
+@end defmac
+
+@hook TARGET_RESET_LOCATION_VIEW
+
 @hook TARGET_WANT_DEBUG_PUB_SECTIONS
 
 @hook TARGET_DELAY_SCHED2
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 984df9fe4e9a..4e8d40bc91f2 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -2957,6 +2957,37 @@ struct GTY(()) dw_line_info_table {
   vec<dw_line_info_entry, va_gc> *entries;
 };
 
+/* If we're keep track of location views and their reset points, and
+   INSN is a reset point (i.e., it necessarily advances the PC), mark
+   the next view in TABLE as reset.  */
+
+static void
+maybe_reset_location_view (rtx_insn *insn, dw_line_info_table *table)
+{
+  if (!debug_internal_reset_location_views)
+    return;
+
+  /* Maybe turn (part of?) this test into a default target hook.  */
+  int reset = 0;
+
+  if (targetm.reset_location_view)
+    reset = targetm.reset_location_view (insn);
+
+  if (reset)
+    ;
+  else if (JUMP_TABLE_DATA_P (insn))
+    reset = 1;
+  else if (GET_CODE (insn) == USE
+	   || GET_CODE (insn) == CLOBBER
+	   || GET_CODE (insn) == ASM_INPUT
+	   || asm_noperands (insn) >= 0)
+    ;
+  else if (get_attr_min_length (insn) > 0)
+    reset = 1;
+
+  if (reset > 0)
+    RESET_NEXT_VIEW (table->view);
+}
 
 /* Each DIE attribute has a field specifying the attribute kind,
    a link to the next attribute in the chain, and an attribute value.
@@ -3164,6 +3195,29 @@ skeleton_chain_node;
 #endif
 #endif
 
+/* Return true if GCC configure detected assembler support for .loc.  */
+
+bool
+dwarf2out_default_as_loc_support (void)
+{
+  return DWARF2_ASM_LINE_DEBUG_INFO;
+#if (GCC_VERSION >= 3000)
+ #pragma GCC poison DWARF2_ASM_LINE_DEBUG_INFO
+#endif
+}
+
+/* Return true if GCC configure detected assembler support for views
+   in .loc directives.  */
+
+bool
+dwarf2out_default_as_locview_support (void)
+{
+  return DWARF2_ASM_VIEW_DEBUG_INFO;
+#if (GCC_VERSION >= 3000)
+ #pragma GCC poison DWARF2_ASM_VIEW_DEBUG_INFO
+#endif
+}
+
 /* A bit is set in ZERO_VIEW_P if we are using the assembler-supported
    view computation, and it refers to a view identifier for which we
    will not emit a label because it is known to map to a view number
@@ -3215,9 +3269,9 @@ static GTY(()) bitmap zero_view_p;
 static bool
 output_asm_line_debug_info (void)
 {
-  return (DWARF2_ASM_VIEW_DEBUG_INFO
-	  || (DWARF2_ASM_LINE_DEBUG_INFO
-	      && !debug_variable_location_views));
+  return (dwarf2out_as_loc_support
+	  && (dwarf2out_as_locview_support
+	      || !debug_variable_location_views));
 }
 
 /* Minimum line offset in a special line info. opcode.
@@ -9950,28 +10004,31 @@ dwarf2out_maybe_output_loclist_view_pair (dw_loc_list_ref curr)
 #ifdef DW_LLE_view_pair
   dw2_asm_output_data (1, DW_LLE_view_pair, "DW_LLE_view_pair");
 
-# if DWARF2_ASM_VIEW_DEBUG_INFO
-  if (ZERO_VIEW_P (curr->vbegin))
-    dw2_asm_output_data_uleb128 (0, "Location view begin");
-  else
+  if (dwarf2out_as_locview_support)
     {
-      char label[MAX_ARTIFICIAL_LABEL_BYTES];
-      ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
-      dw2_asm_output_symname_uleb128 (label, "Location view begin");
-    }
+      if (ZERO_VIEW_P (curr->vbegin))
+	dw2_asm_output_data_uleb128 (0, "Location view begin");
+      else
+	{
+	  char label[MAX_ARTIFICIAL_LABEL_BYTES];
+	  ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
+	  dw2_asm_output_symname_uleb128 (label, "Location view begin");
+	}
 
-  if (ZERO_VIEW_P (curr->vend))
-    dw2_asm_output_data_uleb128 (0, "Location view end");
+      if (ZERO_VIEW_P (curr->vend))
+	dw2_asm_output_data_uleb128 (0, "Location view end");
+      else
+	{
+	  char label[MAX_ARTIFICIAL_LABEL_BYTES];
+	  ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
+	  dw2_asm_output_symname_uleb128 (label, "Location view end");
+	}
+    }
   else
     {
-      char label[MAX_ARTIFICIAL_LABEL_BYTES];
-      ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
-      dw2_asm_output_symname_uleb128 (label, "Location view end");
+      dw2_asm_output_data_uleb128 (curr->vbegin, "Location view begin");
+      dw2_asm_output_data_uleb128 (curr->vend, "Location view end");
     }
-# else /* !DWARF2_ASM_VIEW_DEBUG_INFO */
-  dw2_asm_output_data_uleb128 (curr->vbegin, "Location view begin");
-  dw2_asm_output_data_uleb128 (curr->vend, "Location view end");
-# endif /* DWARF2_ASM_VIEW_DEBUG_INFO */
 #endif /* DW_LLE_view_pair */
 
   return;
@@ -10001,40 +10058,43 @@ output_loc_list (dw_loc_list_ref list_head)
 	  vcount++;
 
 	  /* ?? dwarf_split_debug_info?  */
-#if DWARF2_ASM_VIEW_DEBUG_INFO
-	  char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-	  if (!ZERO_VIEW_P (curr->vbegin))
+	  if (dwarf2out_as_locview_support)
 	    {
-	      ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
-	      dw2_asm_output_symname_uleb128 (label,
-					      "View list begin (%s)",
-					      list_head->vl_symbol);
+	      char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+	      if (!ZERO_VIEW_P (curr->vbegin))
+		{
+		  ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
+		  dw2_asm_output_symname_uleb128 (label,
+						  "View list begin (%s)",
+						  list_head->vl_symbol);
+		}
+	      else
+		dw2_asm_output_data_uleb128 (0,
+					     "View list begin (%s)",
+					     list_head->vl_symbol);
+
+	      if (!ZERO_VIEW_P (curr->vend))
+		{
+		  ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
+		  dw2_asm_output_symname_uleb128 (label,
+						  "View list end (%s)",
+						  list_head->vl_symbol);
+		}
+	      else
+		dw2_asm_output_data_uleb128 (0,
+					     "View list end (%s)",
+					     list_head->vl_symbol);
 	    }
 	  else
-	    dw2_asm_output_data_uleb128 (0,
-					 "View list begin (%s)",
-					 list_head->vl_symbol);
-
-	  if (!ZERO_VIEW_P (curr->vend))
 	    {
-	      ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
-	      dw2_asm_output_symname_uleb128 (label,
-					      "View list end (%s)",
-					      list_head->vl_symbol);
+	      dw2_asm_output_data_uleb128 (curr->vbegin,
+					   "View list begin (%s)",
+					   list_head->vl_symbol);
+	      dw2_asm_output_data_uleb128 (curr->vend,
+					   "View list end (%s)",
+					   list_head->vl_symbol);
 	    }
-	  else
-	    dw2_asm_output_data_uleb128 (0,
-					 "View list end (%s)",
-					 list_head->vl_symbol);
-#else /* !DWARF2_ASM_VIEW_DEBUG_INFO */
-	  dw2_asm_output_data_uleb128 (curr->vbegin,
-				       "View list begin (%s)",
-				       list_head->vl_symbol);
-	  dw2_asm_output_data_uleb128 (curr->vend,
-				       "View list end (%s)",
-				       list_head->vl_symbol);
-#endif
 	}
     }
 
@@ -23721,11 +23781,14 @@ add_high_low_attributes (tree stmt, dw_die_ref die)
     {
       inline_entry_data *ied = *iedp;
       gcc_assert (MAY_HAVE_DEBUG_MARKER_INSNS);
+      gcc_assert (debug_inline_points);
       gcc_assert (inlined_function_outer_scope_p (stmt));
+
       ASM_GENERATE_INTERNAL_LABEL (label, ied->label_pfx, ied->label_num);
       add_AT_lbl_id (die, DW_AT_entry_pc, label);
 
-      if (debug_variable_location_views && !ZERO_VIEW_P (ied->view))
+      if (debug_variable_location_views && !ZERO_VIEW_P (ied->view)
+	  && !dwarf_strict)
 	{
 	  if (!output_asm_line_debug_info ())
 	    add_AT_unsigned (die, DW_AT_GNU_entry_view, ied->view);
@@ -23756,7 +23819,7 @@ add_high_low_attributes (tree stmt, dw_die_ref die)
       dw_die_ref pdie;
       dw_attr_node *attr = NULL;
 
-      if (!MAY_HAVE_DEBUG_MARKER_INSNS && inlined_function_outer_scope_p (stmt))
+      if (!debug_inline_points && inlined_function_outer_scope_p (stmt))
 	{
 	  ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
 				       BLOCK_NUMBER (stmt));
@@ -23921,7 +23984,7 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die)
       dw_die_ref subr_die
 	= new_die (DW_TAG_inlined_subroutine, context_die, stmt);
 
-      if (call_arg_locations || MAY_HAVE_DEBUG_MARKER_INSNS)
+      if (call_arg_locations || debug_inline_points)
 	BLOCK_DIE (stmt) = subr_die;
       add_abstract_origin_attribute (subr_die, decl);
       if (TREE_ASM_WRITTEN (stmt))
@@ -26906,7 +26969,7 @@ dwarf2out_var_location (rtx_insn *loc_note)
     {
       if (CALL_P (loc_note))
 	{
-	  RESET_NEXT_VIEW (cur_line_info_table->view);
+	  maybe_reset_location_view (loc_note, cur_line_info_table);
 	  call_site_count++;
 	  if (SIBLING_CALL_P (loc_note))
 	    tail_call_site_count++;
@@ -26942,15 +27005,8 @@ dwarf2out_var_location (rtx_insn *loc_note)
 	}
       else if (!debug_variable_location_views)
 	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
-	       || GET_CODE (loc_note) == CLOBBER
-	       || GET_CODE (loc_note) == ASM_INPUT
-	       || asm_noperands (loc_note) >= 0)
-	;
-      else if (get_attr_min_length (loc_note) > 0)
-	RESET_NEXT_VIEW (cur_line_info_table->view);
+      else
+	maybe_reset_location_view (loc_note, cur_line_info_table);
 
       return;
     }
@@ -27219,6 +27275,8 @@ block_within_block_p (tree block, tree outer, bool bothways)
 static void
 dwarf2out_inline_entry (tree block)
 {
+  gcc_assert (debug_inline_points);
+
   /* If we can't represent it, don't bother.  */
   if (!(dwarf_version >= 3 || !dwarf_strict))
     return;
@@ -28233,7 +28291,7 @@ init_sections_and_labels (bool early_lto_debug)
       debug_str_section = get_section (DEBUG_LTO_STR_SECTION,
 				       DEBUG_STR_SECTION_FLAGS
 				       | SECTION_EXCLUDE, NULL);
-      if (!dwarf_split_debug_info && !DWARF2_ASM_LINE_DEBUG_INFO)
+      if (!dwarf_split_debug_info && !dwarf2out_as_loc_support)
 	debug_line_str_section
 	  = get_section (DEBUG_LTO_LINE_STR_SECTION,
 			 DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE, NULL);
@@ -31468,7 +31526,7 @@ dwarf2out_early_finish (const char *filename)
 
   /* When emitting DWARF5 .debug_line_str, move DW_AT_name and
      DW_AT_comp_dir into .debug_line_str section.  */
-  if (!DWARF2_ASM_LINE_DEBUG_INFO
+  if (!dwarf2out_as_loc_support
       && dwarf_version >= 5
       && DWARF5_USE_DEBUG_LINE_STR)
     {
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 61719606a36d..780cc1e08631 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -235,6 +235,12 @@ hook_int_rtx_1 (rtx)
   return 1;
 }
 
+int
+hook_int_rtx_insn_0 (rtx_insn *)
+{
+  return 0;
+}
+
 int
 hook_int_rtx_insn_unreachable (rtx_insn *)
 {
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 8caedd429a69..0ed5b952b48e 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -93,6 +93,7 @@ extern int hook_int_const_tree_0 (const_tree);
 extern int hook_int_const_tree_const_tree_1 (const_tree, const_tree);
 extern int hook_int_rtx_0 (rtx);
 extern int hook_int_rtx_1 (rtx);
+extern int hook_int_rtx_insn_0 (rtx_insn *);
 extern int hook_int_rtx_insn_unreachable (rtx_insn *);
 extern int hook_int_rtx_bool_0 (rtx, bool);
 extern int hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t,
diff --git a/gcc/target.def b/gcc/target.def
index aeb41df19454..c5b2a1e7e71f 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -6447,6 +6447,23 @@ This will suppress generation of the normal debug frame unwind information.",
  enum unwind_info_type, (void),
  default_debug_unwind_info)
 
+DEFHOOK
+(reset_location_view, "\
+This hook, if defined, enables -ginternal-reset-location-views, and\n\
+uses its result to override cases in which the estimated min insn\n\
+length might be nonzero even when a PC advance (i.e., a view reset)\n\
+cannot be taken for granted.\n\
+\n\
+If the hook is defined, it must return a positive value to indicate\n\
+the insn definitely advances the PC, and so the view number can be\n\
+safely assumed to be reset; a negative value to mean the insn\n\
+definitely does not advance the PC, and os the view number must not\n\
+be reset; or zero to decide based on the estimated insn length.\n\
+\n\
+If insn length is to be regarded as reliable, set the hook to\n\
+@code{hook_int_rtx_insn_0}.",
+ int, (rtx_insn *), NULL)
+
 /* The code parameter should be of type enum rtx_code but this is not
    defined at this time.  */
 DEFHOOK
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 23db0636fc79..b066bcc72297 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1558,13 +1558,23 @@ process_options (void)
 	     || write_symbols == VMS_AND_DWARF2_DEBUG)
 	 && !(flag_selective_scheduling || flag_selective_scheduling2));
 
+  if (dwarf2out_as_loc_support == AUTODETECT_VALUE)
+    dwarf2out_as_loc_support
+      = dwarf2out_default_as_loc_support ();
+  if (dwarf2out_as_locview_support == AUTODETECT_VALUE)
+    dwarf2out_as_locview_support
+      = dwarf2out_default_as_locview_support ();
+
   if (debug_variable_location_views == AUTODETECT_VALUE)
     {
-      debug_variable_location_views = flag_var_tracking
-	&& debug_info_level >= DINFO_LEVEL_NORMAL
-	&& (write_symbols == DWARF2_DEBUG
-	    || write_symbols == VMS_AND_DWARF2_DEBUG)
-	&& !dwarf_strict;
+      debug_variable_location_views
+	= (flag_var_tracking
+	   && debug_info_level >= DINFO_LEVEL_NORMAL
+	   && (write_symbols == DWARF2_DEBUG
+	       || write_symbols == VMS_AND_DWARF2_DEBUG)
+	   && !dwarf_strict
+	   && dwarf2out_as_loc_support
+	   && dwarf2out_as_locview_support);
     }
   else if (debug_variable_location_views == -1 && dwarf_version != 5)
     {
@@ -1574,6 +1584,31 @@ process_options (void)
       debug_variable_location_views = 1;
     }
 
+  if (debug_internal_reset_location_views == 2)
+    {
+      debug_internal_reset_location_views
+	= (debug_variable_location_views
+	   && targetm.reset_location_view);
+    }
+  else if (debug_internal_reset_location_views
+	   && !debug_variable_location_views)
+    {
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-ginternal-reset-location-views is forced disabled "
+		  "without -gvariable-location-views");
+      debug_internal_reset_location_views = 0;
+    }
+
+  if (debug_inline_points == AUTODETECT_VALUE)
+    debug_inline_points = debug_variable_location_views;
+  else if (debug_inline_points && !debug_nonbind_markers_p)
+    {
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-ginline-points is forced disabled without "
+		  "-gstatement-frontiers");
+      debug_inline_points = 0;
+    }
+
   if (flag_tree_cselim == AUTODETECT_VALUE)
     {
       if (HAVE_conditional_move)
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 7f9ec770e197..811829e85299 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4605,7 +4605,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
 			GSI_NEW_STMT);
     }
   initialize_inlined_parameters (id, stmt, fn, bb);
-  if (debug_nonbind_markers_p && id->block
+  if (debug_nonbind_markers_p && debug_inline_points && id->block
       && inlined_function_outer_scope_p (id->block))
     {
       gimple_stmt_iterator si = gsi_last_bb (bb);
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 26da31f74cb2..62bb3c5de659 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -522,7 +522,7 @@ remove_unused_scope_block_p (tree scope, bool in_ctor_dtor_block)
      unused = false;
    /* Preserve the block, it is referenced by at least the inline
       entry point marker.  */
-   else if (debug_nonbind_markers_p
+   else if (debug_inline_points
 	    && inlined_function_outer_scope_p (scope))
      unused = false;
    /* Innermost blocks with no live variables nor statements can be always
@@ -558,7 +558,7 @@ remove_unused_scope_block_p (tree scope, bool in_ctor_dtor_block)
       with block_ultimate_origin being set to FUNCTION_DECL and
       DECL_SOURCE_LOCATION set, unless they expand to nothing...  But
       see above for the case of statement frontiers.  */
-   else if (!debug_nonbind_markers_p
+   else if (!debug_inline_points
 	    && inlined_function_outer_scope_p (scope))
      unused = false;
    else


-- 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]