This cleans up some left-overs of the transition from locators to locations in
the RTL middle-end, most notably direct comparisons against UNKNOWN_LOCATION,
and adds an insn_location function to be called instead of using insn_file and
insn_line in a row.
Tested on x86_64-suse-linux, applied on the mainline.
2014-06-06 Eric Botcazou <ebotca...@adacore.com>
* rtl.h (insn_location): Declare.
* cfgcleanup.c (try_forward_edges): Compare the locus of locations
with UNKNOWN_LOCATION.
* emit-rtl.c (insn_location): New function.
* final.c (notice_source_line): Check that the instruction has a
location before retrieving it and use insn_location.
* modulo-sched.c (loop_single_full_bb_p): Likewise.
* print-rtl.c (print_rtx): Likewise.
--
Eric Botcazou
Index: rtl.h
===================================================================
--- rtl.h (revision 211101)
+++ rtl.h (working copy)
@@ -2130,6 +2130,7 @@ extern rtx prev_cc0_setter (rtx);
extern int insn_line (const_rtx);
extern const char * insn_file (const_rtx);
extern tree insn_scope (const_rtx);
+extern expanded_location insn_location (const_rtx);
extern location_t prologue_location, epilogue_location;
/* In jump.c */
Index: cfgcleanup.c
===================================================================
--- cfgcleanup.c (revision 211101)
+++ cfgcleanup.c (working copy)
@@ -482,31 +482,30 @@ try_forward_edges (int mode, basic_block
location_t new_locus = single_succ_edge (target)->goto_locus;
location_t locus = goto_locus;
- if (new_locus != UNKNOWN_LOCATION
- && locus != UNKNOWN_LOCATION
+ if (LOCATION_LOCUS (new_locus) != UNKNOWN_LOCATION
+ && LOCATION_LOCUS (locus) != UNKNOWN_LOCATION
&& new_locus != locus)
new_target = NULL;
else
{
- rtx last;
-
- if (new_locus != UNKNOWN_LOCATION)
+ if (LOCATION_LOCUS (new_locus) != UNKNOWN_LOCATION)
locus = new_locus;
- last = BB_END (target);
+ rtx last = BB_END (target);
if (DEBUG_INSN_P (last))
last = prev_nondebug_insn (last);
+ if (last && INSN_P (last))
+ new_locus = INSN_LOCATION (last);
+ else
+ new_locus = UNKNOWN_LOCATION;
- new_locus = last && INSN_P (last)
- ? INSN_LOCATION (last) : 0;
-
- if (new_locus != UNKNOWN_LOCATION
- && locus != UNKNOWN_LOCATION
+ if (LOCATION_LOCUS (new_locus) != UNKNOWN_LOCATION
+ && LOCATION_LOCUS (locus) != UNKNOWN_LOCATION
&& new_locus != locus)
new_target = NULL;
else
{
- if (new_locus != UNKNOWN_LOCATION)
+ if (LOCATION_LOCUS (new_locus) != UNKNOWN_LOCATION)
locus = new_locus;
goto_locus = locus;
Index: emit-rtl.c
===================================================================
--- emit-rtl.c (revision 211101)
+++ emit-rtl.c (working copy)
@@ -6173,6 +6173,13 @@ insn_file (const_rtx insn)
return LOCATION_FILE (INSN_LOCATION (insn));
}
+/* Return expanded location of the statement that produced this insn. */
+expanded_location
+insn_location (const_rtx insn)
+{
+ return expand_location (INSN_LOCATION (insn));
+}
+
/* Return true if memory model MODEL requires a pre-operation (release-style)
barrier or a post-operation (acquire-style) barrier. While not universal,
this function matches behavior of several targets. */
Index: final.c
===================================================================
--- final.c (revision 211101)
+++ final.c (working copy)
@@ -3019,10 +3019,16 @@ notice_source_line (rtx insn, bool *is_s
filename = override_filename;
linenum = override_linenum;
}
+ else if (INSN_HAS_LOCATION (insn))
+ {
+ expanded_location xloc = insn_location (insn);
+ filename = xloc.file;
+ linenum = xloc.line;
+ }
else
{
- filename = insn_file (insn);
- linenum = insn_line (insn);
+ filename = NULL;
+ linenum = 0;
}
if (filename == NULL)
Index: modulo-sched.c
===================================================================
--- modulo-sched.c (revision 211101)
+++ modulo-sched.c (working copy)
@@ -1244,11 +1244,10 @@ loop_single_full_bb_p (struct loop *loop
static void
dump_insn_location (rtx insn)
{
- if (dump_file && INSN_LOCATION (insn))
+ if (dump_file && INSN_HAS_LOCATION (insn))
{
- const char *file = insn_file (insn);
- if (file)
- fprintf (dump_file, " %s:%i", file, insn_line (insn));
+ expanded_location xloc = insn_location (insn);
+ fprintf (dump_file, " %s:%i", xloc.file, xloc.line);
}
}
Index: print-rtl.c
===================================================================
--- print-rtl.c (revision 211101)
+++ print-rtl.c (working copy)
@@ -395,9 +395,11 @@ print_rtx (const_rtx in_rtx)
/* Pretty-print insn locations. Ignore scoping as it is mostly
redundant with line number information and do not print anything
when there is no location information available. */
- if (INSN_LOCATION (in_rtx) && insn_file (in_rtx))
- fprintf (outfile, " %s:%i", insn_file (in_rtx),
- insn_line (in_rtx));
+ if (INSN_HAS_LOCATION (in_rtx))
+ {
+ expanded_location xloc = insn_location (in_rtx);
+ fprintf (outfile, " %s:%i", xloc.file, xloc.line);
+ }
#endif
}
else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)