summaryrefslogtreecommitdiff
path: root/gcc/final.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-05-02 14:43:35 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-05-02 14:43:35 +0000
commit34efdaf078b01a7387007c4e6bde6db86384c4b7 (patch)
treed503eaf41d085669d1481bb46ec038bc866fece6 /gcc/final.c
parentf733cf303bcdc952c92b81dd62199a40a1f555ec (diff)
downloadgcc-tarball-master.tar.gz
gcc-7.1.0gcc-7.1.0
Diffstat (limited to 'gcc/final.c')
-rw-r--r--gcc/final.c79
1 files changed, 63 insertions, 16 deletions
diff --git a/gcc/final.c b/gcc/final.c
index 55cf509611..820162b2d2 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -1,5 +1,5 @@
/* Convert RTL to assembler code and output it, for GNU compiler.
- Copyright (C) 1987-2016 Free Software Foundation, Inc.
+ Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GCC.
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "cfghooks.h"
#include "df.h"
+#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
#include "regs.h"
@@ -117,6 +118,9 @@ rtx_insn *current_output_insn;
/* Line number of last NOTE. */
static int last_linenum;
+/* Column number of last NOTE. */
+static int last_columnnum;
+
/* Last discriminator written to assembly. */
static int last_discriminator;
@@ -132,9 +136,10 @@ static int high_function_linenum;
/* Filename of last NOTE. */
static const char *last_filename;
-/* Override filename and line number. */
+/* Override filename, line and column number. */
static const char *override_filename;
static int override_linenum;
+static int override_columnnum;
/* Whether to force emission of a line note before the next insn. */
static bool force_source_line = false;
@@ -213,7 +218,7 @@ static void leaf_renumber_regs (rtx_insn *);
static int alter_cond (rtx);
#endif
#ifndef ADDR_VEC_ALIGN
-static int final_addr_vec_align (rtx);
+static int final_addr_vec_align (rtx_insn *);
#endif
static int align_fuzz (rtx, rtx, int, unsigned);
static void collect_fn_hard_reg_usage (void);
@@ -512,7 +517,7 @@ default_jump_align_max_skip (rtx_insn *insn ATTRIBUTE_UNUSED)
#ifndef ADDR_VEC_ALIGN
static int
-final_addr_vec_align (rtx addr_vec)
+final_addr_vec_align (rtx_insn *addr_vec)
{
int align = GET_MODE_SIZE (GET_MODE (PATTERN (addr_vec)));
@@ -1462,7 +1467,7 @@ shorten_branches (rtx_insn *first)
if (!increasing)
break;
}
-
+ crtl->max_insn_address = insn_current_address;
free (varying_length);
}
@@ -1762,6 +1767,7 @@ final_start_function (rtx_insn *first, FILE *file,
last_filename = LOCATION_FILE (prologue_location);
last_linenum = LOCATION_LINE (prologue_location);
+ last_columnnum = LOCATION_COLUMN (prologue_location);
last_discriminator = discriminator = 0;
high_block_linenum = high_function_linenum = last_linenum;
@@ -1770,10 +1776,10 @@ final_start_function (rtx_insn *first, FILE *file,
asan_function_start ();
if (!DECL_IGNORED_P (current_function_decl))
- debug_hooks->begin_prologue (last_linenum, last_filename);
+ debug_hooks->begin_prologue (last_linenum, last_columnnum, last_filename);
if (!dwarf2_debug_info_emitted_p (current_function_decl))
- dwarf2out_begin_prologue (0, NULL);
+ dwarf2out_begin_prologue (0, 0, NULL);
#ifdef LEAF_REG_REMAP
if (crtl->uses_only_leaf_regs)
@@ -2096,9 +2102,11 @@ output_alternate_entry_point (FILE *file, rtx_insn *insn)
case LABEL_WEAK_ENTRY:
#ifdef ASM_WEAKEN_LABEL
ASM_WEAKEN_LABEL (file, name);
+ gcc_fallthrough ();
#endif
case LABEL_GLOBAL_ENTRY:
targetm.asm_out.globalize_label (file, name);
+ gcc_fallthrough ();
case LABEL_STATIC_ENTRY:
#ifdef ASM_OUTPUT_TYPE_DIRECTIVE
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
@@ -2140,6 +2148,26 @@ call_from_call_insn (rtx_call_insn *insn)
return x;
}
+/* Print a comment into the asm showing FILENAME, LINENUM, and the
+ corresponding source line, if available. */
+
+static void
+asm_show_source (const char *filename, int linenum)
+{
+ if (!filename)
+ return;
+
+ int line_size;
+ const char *line = location_get_source_line (filename, linenum, &line_size);
+ if (!line)
+ return;
+
+ fprintf (asm_out_file, "%s %s:%i: ", ASM_COMMENT_START, filename, linenum);
+ /* "line" is not 0-terminated, so we must use line_size. */
+ fwrite (line, 1, line_size, asm_out_file);
+ fputc ('\n', asm_out_file);
+}
+
/* The final scan for one insn, INSN.
Args are same as in `final', except that INSN
is the insn being scanned.
@@ -2300,6 +2328,7 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
/* Mark this block as output. */
TREE_ASM_WRITTEN (NOTE_BLOCK (insn)) = 1;
+ BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn)) = in_cold_section_p;
}
if (write_symbols == DBX_DEBUG
|| write_symbols == SDB_DEBUG)
@@ -2311,6 +2340,7 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
{
override_filename = LOCATION_FILE (*locus_ptr);
override_linenum = LOCATION_LINE (*locus_ptr);
+ override_columnnum = LOCATION_COLUMN (*locus_ptr);
}
}
break;
@@ -2332,6 +2362,8 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
if (!DECL_IGNORED_P (current_function_decl))
debug_hooks->end_block (high_block_linenum, n);
+ gcc_assert (BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn))
+ == in_cold_section_p);
}
if (write_symbols == DBX_DEBUG
|| write_symbols == SDB_DEBUG)
@@ -2344,11 +2376,13 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
{
override_filename = LOCATION_FILE (*locus_ptr);
override_linenum = LOCATION_LINE (*locus_ptr);
+ override_columnnum = LOCATION_COLUMN (*locus_ptr);
}
else
{
override_filename = NULL;
override_linenum = 0;
+ override_columnnum = 0;
}
}
break;
@@ -2563,8 +2597,17 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
note in a row. */
if (!DECL_IGNORED_P (current_function_decl)
&& notice_source_line (insn, &is_stmt))
- (*debug_hooks->source_line) (last_linenum, last_filename,
- last_discriminator, is_stmt);
+ {
+ if (flag_verbose_asm)
+ asm_show_source (last_filename, last_linenum);
+ (*debug_hooks->source_line) (last_linenum, last_columnnum,
+ last_filename, last_discriminator,
+ is_stmt);
+ }
+
+ if (GET_CODE (body) == PARALLEL
+ && GET_CODE (XVECEXP (body, 0, 0)) == ASM_INPUT)
+ body = XVECEXP (body, 0, 0);
if (GET_CODE (body) == ASM_INPUT)
{
@@ -3044,23 +3087,26 @@ static bool
notice_source_line (rtx_insn *insn, bool *is_stmt)
{
const char *filename;
- int linenum;
+ int linenum, columnnum;
if (override_filename)
{
filename = override_filename;
linenum = override_linenum;
+ columnnum = override_columnnum;
}
else if (INSN_HAS_LOCATION (insn))
{
expanded_location xloc = insn_location (insn);
filename = xloc.file;
linenum = xloc.line;
+ columnnum = xloc.column;
}
else
{
filename = NULL;
linenum = 0;
+ columnnum = 0;
}
if (filename == NULL)
@@ -3068,11 +3114,13 @@ notice_source_line (rtx_insn *insn, bool *is_stmt)
if (force_source_line
|| filename != last_filename
- || last_linenum != linenum)
+ || last_linenum != linenum
+ || (debug_column_info && last_columnnum != columnnum))
{
force_source_line = false;
last_filename = filename;
last_linenum = linenum;
+ last_columnnum = columnnum;
last_discriminator = discriminator;
*is_stmt = true;
high_block_linenum = MAX (last_linenum, high_block_linenum);
@@ -3795,7 +3843,7 @@ output_asm_label (rtx x)
char buf[256];
if (GET_CODE (x) == LABEL_REF)
- x = LABEL_REF_LABEL (x);
+ x = label_ref_label (x);
if (LABEL_P (x)
|| (NOTE_P (x)
&& NOTE_KIND (x) == NOTE_INSN_DELETED_LABEL))
@@ -3886,7 +3934,7 @@ output_addr_const (FILE *file, rtx x)
break;
case LABEL_REF:
- x = LABEL_REF_LABEL (x);
+ x = label_ref_label (x);
/* Fall through. */
case CODE_LABEL:
ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
@@ -4450,8 +4498,6 @@ rest_of_handle_final (void)
assemble_end_function (current_function_decl, fnname);
- user_defined_section_attribute = false;
-
/* Free up reg info memory. */
free_reg_info ();
@@ -4667,7 +4713,8 @@ rest_of_clean_state (void)
free_bb_for_insn ();
- delete_tree_ssa (cfun);
+ if (cfun->gimple_df)
+ delete_tree_ssa (cfun);
/* We can reduce stack alignment on call site only when we are sure that
the function body just produced will be actually used in the final