Commit Graph

616 Commits

Author SHA1 Message Date
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Richard Sandiford 13e08dc939 Add a loop versioning pass
This patch adds a pass that versions loops with variable index strides
for the case in which the stride is 1.  E.g.:

    for (int i = 0; i < n; ++i)
      x[i * stride] = ...;

becomes:

    if (stepx == 1)
      for (int i = 0; i < n; ++i)
        x[i] = ...;
    else
      for (int i = 0; i < n; ++i)
        x[i * stride] = ...;

This is useful for both vector code and scalar code, and in some cases
can enable further optimisations like loop interchange or pattern
recognition.

The pass gives a 7.6% improvement on Cortex-A72 for 554.roms_r at -O3
and a 2.4% improvement for 465.tonto.  I haven't found any SPEC tests
that regress.

Sizewise, there's a 10% increase in .text for both 554.roms_r and
465.tonto.  That's obviously a lot, but in tonto's case it's because
the whole program is written using assumed-shape arrays and pointers,
so a large number of functions really do benefit from versioning.
roms likewise makes heavy use of assumed-shape arrays, and that
improvement in performance IMO justifies the code growth.

The next biggest .text increase is 4.5% for 548.exchange2_r.  I did see
a small (0.4%) speed improvement there, but although both 3-iteration runs
produced stable results, that might still be noise.  There was a slightly
larger (non-noise) improvement for a 256-bit SVE model.

481.wrf and 521.wrf_r .text grew by 2.8% and 2.5% respectively, but
without any noticeable improvement in performance.  No other test grew
by more than 2%.

Although the main SPEC beneficiaries are all Fortran tests, the
benchmarks we use for SVE also include some C and C++ tests that
benefit.

Using -frepack-arrays gives the same benefits in many Fortran cases.
The problem is that using that option inappropriately can force a full
array copy for arguments that the function only reads once, and so it
isn't really something we can turn on by default.  The new pass is
supposed to give most of the benefits of -frepack-arrays without
the risk of unnecessary repacking.

The patch therefore enables the pass by default at -O3.

2018-12-17  Richard Sandiford  <richard.sandiford@arm.com>
	    Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
	    Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

gcc/
	* doc/invoke.texi (-fversion-loops-for-strides): Document
	(loop-versioning-group-size, loop-versioning-max-inner-insns)
	(loop-versioning-max-outer-insns): Document new --params.
	* Makefile.in (OBJS): Add gimple-loop-versioning.o.
	* common.opt (fversion-loops-for-strides): New option.
	* opts.c (default_options_table): Enable fversion-loops-for-strides
	at -O3.
	* params.def (PARAM_LOOP_VERSIONING_GROUP_SIZE)
	(PARAM_LOOP_VERSIONING_MAX_INNER_INSNS)
	(PARAM_LOOP_VERSIONING_MAX_OUTER_INSNS): New parameters.
	* passes.def: Add pass_loop_versioning.
	* timevar.def (TV_LOOP_VERSIONING): New time variable.
	* tree-ssa-propagate.h
	(substitute_and_fold_engine::substitute_and_fold): Add an optional
	block parameter.
	* tree-ssa-propagate.c
	(substitute_and_fold_engine::substitute_and_fold): Likewise.
	When passed, only walk blocks dominated by that block.
	* tree-vrp.h (range_includes_p): Declare.
	(range_includes_zero_p): Turn into an inline wrapper around
	range_includes_p.
	* tree-vrp.c (range_includes_p): New function, generalizing...
	(range_includes_zero_p): ...this.
	* tree-pass.h (make_pass_loop_versioning): Declare.
	* gimple-loop-versioning.cc: New file.

gcc/testsuite/
	* gcc.dg/loop-versioning-1.c: New test.
	* gcc.dg/loop-versioning-10.c: Likewise.
	* gcc.dg/loop-versioning-11.c: Likewise.
	* gcc.dg/loop-versioning-2.c: Likewise.
	* gcc.dg/loop-versioning-3.c: Likewise.
	* gcc.dg/loop-versioning-4.c: Likewise.
	* gcc.dg/loop-versioning-5.c: Likewise.
	* gcc.dg/loop-versioning-6.c: Likewise.
	* gcc.dg/loop-versioning-7.c: Likewise.
	* gcc.dg/loop-versioning-8.c: Likewise.
	* gcc.dg/loop-versioning-9.c: Likewise.
	* gfortran.dg/loop_versioning_1.f90: Likewise.
	* gfortran.dg/loop_versioning_2.f90: Likewise.
	* gfortran.dg/loop_versioning_3.f90: Likewise.
	* gfortran.dg/loop_versioning_4.f90: Likewise.
	* gfortran.dg/loop_versioning_5.f90: Likewise.
	* gfortran.dg/loop_versioning_6.f90: Likewise.
	* gfortran.dg/loop_versioning_7.f90: Likewise.
	* gfortran.dg/loop_versioning_8.f90: Likewise.

From-SVN: r267197
2018-12-17 10:05:51 +00:00
Qing Zhao 6fd6a2ffee Add a new option -flive-patching={inline-only-static|inline-clone}
to support live patching in GCC.

2018-11-29  qing zhao  <qing.zhao@oracle.com>

gcc/ChangeLog:

	* cif-code.def (EXTERN_LIVE_ONLY_STATIC): New CIF code.
	* common.opt: Add -flive-patching flag.
	* doc/invoke.texi: Document -flive-patching.
	* flag-types.h (enum live_patching_level): New enum.
	* ipa-inline.c (can_inline_edge_p): Disable external functions from
	inlining when flag_live_patching is LIVE_PATCHING_INLINE_ONLY_STATIC.
	* opts.c (control_options_for_live_patching): New function.
	(finish_options): Make flag_live_patching incompatible with flag_lto.
	Control IPA optimizations based on different levels of 
	flag_live_patching.

gcc/testsuite/ChangeLog:

	* gcc.dg/live-patching-1.c: New test.
	* gcc.dg/live-patching-2.c: New test.
	* gcc.dg/live-patching-3.c: New test.
	* gcc.dg/tree-ssa/writeonly-3.c: New test.
	* gcc.target/i386/ipa-stack-alignment-2.c: New test.

From-SVN: r266627
2018-11-29 16:06:03 +00:00
David Malcolm 478dd60ddc Machine-readable diagnostic output (PR other/19165)
This patch implements a -fdiagnostics-format=json option which
converts the diagnostics to be output to stderr in a JSON format;
see the documentation in invoke.texi.

Logically-related diagnostics are nested at the JSON level, using
the auto_diagnostic_group mechanism.

gcc/ChangeLog:
	PR other/19165
	* Makefile.in (OBJS): Move json.o to...
	(OBJS-libcommon): ...here and add diagnostic-format-json.o.
	* common.opt (fdiagnostics-format=): New option.
	(diagnostics_output_format): New enum.
	* diagnostic-format-json.cc: New file.
	* diagnostic.c (default_diagnostic_final_cb): New function, taken
	from start of diagnostic_finish.
	(diagnostic_initialize): Initialize final_cb to
	default_diagnostic_final_cb.
	(diagnostic_finish): Move "being treated as errors" messages to
	default_diagnostic_final_cb.  Call any final_cb.
	(default_diagnostic_finalizer): Add diagnostic_t param.
	(diagnostic_report_diagnostic): Pass "orig_diag_kind" to
	diagnostic_finalizer callback.
	* diagnostic.h (enum diagnostics_output_format): New enum.
	(diagnostic_finalizer_fn): Reimplement, adding diagnostic_t param.
	(struct diagnostic_context): Add "final_cb".
	(default_diagnostic_finalizer): Add diagnostic_t param.
	(diagnostic_output_format_init): New decl.
	* doc/invoke.texi (-fdiagnostics-format): New option.
	* dwarf2out.c (gen_producer_string): Ignore
	OPT_fdiagnostics_format_.
	* gcc.c (driver_handle_option): Handle OPT_fdiagnostics_format_.
	* lto-wrapper.c (append_diag_options): Ignore it.
	* opts.c (common_handle_option): Handle it.

gcc/c-family/ChangeLog:
	PR other/19165
	* c-opts.c (c_diagnostic_finalizer): Add diagnostic_t param.

gcc/fortran/ChangeLog:
	PR other/19165
	* error.c (gfc_diagnostic_finalizer): Add diagnostic_t param.

gcc/jit/ChangeLog:
	PR other/19165
	* dummy-frontend.c (jit_begin_diagnostic): Add diagnostic_t param.

gcc/testsuite/ChangeLog:
	PR other/19165
	* c-c++-common/diagnostic-format-json-1.c: New test.
	* c-c++-common/diagnostic-format-json-2.c: New test.
	* c-c++-common/diagnostic-format-json-3.c: New test.
	* c-c++-common/diagnostic-format-json-4.c: New test.
	* c-c++-common/diagnostic-format-json-5.c: New test.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
	(custom_diagnostic_finalizer): Add diagnostic_t param.
	* gcc.dg/plugin/location_overflow_plugin.c
	(verify_unpacked_ranges): Likewise.
	(verify_no_columns): Likewise.
	* gfortran.dg/diagnostic-format-json-1.F90: New test.
	* gfortran.dg/diagnostic-format-json-2.F90: New test.
	* gfortran.dg/diagnostic-format-json-3.F90: New test.

From-SVN: r266186
2018-11-15 14:32:41 +00:00
Martin Liska e18240ffe2 Instrument only selected files (PR gcov-profile/87442).
2018-11-12  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/87442
	* common.opt: Add -fprofile-filter-files and -fprofile-exclude-files
	options.
	* doc/invoke.texi: Document them.
	* tree-profile.c (parse_profile_filter): New.
	(parse_profile_file_filtering): Likewise.
	(release_profile_file_filtering): Likewise.
	(include_source_file_for_profile): Likewise.
	(tree_profiling): Filter source files based on the
	newly added options.
2018-11-12  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/87442
	* gcc.dg/profile-filtering-1.c: New test.
	* gcc.dg/profile-filtering-2.c: New test.

From-SVN: r266037
2018-11-12 21:01:38 +00:00
Martin Sebor 79a2c4281c PR middle-end/81824 - Warn for missing attributes with function aliases
gcc/c-family/ChangeLog:

	PR middle-end/81824
	* c-attribs.c (handle_copy_attribute): New function.

gcc/cp/ChangeLog:

	PR middle-end/81824
	* pt.c (warn_spec_missing_attributes): Move code to attribs.c.
	Call decls_mismatched_attributes.

gcc/ChangeLog:

	PR middle-end/81824
	* attribs.c (has_attribute): New helper function.
	(decls_mismatched_attributes, maybe_diag_alias_attributes): Same.
	* attribs.h (decls_mismatched_attributes): Declare.
	* cgraphunit.c (handle_alias_pairs): Call maybe_diag_alias_attributes.
	(maybe_diag_incompatible_alias): Use OPT_Wattribute_alias_.
	* common.opt (-Wattribute-alias): Take an argument.
	(-Wno-attribute-alias): New option.
	* doc/extend.texi (Common Function Attributes): Document copy.
	(Common Variable Attributes): Same.
	* doc/invoke.texi (-Wmissing-attributes): Document enhancement.
	(-Wattribute-alias): Document new option argument.

gcc/testsuite/ChangeLog:

	PR middle-end/81824
	* gcc.dg/Wattribute-alias.c: New test.
	* gcc.dg/Wmissing-attributes.c: New test.
	* gcc.dg/attr-copy.c: New test.
	* gcc.dg/attr-copy-2.c: New test.
	* gcc.dg/attr-copy-3.c: New test.
	* gcc.dg/attr-copy-4.c: New test.

From-SVN: r265980
2018-11-09 10:32:52 -07:00
Martin Liska 47b840eb39 Come up with the flag -fipa-stack-alignment.
2018-11-09  Martin Liska  <mliska@suse.cz>

	* common.opt: Add -fipa-stack-alignment flag.
	* doc/invoke.texi: Document it.
	* final.c (rest_of_clean_state): Guard stack
	shrinking with flag.
2018-11-09  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/ipa-stack-alignment.c: New test.

From-SVN: r265970
2018-11-09 15:05:40 +00:00
Martin Liska 2e14744fcd Come up with -fipa-reference-addressable flag.
2018-11-09  Martin Liska  <mliska@suse.cz>

	* cgraph.h (ipa_discover_readonly_nonaddressable_vars): Rename
	to ...
	(ipa_discover_variable_flags): ... this.
	* common.opt: Come up with new flag -fipa-reference-addressable.
	* doc/invoke.texi: Document it.
	* ipa-reference.c (propagate): Call the renamed fn.
	* ipa-visibility.c (whole_program_function_and_variable_visibility):
	Likewise.
	* ipa.c (ipa_discover_readonly_nonaddressable_vars): Renamed to
	...
	(ipa_discover_variable_flags): ... this.  Discover
	non-addressable variables only with the newly added flag.
	* opts.c: Enable the newly added flag with -O1 and higher
	optimization level.
2018-11-09  Martin Liska  <mliska@suse.cz>

	* gcc.dg/tree-ssa/writeonly-2.c: New test.

From-SVN: r265969
2018-11-09 15:04:52 +00:00
Roman Geissler d69ac8b7f8 collect2.c (linker_select): Add USE_LLD_LD.
* collect2.c (linker_select):  Add USE_LLD_LD.
	(ld_suffixes): Add ld.lld.
	(main): Handle -fuse-ld=lld.
	* common.opt (-fuse-ld=lld): New option.
	* doc/invoke.texi (-fuse-ld=lld): Document.
	* opts.c (common_handle_option): Handle OPT_fuse_ld_lld.

From-SVN: r265940
2018-11-08 15:05:27 -07:00
Nikolai Merinov e217792bed common.opt: Add -Wattribute-warning.
* common.opt: Add -Wattribute-warning.
         * doc/invoke.texi: Add documentation for -Wno-attribute-warning.
         * expr.c (expand_expr_real_1): Add new attribute to warning_at
         call to allow user configure behavior of "warning" attribute.

         * gcc.dg/Wno-attribute-warning.c: New test.

From-SVN: r265891
2018-11-07 14:02:27 -07:00
David Malcolm 0141ab44c5 diagnostics: add minimum width to left margin for line numbers
This patch adds a minimum width to the left margin used for printing
line numbers.   I set the default to 6.  Hence rather than:

some-filename:9:1: some message
9 | some source text
  | ^~~~~~~~~~~~~~~~
some-filename:10:1: another message
10 | more source text
   | ^~~~~~~~~~~~~~~~

we now print:

some-filename:9:42: some message
    9 | some source text
      | ^~~~~~~~~~~~~~~~
some-filename:10:42: another message
   10 | more source text
      | ^~~~~~~~~~~~~~~~

This implicitly fixes issues with margins failing to line up due
to different lengths of the number when we haven't read the full
file yet and so don't know the highest possible line number, for
line numbers up to 99999.

Doing so adds some whitespace on the left-hand side, for non-huge
files, at least.  I believe that this makes it easier to see where each
diagnostic starts, by visually breaking things up at the leftmost
column; my hope is to make it easier for the eye to see the different
diagnostics as if they were different "paragraphs".

gcc/ChangeLog:
	* common.opt (fdiagnostics-minimum-margin-width=): New option.
	* diagnostic-show-locus.c (layout::layout): Apply the minimum
	margin width.
	(layout::start_annotation_line): Only print up to 3 of the
	margin character, to avoid touching the left-hand side.
	(selftest::test_diagnostic_show_locus_fixit_lines): Update for
	minimum margin width, as set by test_diagnostic_context's ctor.
	(selftest::test_fixit_insert_containing_newline): Likewise.
	(selftest::test_fixit_insert_containing_newline_2): Likewise.
	(selftest::test_line_numbers_multiline_range): Clear
	dc.min_margin_width.
	* diagnostic.c (diagnostic_initialize): Initialize
	min_margin_width.
	* diagnostic.h (struct diagnostic_context): Add field
	"min_margin_width".
	* doc/invoke.texi: Add -fdiagnostics-minimum-margin-width=.
	* opts.c (common_handle_option): Handle
	OPT_fdiagnostics_minimum_margin_width_.
	* selftest-diagnostic.c
	(selftest::test_diagnostic_context::test_diagnostic_context):
	Initialize min_margin_width to 6.
	* toplev.c (general_init): Initialize global_dc->min_margin_width.

gcc/testsuite/ChangeLog:
	* gcc.dg/missing-header-fixit-3.c: Update expected indentation
	to reflect minimum margin width.
	* gcc.dg/missing-header-fixit-4.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c:
	Likewise.
	* gcc.dg/plugin/diagnostic-test-show-locus-color-line-numbers.c:
	Likewise.
	* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers-2.c:
	New test.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add it.

From-SVN: r265178
2018-10-15 22:16:59 +00:00
Indu Bhagat bc162b0e6f re PR gcov-profile/86957 (gcc should warn about missing profiles for a compilation unit or a new function with -fprofile-use)
2018-09-26  Indu Bhagat  <indu.bhagat@oracle.com>

	PR gcov-profile/86957
	* common.opt: New warning option -Wmissing-profile.
	* coverage.c (get_coverage_counts): Add warning for missing .gcda file.
	* doc/invoke.texi: Document -Wmissing-profile.

From-SVN: r264657
2018-09-26 22:29:54 +00:00
Tom de Vries 03e992acea [debug] Add -gdescribe-dies
This patch adds option -gdescribe-dies.  It sets the DW_AT_description
attribute of dies that do not get a DW_AT_name attribute, to make it easier
to figure out what the die is describing.

The option exports the names of artificial variables:
...
 DIE    0: DW_TAG_variable (0x7fa934dd54b0)
+  DW_AT_description: "D.1922"
   DW_AT_type: die -> 0 (0x7fa934dd0d70)
   DW_AT_artificial: 1

...
which can be traced back to gimple dumps:
...
  char a[0:D.1922] [value-expr: *a.0];
...

Furthermore, it adds names to external references:
...
 DIE    0: DW_TAG_subprogram (0x7fa88b9650f0)
+DW_AT_description: "main"
 DW_AT_abstract_origin: die -> label: vla_1.c.6719312a + 29 (0x7fa88b965140)
...
and likewise to DW_TAG_call_site_parameter DIEs.

Bootstrapped and reg-tested on x86_64.

2018-09-12  Tom de Vries  <tdevries@suse.de>

	* common.opt (gdescribe-dies): Add option.
	* dwarf2out.c (add_name_and_src_coords_attributes): Add description
	attribute for artifical and nameless decls.
	(dwarf2out_register_external_die): Add description attribute to
	external reference die.
	(add_desc_attribute): New functions.
	(gen_subprogram_die): Add description attribute to
	DW_TAG_call_site_parameter.
	* tree-pretty-print.c (print_generic_expr_to_str): New function.
	* tree-pretty-print.h (print_generic_expr_to_str): Declare.
	* doc/invoke.texi (@item Debugging Options): Add -gdescribe-dies and
	-gno-describe-dies.
	(@item -gdescribe-dies): Add.

From-SVN: r264229
2018-09-12 07:27:26 +00:00
Martin Liska c0c1235622 Merge Ignore and Deprecated in .opt files.
2018-08-17  Martin Liska  <mliska@suse.cz>

	* common.opt: Remove Warn, Init and Report for options with
        Ignore/Deprecated flag. Warning is done automatically for
        Deprecated flags.
	* config/i386/i386.opt: Likewise.
	* config/ia64/ia64.opt: Likewise.
	* config/rs6000/rs6000.opt: Likewise.
	* cppbuiltin.c (define_builtin_macros_for_compilation_flags):
        Remove usage of flag_check_pointer_bounds.
	* lto-wrapper.c (merge_and_complain): Do not handle
        OPT_fcheck_pointer_bounds.
	(append_compiler_options): Likewise.
	* opt-functions.awk: Do not handle Deprecated.
	* optc-gen.awk: Check that Var, Report and Init are not
        used for an option with Ignore/Deprecated flag.
	* opts-common.c (decode_cmdline_option): Do not report
        CL_ERR_DEPRECATED.
	(read_cmdline_option): Report warning for OPT_SPECIAL_deprecated
        options.
	* opts.h (struct cl_option): Remove cl_deprecated flag.
	(CL_ERR_DEPRECATED): Remove error enum value.
2018-08-17  Martin Liska  <mliska@suse.cz>

	* g++.dg/opt/mpx.C: Fix scanned pattern.
	* gcc.target/i386/mpx.c: Likewise.
	* g++.dg/warn/Wunreachable-code-1.C: Remove.
	* g++.dg/warn/Wunreachable-code-2.C: Likewise.
	* gcc.dg/torture/pr52969.c: Likewise.
	* g++.dg/warn/pr31246-2.C: Likewise.
	* g++.dg/warn/pr31246.C: Likewise.
	* gcc.dg/pr33092.c: Likewise.
	* g++.dg/opt/eh1.C: Remove a deprecated option.
	* g++.dg/template/inline1.C: Likewise.
	* g++.dg/tree-ssa/pr81408.C: Likewise.
	* gcc.dg/pr41837.c: Likewise.
	* gcc.dg/pr41841.c: Likewise.
	* gcc.dg/pr42250.c: Likewise.
	* gcc.dg/pr43084.c: Likewise.
	* gcc.dg/pr43317.c: Likewise.
	* gcc.dg/pr51879-18.c: Likewise.
	* gcc.dg/torture/pr36066.c: Likewise.
	* gcc.dg/tree-ssa/ifc-8.c: Likewise.
	* gcc.dg/tree-ssa/ifc-cd.c: Likewise.
	* gcc.dg/tree-ssa/pr19210-1.c: Likewise.
	* gcc.dg/tree-ssa/pr45122.c: Likewise.
	* gcc.target/i386/pr45352-2.c: Likewise.
	* gcc.target/i386/zee.c: Likewise.
	* gfortran.dg/auto_char_len_2.f90: Likewise.
	* gfortran.dg/auto_char_len_4.f90: Likewise.
	* gfortran.dg/c_ptr_tests_15.f90: Likewise.
	* gfortran.dg/char_array_structure_constructor.f90: Likewise.
	* gfortran.dg/gomp/pr47331.f90: Likewise.
	* gfortran.dg/pr40999.f: Likewise.
	* gfortran.dg/pr41011.f: Likewise.
	* gfortran.dg/pr42051.f03: Likewise.
	* gfortran.dg/pr46804.f90: Likewise.
	* gfortran.dg/pr83149_1.f90: Likewise.
	* gfortran.dg/pr83149_b.f90: Likewise.
	* gfortran.dg/whole_file_1.f90: Likewise.
	* gfortran.dg/whole_file_10.f90: Likewise.
	* gfortran.dg/whole_file_11.f90: Likewise.
	* gfortran.dg/whole_file_12.f90: Likewise.
	* gfortran.dg/whole_file_13.f90: Likewise.
	* gfortran.dg/whole_file_14.f90: Likewise.
	* gfortran.dg/whole_file_15.f90: Likewise.
	* gfortran.dg/whole_file_16.f90: Likewise.
	* gfortran.dg/whole_file_17.f90: Likewise.
	* gfortran.dg/whole_file_18.f90: Likewise.
	* gfortran.dg/whole_file_19.f90: Likewise.
	* gfortran.dg/whole_file_2.f90: Likewise.
	* gfortran.dg/whole_file_20.f03: Likewise.
	* gfortran.dg/whole_file_3.f90: Likewise.
	* gfortran.dg/whole_file_4.f90: Likewise.
	* gfortran.dg/whole_file_5.f90: Likewise.
	* gfortran.dg/whole_file_6.f90: Likewise.
	* gfortran.dg/whole_file_7.f90: Likewise.
	* gfortran.dg/whole_file_8.f90: Likewise.
	* gfortran.dg/whole_file_9.f90: Likewise.
	* gcc.dg/vect/vect.exp: Likewise.
2018-08-17  Martin Liska  <mliska@suse.cz>

	* c.opt: Remove Warn, Init and Report for options with
        Ignore/Deprecated flag. Warning is done automatically for
        Deprecated flags.

From-SVN: r263614
2018-08-17 09:25:56 +00:00
David Malcolm 96e6ae576c diagnostics: add labeling of source ranges
This patch adds the ability to label source ranges within a rich_location,
to be printed by diagnostic_show_locus.

For example:

pr69554-1.c:11:18: error: invalid operands to binary + (have 'const char *' and 'const char *')
11 |   return (p + 1) + (q + 1);
   |          ~~~~~~~ ^ ~~~~~~~
   |             |         |
   |             |         const char *
   |             const char *

The patch implements labels for various type mismatch errors in the C and
C++ frontends, and in -Wformat.  I implemented it wherever accurate location
information was guaranteed (there are other places that could benefit, but
we need better location information in those places).

The labels can be disabled via -fno-diagnostics-show-labels.

Similarly:

param-type-mismatch.C: In function 'int test_1(int, int, float)':
param-type-mismatch.C:11:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
11 |   return callee_1 (first, second, third);
   |                           ^~~~~~
   |                           |
   |                           int
param-type-mismatch.C:7:43: note:   initializing argument 2 of 'int callee_1(int, const char*, float)'
7 | extern int callee_1 (int one, const char *two, float three);
  |                               ~~~~~~~~~~~~^~~

where the first "error" describing the bad argument gets a label
describing the type inline (since it's non-obvious from "second").
The "note" describing the type of the param of the callee *doesn't*
get a label, since that information is explicit there in the
source ("const char *two").

The idea is that in any diagnostic where two aspects of the source aren't
in sync it ought to be easier for the user if we directly show them the
mismatching aspects inline (e.g. types).

As well as type mismatch errors, perhaps labels could also be used for
buffer overflow warnings, for describing the capacity of the destination
buffer vs the size of what's being written:

  sprintf (buf, "filename: %s\n", file);
           ^~~   ~~~~~~~~~~~^~~
           |                |
           capacity: 32     10 + strlen(file) + 2

or somesuch.  Another idea might be for macro expansion warnings:

warning: repeated side effects in macro expansion...
   x = MIN (p++, q++);
       ~~~~^~~~~~~~~~
note: ...expanded here as
 #define MIN(X,Y) (X<Y?X:Y)
         ^~~ ~ ~   ~ ~ ~ ~
             | |   | | | |
             | |   | | | q++
             | |   | | p++
             | |   | q++
             | q++ p++
             p++

The patch removes some logic from multiline.exp which special-cased
lines ending with a '|' character (thus complicating testing of this
patch).  I believe that this was a vestige from experiments I did to
support strippng dg directives from the output; it was present in the
earliest version of multiline.exp I posted:
  "[RFC, stage1] Richer source location information for gcc 6 (location ranges etc)"
    https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00837.html
and I believe was neved used.

gcc/c-family/ChangeLog:
	* c-format.c: Include "selftest-diagnostic.h" and
	"gcc-rich-location.h".
	(format_warning_at_char): Pass NULL for new label params of
	format_warning_va.
	(class indirection_suffix): New class.
	(class range_label_for_format_type_mismatch): New class.
	(format_type_warning): Move logic for generating "*" suffix to
	class indirection_suffix.  Create "fmt_label" and "param_label"
	to show their types, and pass them to the
	format_warning_at_substring calls.
	(selftest::test_type_mismatch_range_labels): New test.
	(selftest::c_format_c_tests): Call it.

gcc/c/ChangeLog:
	* c-objc-common.c: Include "gcc-rich-location.h".
	(c_tree_printer): Move implemenation of '%T' to...
	(print_type): ...this new function.
	(range_label_for_type_mismatch::get_text): New function.
	* c-typeck.c (convert_for_assignment): Add type labels to the rhs
	range for the various ic_argpass cases.
	(class maybe_range_label_for_tree_type_mismatch): New class.
	(build_binary_op): Use it when calling binary_op_error.

gcc/cp/ChangeLog:
	* call.c: Include "gcc-rich-location.h".
	(convert_like_real): Add range label for "invalid conversion"
	diagnostic.
	(perform_implicit_conversion_flags): Add type label to the
	"could not convert" error.
	* error.c: Include "gcc-rich-location.h".
	(range_label_for_type_mismatch::get_text): New function.
	* typeck.c (convert_for_assignment): Add type label to
	the "cannot convert" error if a location is available.

gcc/ChangeLog:
	* common.opt (fdiagnostics-show-labels): New option.
	* diagnostic-show-locus.c (class layout_range): Add field
	"m_label".
	(class layout): Add field "m_show_labels_p".
	(layout_range::layout_range): Add param "label" and use it to
	initialize m_label.
	(make_range): Pass in NULL for new "label" param of layout_range's
	ctor.
	(layout::layout): Initialize m_show_labels_p.
	(layout::maybe_add_location_range): Pass in loc_range->m_label
	when constructing layout_range instances.
	(struct line_label): New struct.
	(layout::print_any_labels): New member function.
	(layout::print_line): Call it if label-printing is enabled.
	(selftest::test_one_liner_labels): New test.
	(selftest::test_diagnostic_show_locus_one_liner): Call it.
	* diagnostic.c (diagnostic_initialize): Initialize
	context->show_labels_p.
	* diagnostic.h (struct diagnostic_context): Add field
	"show_labels_p".
	* doc/invoke.texi (Diagnostic Message Formatting Options): Add
	-fno-diagnostics-show-labels.
	* dwarf2out.c (gen_producer_string): Add
	OPT_fdiagnostics_show_labels to the ignored options.
	* gcc-rich-location.c (gcc_rich_location::add_expr): Add "label"
	param.
	(gcc_rich_location::maybe_add_expr): Likewise.
	* gcc-rich-location.h (gcc_rich_location::gcc_rich_location): Add
	label" param, defaulting to NULL.
	(gcc_rich_location::add_expr): Add "label" param.
	(gcc_rich_location::maybe_add_expr): Likewise.
	(class text_range_label): New class.
	(class range_label_for_type_mismatch): New class.
	* gimple-ssa-sprintf.c (fmtwarn): Pass NULL for new label params
	of format_warning_va.
	(fmtwarn_n): Likewise for new params of format_warning_n_va.
	* lto-wrapper.c (merge_and_complain): Add
	OPT_fdiagnostics_show_labels to the "pick one setting" options.
	(append_compiler_options): Likewise to the dropped options.
	(append_diag_options): Likewise to the passed-on options.
	* opts.c (common_handle_option): Handle the new option.
	* selftest-diagnostic.c
	(test_diagnostic_context::test_diagnostic_context): Enable
	show_labels_p.
	* substring-locations.c: Include "gcc-rich-location.h".
	(format_warning_n_va): Add "fmt_label" and "param_label" params
	and use them as appropriate.
	(format_warning_va): Add "fmt_label" and "param_label" params,
	passing them on to format_warning_n_va.
	(format_warning_at_substring): Likewise.
	(format_warning_at_substring_n): Likewise.
	* substring-locations.h (format_warning_va): Add "fmt_label" and
	"param_label" params.
	(format_warning_n_va): Likewise.
	(format_warning_at_substring): Likewise.
	(format_warning_at_substring_n): Likewise.
	* toplev.c (general_init): Initialize global_dc->show_labels_p.

gcc/testsuite/ChangeLog:
	* g++.dg/diagnostic/aka3.C: New test.
	* g++.dg/diagnostic/param-type-mismatch-2.C: Update expected
	output to show range labels.
	* g++.dg/diagnostic/param-type-mismatch.C: Likewise.
	* g++.dg/plugin/plugin.exp (plugin_test_list): Add...
	* g++.dg/plugin/show-template-tree-color-labels.C: New test.
	* gcc.dg/bad-binary-ops.c: Update expected output to show range
	labels.  Add an "aka" example.
	* gcc.dg/cpp/pr66415-1.c: Update expected output to show range
	labels.
	* gcc.dg/format/diagnostic-ranges.c: Likewise.
	* gcc.dg/format/pr72858.c: Likewise.
	* gcc.dg/format/pr78498.c: Likewise.
	* gcc.dg/param-type-mismatch.c: Add "-Wpointer-sign" to options.
	Update expected output to show range labels.  Add examples of
	-Wincompatible-pointer-types and -Wpointer-sign for parameters.
	* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c:
	Update expected output to show range labels.
	* gcc.dg/plugin/diagnostic-test-show-locus-bw.c: Likewise.
	(test_very_wide_line): Adjust so that label is at left-clipping
	boundary.
	(test_very_wide_line_2): New test.
	* gcc.dg/plugin/diagnostic-test-show-locus-color-line-numbers.c:
	Update expected output to show range labels.
	* gcc.dg/plugin/diagnostic-test-show-locus-color.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-show-locus-no-labels.c: New test.
	* gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Update
	for new param to gcc_rich_location::add_expr.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (add_range):
	Add "label" param.
	(test_show_locus): Add examples of labels to various tests.  Tweak
	the "very wide_line" test case and duplicate it, to cover the
	boundary values for clipping of labels against the left-margin.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
	diagnostic-test-show-locus-no-labels.c.
	* gcc.dg/pr69554-1.c: Update expected output to show range labels.
	Update line numbers of dg-locus directives.
	* gcc.dg/pr69627.c:  Update expected output to show range labels.
	* lib/multiline.exp (proc _build_multiline_regex): Remove
	special-case handling of lines with trailing '|'.

libcpp/ChangeLog:
	* include/line-map.h (struct location_range): Add "m_label" field.
	(class rich_location): Add description of labels to leading
	comment.
	(rich_location::rich_location): Add "label" param, defaulting to
	NULL.
	(rich_location::add_range): Likewise.
	(struct label_text): New struct.
	(class range_label): New abstract base class.
	* line-map.c (rich_location::rich_location): Add "label" param;
	use it.
	(rich_location::add_range): Likewise.

From-SVN: r263564
2018-08-15 18:09:35 +00:00
David Malcolm 56b61d7fc4 diagnostics: add line numbers to source (PR other/84889)
This patch adds a left margin to the lines of source (and annotations)
printed by diagnostic_show_locus, so that e.g. rather than:

test.c: In function 'test':
test.c:12:15: error: 'struct foo' has no member named 'm_bar'; did you mean 'bar'?
   return ptr->m_bar;
               ^~~~~
               bar

we print:

test.c: In function 'test':
test.c:12:15: error: 'struct foo' has no member named 'm_bar'; did you mean 'bar'?
12 |   return ptr->m_bar;
   |               ^~~~~
   |               bar

Similarly, for a multiline case (in C++ this time), this:

bad-binary-ops.C: In function 'int test_2()':
bad-binary-ops.C:26:4: error: no match for 'operator+' (operand types are 's' and 't')
   return (some_function ()
           ~~~~~~~~~~~~~~~~
    + some_other_function ());
    ^~~~~~~~~~~~~~~~~~~~~~~~

becomes:

bad-binary-ops.C: In function 'int test_2()':
bad-binary-ops.C:26:4: error: no match for 'operator+' (operand types are 's' and 't')
25 |   return (some_function ()
   |           ~~~~~~~~~~~~~~~~
26 |    + some_other_function ());
   |    ^~~~~~~~~~~~~~~~~~~~~~~~

I believe this slightly improves the readability of the output, in that it:
- distinguishes between the user's source code vs the annotation lines
  that we're adding (the underlinings and fix-it hints here)
- shows the line numbers in another place (potentially helpful for
  multiline diagnostics, where the user can see the line numbers directly,
  rather than have to figure them out relative to the caret: in the 2nd
  example, note how the diagnostic is reported at line 26, but the first
  line printed is actually line 25)

I'm not sure that this is the precise format we want to go with [1], but
I think it's an improvement over the status quo, and we're in stage 1
of gcc 9, so there's plenty of time to shake out issues.

I've turned it on by default; it can be disabled via
-fno-diagnostics-show-line-numbers (it's also turned off in the testsuite, to
avoid breaking numerous existing test cases).

[1] Some possible variants:
  - maybe just "LL|" rather than "LL | "
  - maybe ':' rather than '|'
  - maybe we should have some leading indentation, to better split up
    the diagnostics visually via the left-hand column
  - etc

gcc/ChangeLog:
	PR other/84889
	* common.opt (fdiagnostics-show-line-numbers): New option.
	* diagnostic-show-locus.c (class layout): Add fields
	"m_show_line_numbers_p" and "m_linenum_width";
	(num_digits): New function.
	(test_num_digits): New function.
	(layout::layout): Initialize new fields.  Update m_x_offset
	logic to handle any left margin.
	(layout::print_source_line): Print line number when requested.
	(layout::start_annotation_line): New member function.
	(layout::print_annotation_line): Call it.
	(layout::print_leading_fixits): Likewise.
	(layout::print_trailing_fixits): Likewise.  Update calls to
	move_to_column for new parameter.
	(layout::get_x_bound_for_row): Add "add_left_margin" param and use
	it to potentially call start_annotation_line.
	(layout::show_ruler): Call start_annotation_line.
	(selftest::test_line_numbers_multiline_range): New selftest.
	(selftest::diagnostic_show_locus_c_tests): Call test_num_digits
	and selftest::test_line_numbers_multiline_range.
	* diagnostic.c (diagnostic_initialize): Initialize
	show_line_numbers_p.
	* diagnostic.h (struct diagnostic_context): Add field
	"show_line_numbers_p".
	* doc/invoke.texi (Diagnostic Message Formatting Options): Add
	-fno-diagnostics-show-line-numbers.
	* dwarf2out.c (gen_producer_string): Add
	OPT_fdiagnostics_show_line_numbers to the ignored options.
	* lto-wrapper.c (merge_and_complain): Likewise to the "pick
	one setting" options.
	(append_compiler_options): Likewise to the dropped options.
	(append_diag_options): Likewise to the passed-on options.
	* opts.c (common_handle_option): Handle the new option.
	* toplev.c (general_init): Set up global_dc->show_line_numbers_p.

gcc/testsuite/ChangeLog:
	PR other/84889
	* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c: New
	test.
	* gcc.dg/plugin/diagnostic-test-show-locus-color-line-numbers.c:
	New test.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the new tests.
	* lib/prune.exp: Add -fno-diagnostics-show-line-numbers to
	TEST_ALWAYS_FLAGS.

From-SVN: r263450
2018-08-09 15:32:13 +00:00
Martin Liska 35cf9fd028 Remove extra line in common.opt (PR c/86895).
2018-08-09  Martin Liska  <mliska@suse.cz>

        PR c/86895
	* common.opt: Remove extra line.

From-SVN: r263444
2018-08-09 10:37:02 +00:00
Olivier Hainque f37866e818 Add support for -nolibc
2018-06-07  Olivier Hainque  <hainque@adacore.com>

	* common.opt (nolibc): New option.
	* doc/invoke.texi (Link Options): Document it.
	* gcc.c (LINK_GCC_C_SEQUENCE_SPEC): Honor nolibc.
	* config/alpha/linux.h: Likewise.
	* config/arc/elf.h: Likewise.
	* config/arm/uclinux-elf.h: Likewise.
	* config/arm/unknown-elf.h: Likewise.
	* config/avr/avrlibc.h: Likewise.
	* config/bfin/bfin.h: Likewise.
	* config/bfin/linux.h: Likewise.
	* config/bfin/uclinux.h: Likewise.
	* config/darwin.h: Likewise.
	* config/darwin10.h: Likewise.
	* config/darwin12.h: Likewise.
	* config/gnu-user.h: Likewise.
	* config/lm32/uclinux-elf.h: Likewise.
	* config/pa/pa-hpux11.h: Likewise.
	* config/pa/pa64-hpux.h: Likewise.
	* config/sparc/sparc.h: Likewise.

From-SVN: r263083
2018-07-31 09:24:41 +00:00
Martin Sebor 00abf86c47 PR middle-end/82063 - issues with arguments enabled by -Wall
gcc/ada/ChangeLog:

	PR middle-end/82063
	* gcc-interface/misc.c (gnat_handle_option): Change function argument
	to HOST_WIDE_INT.

gcc/brig/ChangeLog:

	PR middle-end/82063
	* brig/brig-lang.c (brig_langhook_handle_option): Change function
	argument to HOST_WIDE_INT.

gcc/c-family/ChangeLog:

	PR middle-end/82063
	* c-common.h (c_common_handle_option): Change function argument
	to HOST_WIDE_INT.
	* c-opts.c (c_common_init_options): Same.
	(c_common_handle_option): Same.  Remove special handling of
	OPT_Walloca_larger_than_ and OPT_Wvla_larger_than_.
	* c.opt (-Walloc-size-larger-than, -Walloca-larger-than): Change
	options to take a HOST_WIDE_INT argument and accept a byte-size
	suffix.  Initialize.
	(-Wvla-larger-than): Same.
	(-Wno-alloc-size-larger-than, -Wno-alloca-larger-than): New.
	(-Wno-vla-larger-than): Same.

gcc/fortran/ChangeLog:

	PR middle-end/82063
	* gfortran.h (gfc_handle_option): Change function argument
	to HOST_WIDE_INT.
	* options.c (gfc_handle_option): Same.

gcc/go/ChangeLog:

	PR middle-end/82063
	* go-lang.c (go_langhook_handle_option): Change function argument
	to HOST_WIDE_INT.

gcc/lto/ChangeLog:

	PR middle-end/82063
	* lto-lang.c (lto_handle_option): Change function argument
	to HOST_WIDE_INT.

gcc/testsuite/ChangeLog:

	PR middle-end/82063
	* gcc/testsuite/c-c++-common/pr68657-1.c: Adjust.
	* gcc/testsuite/c-c++-common/pr68657-2.c: Same.
	* gcc/testsuite/c-c++-common/pr68657-3.c: Same.
	* gcc.dg/Walloc-size-larger-than-16.c: Same.
	* gcc.dg/Walloca-larger-than.c: New test.
	* gcc.dg/Walloca-larger-than-2.c: New test.
	* gcc.dg/Wframe-larger-than-2.c: New test.
	* gcc.dg/Wlarger-than3.c: New test.
	* gcc.dg/Wvla-larger-than-3.c: New test.
	* gcc.dg/pr42611.c: Adjust.
	* gnat.dg/frame_overflow.adb: Same.

gcc/ChangeLog:

	PR middle-end/82063
	* builtins.c (expand_builtin_alloca): Adjust.
	* calls.c (alloc_max_size): Simplify.
	* cgraphunit.c (cgraph_node::expand): Adjust.
	* common.opt (larger_than_size, warn_frame_larger_than): Remove
	variables.
	(frame_larger_than_size): Same.
	(-Wframe-larger-than, -Wlarger-than, -Wstack-usage): Change options
	to take a HOST_WIDE_INT argument and accept a byte-size suffix.
	Initialize.
	* doc/invoke.texi (GCC Command Options): Document option arguments.
	Explain byte-size arguments and suffixes.
	(-Wvla-larger-than, -Wno-alloc-size-larger-than): Update.
	(-Wno-alloca-larger-than, -Wno-vla-larger-than): Same.
	(-Wframe-larger-than, -Wlarger-than, -Wstack-usage): Same.
	* doc/options.texi (UInteger): Expand.
	(Host_Wide_Int, ByteSize): Document new properties.
	* final.c (final_start_function_1): Include sizes in an error message.
	* function.c (frame_offset_overflow): Same.
	* gimple-ssa-warn-alloca.c (pass_walloca::gate): Adjust.
	(alloca_call_type_by_arg): Change function argument to HOST_WIDE_INT.
	Diagnose unbounded alloca calls only for limits of less than
	PTRDIFF_MAX.
	(alloca_call_type): Adjust.  Diagnose possibly out-of-bounds alloca
	calls and VLA size only for limits of less than	PTRDIFF_MAX.  Same
	for alloca(0).
	(pass_walloca::execute): Adjust.  Diagnose alloca calls in loops
	only for limits of less than PTRDIFF_MAX.
	* langhooks-def.h (lhd_handle_option): Change function argument
	to HOST_WIDE_INT.
	* langhooks.c (lhd_handle_option): Same.
	* langhooks.h (handle_option): Same.
	* opt-functions.awk (switch_bit_fields): Handle Host_Wide_Int and
	ByteSize flags.
	(var_type, var_type_struct): Same.
	(var_set): Handle ByteSize flag.
	* optc-gen.awk: Add comments to output to ease debugging.  Make
	use of HOST_WIDE_INT where appropriate.
	* opts-gen-save.awk:  Use %lx to format unsigned long.
	* opth-gen.awk: Change function argument to HOST_WIDE_INT.
	* opts-common.c (integral_argument): Return HOST_WIDE_INT and add
	arguments.  Parse bytes-size suffixes.
	(enum_arg_to_value): Change function argument to HOST_WIDE_INT.
	(enum_value_to_arg): Same.
	(decode_cmdline_option): Handle cl_host_wide_int.  Adjust.
	(handle_option): Adjust.
	(generate_option): Change function argument to HOST_WIDE_INT.
	(cmdline_handle_error): Adjust.
	(read_cmdline_option): Change function argument to HOST_WIDE_INT.
	(set_option): Change function argument to HOST_WIDE_INT.
	(option_enabled): Handle cl_host_wide_int.
	(get_option_state): Handle CLVC_SIZE.
	(control_warning_option): Same.
	* opts.c (common_handle_option): Change function argument to
	HOST_WIDE_INT.  Remove handling of OPT_Walloca_larger_than_ and
	OPT_Wvla_larger_than_.
	* opts.h (enum cl_var_type): Add an enumerator.
	* stor-layout.c (layout_decl): Print a more meaningful warning.
	* toplev.c (output_stack_usage): Adjust.

From-SVN: r262910
2018-07-20 14:51:20 -06:00
David Malcolm 4a4412b9de Add "-fsave-optimization-record"
This patch implements a -fsave-optimization-record option, which
leads to a JSON file being written out, recording the dump_* calls
made (via the optinfo infrastructure).

The patch includes a minimal version of the JSON patch I posted last
year, with just enough support needed for optimization records (I
removed all of the parser code, leaving just the code for building
in-memory JSON trees and writing them to a pretty_printer).

gcc/ChangeLog:
	* Makefile.in (OBJS): Add json.o and optinfo-emit-json.o.
	(CFLAGS-optinfo-emit-json.o): Define TARGET_NAME.
	* common.opt (fsave-optimization-record): New option.
	* coretypes.h (struct kv_pair): Move here from dumpfile.c.
	* doc/invoke.texi (-fsave-optimization-record): New option.
	* dumpfile.c: Include "optinfo-emit-json.h".
	(struct kv_pair): Move to coretypes.h.
	(optgroup_options): Make non-static.
	(dump_context::end_scope): Call
	optimization_records_maybe_pop_dump_scope.
	* dumpfile.h (optgroup_options): New decl.
	* json.cc: New file.
	* json.h: New file.
	* optinfo-emit-json.cc: New file.
	* optinfo-emit-json.h: New file.
	* optinfo.cc: Include "optinfo-emit-json.h".
	(optinfo::emit): Call optimization_records_maybe_record_optinfo.
	(optinfo_enabled_p): Check optimization_records_enabled_p.
	(optinfo_wants_inlining_info_p): Likewise.
	* optinfo.h: Update comment.
	* profile-count.c (profile_quality_as_string): New function.
	* profile-count.h (profile_quality_as_string): New decl.
	(profile_count::quality): New accessor.
	* selftest-run-tests.c (selftest::run_tests): Call json_cc_tests
	and optinfo_emit_json_cc_tests.
	* selftest.h (selftest::json_cc_tests): New decl.
	(selftest::optinfo_emit_json_cc_tests): New decl.
	* toplev.c: Include "optinfo-emit-json.h".
	(compile_file): Call optimization_records_finish.
	(do_compile): Call optimization_records_start.
	* tree-ssa-live.c: Include optinfo.h.
	(remove_unused_scope_block_p): Retain inlining information if
	optinfo_wants_inlining_info_p returns true.

From-SVN: r262905
2018-07-20 15:37:23 +00:00
Ilya Leoshkevich 6902799c8d S/390: Add direct support for Linux kernel __fentry__ patching.
On i386, the difference between mcount and fentry is that fentry
comes before the prolog. On s390 mcount already comes before the
prolog, but takes 4 instructions. This patch introduces the more
efficient implementation (just 1 instruction) and puts it under
-mfentry flag.

The produced code is compatible only with newer glibc versions,
which provide the __fentry__ symbol and do not clobber %r0 when
resolving lazily bound functions. Because 31-bit PLT stubs assume
%r12 contains GOT address, which is not the case when the code runs
before the prolog, -mfentry is allowed only for 64-bit code.

Also, code compiled with -mfentry cannot be used for the nested C
functions, since they both use %r0. In this case instrumentation is
not insterted, and a new warning is issued for each affected nested
function.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* common.opt: Add the new warning.
	* config/s390/s390.c (s390_function_profiler): Emit "brasl
	%r0,__fentry__" when -mfentry is specified.
	(s390_option_override_internal): Disallow -mfentry for 31-bit
	CPUs.
	* config/s390/s390.opt: Add the new option.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/mfentry-m64.c: New testcase.

From-SVN: r262732
2018-07-16 14:29:08 +00:00
Martin Liska 8956e24714 Add missing Optimization attribute.
2018-07-09  Martin Liska  <mliska@suse.cz>

	* common.opt: Add back wrongly removed attribute.

From-SVN: r262513
2018-07-09 08:22:24 +00:00
Martin Liska c518c1025b [multiple changes]
2018-07-04  Denys Vlasenko  <dvlasenk@redhat.com>
	    Martin Liska  <mliska@suse.cz>

	PR middle-end/66240
	PR target/45996
	PR c/84100
	* common.opt: Rename align options with 'str_' prefix.
	* common/config/i386/i386-common.c (set_malign_value): New
	function.
	(ix86_handle_option): Use it to set -falign-* options/
	* config/aarch64/aarch64-protos.h (struct tune_params): Change
	type from int to string.
	* config/aarch64/aarch64.c: Update default values from int
	to string.
	* config/alpha/alpha.c (alpha_override_options_after_change):
	Likewise.
	* config/arm/arm.c (arm_override_options_after_change_1): Likewise.
	* config/i386/dragonfly.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	* config/i386/freebsd.h (SUBALIGN_LOG): New.
	(ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	* config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	* config/i386/gnu-user.h (SUBALIGN_LOG): New.
	(ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	* config/i386/i386.c (struct ptt): Change type from int to
	string.
	(ix86_default_align): Set default values.
	* config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Print
	max skip conditionally.
	* config/i386/iamcu.h (SUBALIGN_LOG): New.
	(ASM_OUTPUT_MAX_SKIP_ALIGN):
	* config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN):
	* config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	* config/i386/openbsdelf.h (SUBALIGN_LOG): New.
	(ASM_OUTPUT_MAX_SKIP_ALIGN) Print max skip conditionally.:
	* config/i386/x86-64.h (SUBALIGN_LOG): New.
	(ASM_OUTPUT_MAX_SKIP_ALIGN): Print
	max skip conditionally.
	(ASM_OUTPUT_MAX_SKIP_PAD): Likewise.
	* config/ia64/ia64.c (ia64_option_override): Set default values
        for alignment options.
	* config/m68k/m68k.c: Handle new str_align_* options.
	* config/mips/mips.c (mips_set_compression_mode): Change
	type of constants.
	(mips_option_override): Set default values for options.
	* config/powerpcspe/powerpcspe.c (rs6000_option_override_internal):
        Likewise.
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Likewise.
	* config/rx/rx.c (rx_option_override): Likewise.
	* config/rx/rx.h (JUMP_ALIGN): Use align_jumps_log.
	(LABEL_ALIGN): Use align_labels_log.
	(LOOP_ALIGN): Use align_loops_align.
	* config/s390/s390.c (s390_asm_output_function_label): Use new
        macros.
	* config/sh/sh.c (sh_override_options_after_change):
	Change type of constants.
	* config/spu/spu.c (spu_sched_init): Likewise.
	* config/sparc/sparc.c (sparc_option_override): Set default
        values for options.
	* config/visium/visium.c (visium_option_override): Likewise.
	* config/visium/visium.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Do not
        emit p2align format with last argument if it's not needed.
	* doc/invoke.texi: Document extended format of -falign-*.
	* final.c: Use align_labels alignment.
	* flags.h (struct target_flag_state): Change type to use
	align_flags.
	(struct align_flags_tuple): New.
	(struct align_flags): Likewise.
	(align_loops_log): Redefine macro to use new types.
	(align_loops_max_skip): Redefine macro to use new types.
	(align_jumps_log): Redefine macro to use new types.
	(align_jumps_max_skip): Redefine macro to use new types.
	(align_labels_log): Redefine macro to use new types.
	(align_labels_max_skip): Redefine macro to use new types.
	(align_functions_log): Redefine macro to use new types.
	(align_loops): Redefine macro to use new types.
	(align_jumps): Redefine macro to use new types.
	(align_labels): Redefine macro to use new types.
	(align_functions): Redefine macro to use new types.
	(align_functions_max_skip): Redefine macro to use new types.
	(align_loops_value): New macro.
	(align_jumps_value): New macro.
	(align_labels_value): New macro.
	(align_functions_value): New macro.
	* function.c (invoke_set_current_function_hook): Propagate
	alignment values from flags to global variables default in
	topleev.h.
	* ipa-icf.c (sem_function::equals_wpa): Use
	cl_optimization_option_eq instead of memcmp.
	* lto-streamer.h (cl_optimization_stream_out): Support streaming
	of string types.
	(cl_optimization_stream_in): Likewise.
	* optc-save-gen.awk: Support strings in cl_optimization.
	* opth-gen.awk: Likewise.
	* opts.c (finish_options): Remove error checking of invalid
	value ranges.
	(MAX_CODE_ALIGN): Remove.
	(MAX_CODE_ALIGN_VALUE): Likewise.
	(parse_and_check_align_values): New function.
	(check_alignment_argument): Likewise.
	(common_handle_option): Use check_alignment_argument.
	* opts.h (parse_and_check_align_values): Declare.
	* toplev.c (init_alignments): Remove.
	(read_log_maxskip): New.
	(parse_N_M): Likewise.
	(parse_alignment_opts): Likewise.
	(backend_init_target): Remove usage of init_alignments.
	* toplev.h (parse_alignment_opts): Declare.
	* tree-streamer-in.c (streamer_read_tree_bitfields): Add new
	argument.
	* tree-streamer-out.c (streamer_write_tree_bitfields): Likewise.
	* tree.c (cl_option_hasher::equal): New.
	* varasm.c: Use new global macros.
2018-07-04  Martin Liska  <mliska@suse.cz>

	PR middle-end/66240
	PR target/45996
	PR c/84100
	* lto.c (compare_tree_sccs_1): Use cl_optimization_option_eq
	instead of memcmp.
2018-07-04  Martin Liska  <mliska@suse.cz>

	PR middle-end/66240
	PR target/45996
	PR c/84100
	* gcc.dg/pr84100.c (foo):
	* gcc.target/i386/falign-functions-2.c: New test.
	* gcc.target/i386/falign-functions.c: New test.

From-SVN: r262375
2018-07-04 07:51:08 +00:00
Martin Liska d86c7648fb Come up with new --completion option.
2018-06-28  Martin Liska  <mliska@suse.cz>

	* common.opt: Introduce -completion option.
	* gcc.c (driver_handle_option): Handle it.
	(driver::main): Print completions if completion
        is set.
	* opt-suggestions.c (option_proposer::get_completions):
        New function.
	(option_proposer::suggest_completion): Likewise.
	(option_proposer::find_param_completions): Likewise.
	(verify_autocompletions): Likewise.
	(test_completion_valid_options): Likewise.
	(test_completion_valid_params): Likewise.
	(in_completion_p): Likewise.
	(empty_completion_p): Likewise.
	(test_completion_partial_match): Likewise.
	(test_completion_garbage): Likewise.
	(opt_proposer_c_tests): Likewise.
	* opt-suggestions.h: Declare new functions.
	* opts.c (common_handle_option): Handle OPT__completion_.
	* selftest-run-tests.c (selftest::run_tests): Add
        opt_proposer_c_tests.
	* selftest.c (assert_str_startswith): New.
	* selftest.h (assert_str_startswith): Likewise.
	(opt_proposer_c_tests): New.
	(ASSERT_STR_STARTSWITH): Likewise.

From-SVN: r262210
2018-06-28 07:11:16 +00:00
Jakub Jelinek ee79110cfd re PR middle-end/86095 (documentation for -Wunsafe-loop-optimizations references options which have no effect any more)
PR middle-end/86095
	* common.opt (Wunsafe-loop-optimizations): Add Ignore, remove Var,
	documented as preserved for backward compatibility only.
	* doc/invoke.texi: Remove -Wunsafe-loop-optimizations documentation.

From-SVN: r261679
2018-06-16 08:51:32 +02:00
Jason Merrill 34a7a2308d PR c++/86094 - wrong code with defaulted move ctor.
gcc/c-family/
	* c-opts.c (c_common_post_options): Bump the current ABI version to
	13.  Set warn_abi_version and flag_abi_compat_version to the current
	version rather than 0.  Fix defaulting flag_abi_compat_version from
	warn_abi_version.
gcc/cp/
	* class.c (classtype_has_non_deleted_move_ctor): New.
	* tree.c (maybe_warn_parm_abi, type_has_nontrivial_copy_init):
	Handle v12 breakage.

From-SVN: r261562
2018-06-13 15:39:36 -04:00
Jan Hubicka 5b42d19624 passes.c (ipa_write_summaries): Only modify statements if body is in memory.
* passes.c (ipa_write_summaries): Only modify statements if body
	is in memory.
	* cgraphunit.c (ipa_passes): Also produce intermeidate code when
	incrementally linking.
	(ipa_passes): Likewise.
	* lto-cgraph.c (lto_output_node): When incrementally linking do not
	pass down resolution info.
	* common.opt (flag_incremental_link): Update info.
	* gcc.c (plugin specs): Turn flinker-output=* to
	-plugin-opt=-linker-output-known
	* toplev.c (compile_file): Also cut compilation when doing incremental
	link.
	* flag-types. (enum lto_partition_model): Add
	LTO_LINKER_OUTPUT_NOLTOREL.
	(invoke.texi): Add -flinker-output docs.
	* ipa.c (symbol_table::remove_unreachable_nodes): Handle LTO incremental
	link same way as WPA; do not stream in dead initializers.

	* dwarf2out.c (dwarf2out_die_ref_for_decl,
	darf2out_register_external_decl): Support incremental link.

	* lang.opt (lto_linker_output): Add nolto-rel.
	* lto-lang.c (lto_post_options): Handle LTO_LINKER_OUTPUT_REL
	and LTO_LINKER_OUTPUT_NOLTOREL.
	(lto_init): Generate lto when doing incremental link.
	* lto.c (lto_precess_name): Add lto1-inclink.

	* testsuite/g++.dg/lto/20081109-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081118_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081119-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081120-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081120-2_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081123_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081204-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20081219_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20090302_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20090313_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20091002-2_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20091002-3_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20091026-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20100724-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20101010-4_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20101015-2_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/20110311-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr45621_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr48042_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr48354-1_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr54625-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr54625-2_0.c: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/lto/pr68811_0.C: Add -flinker-output=nolto-rel.
	* testsuite/g++.dg/torture/pr43760.C: New test. Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081120-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081120-2_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081126_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081204-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081204-2_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081212-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20081224_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20090116_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20090126-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20090126-2_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20090206-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20090219_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20091013-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20091014-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20091015-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20091016-1_0.c: Add -flinker-output=nolto-rel.
	* testsuite/gcc.dg/lto/20091020-1_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20091020-2_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20091027-1_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20100426_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20100430-1_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20100603-1_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20100603-2_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20100603-3_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/20111213-1_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr45736_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr52634_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr54702_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr59323-2_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr59323_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr60820_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr81406_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gcc.dg/lto/pr83388_0.c: Add -flinker-output-nolto-rel.
	* testsuite/gfortran.dg/lto/20091016-1_0.f90: Add -flinker-output-nolto-rel.
	* testsuite/gfortran.dg/lto/20091028-1_0.f90: Add -flinker-output-nolto-rel.
	* testsuite/gfortran.dg/lto/20091028-2_0.f90: Add -flinker-output-nolto-rel.
	* testsuite/gfortran.dg/lto/pr46911_0.f: Add -flinker-output-nolto-rel.
	* testsuite/gfortran.dg/lto/pr47839_0.f90: Add -flinker-output-nolto-rel.

From-SVN: r260963
2018-05-30 16:42:41 +00:00
Martin Liska cdc3b88343 Support lower and upper limit for -fdbg-cnt flag.
2018-05-18  Martin Liska  <mliska@suse.cz>

	* dbgcnt.c (limit_low): Renamed from limit.
	(limit_high): New variable.
	(dbg_cnt_is_enabled): Check for upper limit.
	(dbg_cnt): Adjust dumping.
	(dbg_cnt_set_limit_by_index): Add new argument for high
	value.
	(dbg_cnt_set_limit_by_name): Likewise.
	(dbg_cnt_process_single_pair): Parse new format.
	(dbg_cnt_process_opt): Use strtok.
	(dbg_cnt_list_all_counters): Remove 'value' and add
	'limit_high'.
	* doc/invoke.texi: Document changes.
2018-05-18  Martin Liska  <mliska@suse.cz>

	* gcc.dg/ipa/ipa-icf-39.c: New test.
	* gcc.dg/pr68766.c: Adjust pruned output.

From-SVN: r260349
2018-05-18 08:42:15 +00:00
Martin Liska cefc09063e Fix typos (PR other/84819).
2018-03-28  Martin Liska  <mliska@suse.cz>

	PR other/84819
	* calls.c (initialize_argument_information): Fix trailing space.
	* common.opt: Fix typo and provide better explanation for
	-fsanitize-coverage option.
	* config/i386/i386.opt: Fix typo.

From-SVN: r258925
2018-03-28 14:51:09 +00:00
Alexandre Oliva 924c9e3efb common.opt (gas-loc-support, [...]): New.
* 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.

From-SVN: r257631
2018-02-13 09:18:37 -07:00
Alexandre Oliva bd2b9f1e2d [LVU] Introduce location views
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.
	(gvariable-location-views=incompat5): 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 (SEEN_NEXT_VIEW): New.
	(set_next_view_needed): New.
	(clear_next_view_needed): New.
	(maybe_output_next_view): New.
	(final_start_function): Rename to...
	(final_start_function_1): ... this.  Take pointer to FIRST,
	add SEEN parameter.  Emit param bindings in the initial view.
	(final_start_function): Reintroduce SEEN-less interface.
	(final): Rename to...
	(final_1): ... this.  Take SEEN parameter.  Output final pending
	next view at the end.
	(final): Reintroduce seen-less interface.
	(final_scan_insn): Output pending next view before switching
	sections or ending a block.  Mark the next view as needed when
	outputting variable locations.  Notify debug backend of section
	changes, and of location view changes.
	(rest_of_handle_final): Adjust.
	* toplev.c (process_options): Autodetect value for debug variable
	location views option.  Warn on incompat5 without -gdwarf-5.
	* doc/invoke.texi (gvariable-location-views): New.
	(gvariable-location-views=incompat5): New.
	(gno-variable-location-views): New.

From-SVN: r257510
2018-02-09 02:21:57 +00:00
Jakub Jelinek 7b56ebc347 re PR c/84100 (Function __attribute__((optimize(align-loops=32))) gives spurious warning and is ignored)
PR c/84100
	* common.opt (falign-functions=, falign-jumps=, falign-labels=,
	falign-loops=): Add Optimization flag.

	* gcc.dg/pr84100.c: New test.

From-SVN: r257219
2018-01-31 09:26:52 +01:00
Boris Kolpackov 7365279fca Add ability to remap file names in __FILE__, etc (PR other/70268)
This commit adds the -fmacro-prefix-map option that allows remapping of file
names in __FILE__, __BASE_FILE__, and __builtin_FILE(), similar to how
-fdebug-prefix-map allows to do the same for debug information.

Additionally, it adds -ffile-prefix-map which can be used to specify both
mappings with a single option (and, should we need to add more -f*-prefix-map
options in the future, those as well).

libcpp/ChangeLog:

2018-01-18  Boris Kolpackov  <boris@codesynthesis.com>

        PR other/70268
        * include/cpplib.h (cpp_callbacks::remap_filename): New callback.
        * libcpp/macro.c (_cpp_builtin_macro_text): Call remap_filename for
        __FILE__ and __BASE_FILE__.


gcc/ChangeLog:

2018-01-18  Boris Kolpackov  <boris@codesynthesis.com>

        PR other/70268
        * common.opt: (-ffile-prefix-map): New option.
        * opts.c (common_handle_option): Defer it.
        * opts-global.c (handle_common_deferred_options): Handle it.
        * debug.h (remap_debug_filename, add_debug_prefix_map): Move to...
        * file-prefix-map.h: New file.
        (remap_debug_filename, add_debug_prefix_map): ...here.
        (add_macro_prefix_map, add_file_prefix_map, remap_macro_filename): New.
        * final.c (debug_prefix_map, add_debug_prefix_map
        remap_debug_filename): Move to...
        * file-prefix-map.c: New file.
        (file_prefix_map, add_prefix_map, remap_filename) ...here and rename,
        generalize, get rid of alloca(), use strrchr() instead of strchr().
        (add_macro_prefix_map, add_debug_prefix_map, add_file_prefix_map):
        Implement in terms of add_prefix_map().
        (remap_macro_filename, remap_debug_filename): Implement in term of
        remap_filename().
        * Makefile.in (OBJS, PLUGIN_HEADERS): Add new files.
        * builtins.c (fold_builtin_FILE): Call remap_macro_filename().
        * dbxout.c: Include file-prefix-map.h.
        * varasm.c: Likewise.
        * vmsdbgout.c: Likewise.
        * xcoffout.c: Likewise.
        * dwarf2out.c: Likewise plus omit new options from DW_AT_producer.
        * doc/cppopts.texi (-fmacro-prefix-map): Document.
        * doc/invoke.texi (-ffile-prefix-map): Document.
	(-fdebug-prefix-map): Update description.


gcc/c-family/ChangeLog:

2018-01-18  Boris Kolpackov  <boris@codesynthesis.com>

        PR other/70268
        * c-family/c.opt (-fmacro-prefix-map): New option.
        * c-family/c-opts.c (c_common_handle_option): Handle it.
        * c-family/c-lex.c (init_c_lex): Set remap_filename cpp callback.
        * c-family/c-ppoutput.c (init_pp_output): Likewise.


gcc/testsuite/ChangeLog:

2018-01-18  Boris Kolpackov  <boris@codesynthesis.com>

        PR other/70268
        * c-c++-common/ffile-prefix-map.c: New test.
        * c-c++-common/fmacro-prefix-map.c: New test.
        * c-c++-common/cpp/ffile-prefix-map.c: New test.
        * c-c++-common/cpp/fmacro-prefix-map.c: New test.

From-SVN: r256847
2018-01-18 13:17:37 +00:00
Jakub Jelinek 3fccbb9ece re PR middle-end/82694 (Linux kernel miscompiled since r250765)
PR middle-end/82694
	* common.opt (fstrict-overflow): No longer an alias.
	(fwrapv-pointer): New option.
	* tree.h (TYPE_OVERFLOW_WRAPS, TYPE_OVERFLOW_UNDEFINED): Define
	also for pointer types based on flag_wrapv_pointer.
	* opts.c (common_handle_option) <case OPT_fstrict_overflow>: Set
	opts->x_flag_wrap[pv] to !value, clear opts->x_flag_trapv if
	opts->x_flag_wrapv got set.
	* fold-const.c (fold_comparison, fold_binary_loc): Revert 2017-08-01
	changes, just use TYPE_OVERFLOW_UNDEFINED on pointer type instead of
	POINTER_TYPE_OVERFLOW_UNDEFINED.
	* match.pd: Likewise in address comparison pattern.
	* doc/invoke.texi: Document -fwrapv and -fstrict-overflow.

	* gcc.dg/no-strict-overflow-7.c: Revert 2017-08-01 changes.
	* gcc.dg/tree-ssa/pr81388-1.c: Likewise.

From-SVN: r256686
2018-01-15 10:05:59 +01:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Alexandre Oliva 8697bf9f46 [SFN] Introduce -gstatement-frontiers option, enable debug markers
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.

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

From-SVN: r255569
2017-12-12 02:16:31 +00:00
Michael Matz dc236397e4 re PR tree-optimization/83323 (186.crafty miscompares)
Fix PR83323

	* gimple-loop-jam (unroll_jam_possible_p): Correct test for
	head-controlled loops and loop BBs.
	* common.opt (funroll-and-jam): Remove, instead ...
	(floop-unroll-and-jam): ... reuse this option.
	* opts.c (default_options_table): Use OPT_floop_unroll_and_jam.
	* doc/invoke.texi (-funroll-and-jam): Move docu to ...
	(-floop-unroll-and-jam): ... this option.

testsuite/
	* gcc.dg/pr83323.c: New test.
	* gcc.dg/unroll-and-jam.c: Use -floop-unroll-and-jam.

From-SVN: r255514
2017-12-08 17:41:58 +00:00
Bin Cheng fbdec14e80 re PR tree-optimization/81303 (410.bwaves regression caused by r249919)
PR tree-optimization/81303
	* Makefile.in (gimple-loop-interchange.o): New object file.
	* common.opt (floop-interchange): Reuse the option from graphite.
	* doc/invoke.texi (-floop-interchange): Ditto.  New document for
	-floop-interchange and mention it for -O3.
	* opts.c (default_options_table): Enable -floop-interchange at -O3.
	* gimple-loop-interchange.cc: New file.
	* params.def (PARAM_LOOP_INTERCHANGE_MAX_NUM_STMTS): New parameter.
	(PARAM_LOOP_INTERCHANGE_STRIDE_RATIO): New parameter.
	* passes.def (pass_linterchange): New pass.
	* timevar.def (TV_LINTERCHANGE): New time var.
	* tree-pass.h (make_pass_linterchange): New declaration.
	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Change to external
	interchange.  Record IV before/after increment in new parameters.
	* tree-ssa-loop-ivopts.h (create_canonical_iv): New declaration.
	* tree-vect-loop.c (vect_is_simple_reduction): Factor out reduction
	path check into...
	(check_reduction_path): ...New function here.
	* tree-vectorizer.h (check_reduction_path): New declaration.

	gcc/testsuite
	* gcc.dg/tree-ssa/loop-interchange-1.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-1b.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-2.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-3.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-4.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-5.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-6.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-7.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-8.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-9.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-10.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-11.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-12.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-13.c: New test.

Co-Authored-By: Richard Biener <rguenther@suse.de>

From-SVN: r255472
2017-12-07 18:03:53 +00:00
Michael Matz 1cc521f1a8 Add unroll and jam pass
* gimple-loop-jam.c: New file.
	* Makefile.in (OBJS): Add gimple-loop-jam.o.
	* common.opt (funroll-and-jam): New option.
	* opts.c (default_options_table): Add unroll-and-jam at -O3.
	* params.def (PARAM_UNROLL_JAM_MIN_PERCENT): New param.
	(PARAM_UNROLL_JAM_MAX_UNROLL): Ditto.
	* passes.def: Add pass_loop_jam.
	* timevar.def (TV_LOOP_JAM): Add.
	* tree-pass.h (make_pass_loop_jam): Declare.
	* cfgloop.c (flow_loop_tree_node_add): Add AFTER argument.
	* cfgloop.h (flow_loop_tree_node_add): Adjust declaration.
	* cfgloopmanip.c (duplicate_loop): Add AFTER argument, adjust call
	to flow_loop_tree_node_add.
	(duplicate_subloops, copy_loops_to): Append to sibling list.
	* cfgloopmanip.h: (duplicate_loop): Adjust declaration.
	* doc/invoke.texi (-funroll-and-jam): Document new option.
	(unroll-jam-min-percent, unroll-jam-max-unroll): Document new params.

testsuite/
	* gcc.dg/unroll-and-jam.c: New test.

From-SVN: r255467
2017-12-07 14:49:54 +00:00
Jim Wilson d7d5f241f0 Delete obsolete DWARF1 references.
gcc/
	* common.opt (use_gnu_debug_info_extensions): Delete DWARF_DEBUG from
	comment.
	* config/vx-common.h (DWARF_DEBUGGING_INFO): Delete undef.
	* doc/tm.texi.in (PREFERRED_DEBUGGING_TYPE): Delete DWARF_DEBUG
	reference.
	* doc/tm.texi: Regenerate.

From-SVN: r255345
2017-12-01 16:24:36 -08:00
Marek Polacek 974aedcce8 re PR c++/60336 (empty struct value is passed differently in C and C++)
PR c++/60336
	PR middle-end/67239
	PR target/68355
	* c-decl.c (grokdeclarator): Set DECL_PADDING_P on unnamed bit-fields.

	* class.c (layout_class_type): Set DECL_PADDING_P on padding.
	* decl.c (cxx_init_decl_processing): Set TRANSLATION_UNIT_WARN_EMPTY_P.
	(grokdeclarator): Set DECL_PADDING_P on unnamed bit-fields.

	* lto.c (compare_tree_sccs_1): Compare TYPE_EMPTY_P and DECL_PADDING_P.

	* calls.c (initialize_argument_information): Call
	warn_parameter_passing_abi target hook.
	(store_one_arg): Use 0 for empty record size.  Don't push 0 size
	argument onto stack.
	(must_pass_in_stack_var_size_or_pad): Return false for empty types.
	* common.opt: Update -fabi-version description.
	* config/i386/i386.c (init_cumulative_args): Set cum->warn_empty.
	(ix86_gimplify_va_arg): Call arg_int_size_in_bytes instead of
	int_size_in_bytes.
	(ix86_is_empty_record): New function.
	(ix86_warn_parameter_passing_abi): New function.
	(TARGET_EMPTY_RECORD_P): Redefine.
	(TARGET_WARN_PARAMETER_PASSING_ABI): Redefine.
	* config/i386/i386.h (CUMULATIVE_ARGS): Add warn_empty.
	* doc/tm.texi: Regenerated.
	* doc/tm.texi.in (TARGET_EMPTY_RECORD_P,
	TARGET_WARN_PARAMETER_PASSING_ABI): Add.
	* dwarf2out.c (get_ultimate_context): Move to tree.c.
	* explow.c (hard_function_value): Call arg_int_size_in_bytes
	instead of int_size_in_bytes.
	* expr.c (copy_blkmode_to_reg): Likewise.
	* function.c (aggregate_value_p): Return 0 for empty types.
	(assign_parm_find_entry_rtl): Call warn_parameter_passing_abi target hook.
	(locate_and_pad_parm): Call arg size_in_bytes instead
	size_in_bytes.
	* lto-streamer-out.c (hash_tree): Hash TYPE_EMPTY_P and DECL_PADDING_P.
	* stor-layout.c (finalize_type_size): Set TYPE_EMPTY_P.
	* target.def (empty_record_p, warn_parameter_passing_abi): New target
	hooks.
	* targhooks.c (hook_void_CUMULATIVE_ARGS_tree): New hook.
	(std_gimplify_va_arg_expr): Skip empty records.  Call
	arg_size_in_bytes instead size_in_bytes.
	* targhooks.h (hook_void_CUMULATIVE_ARGS_tree): Declare.
	* tree-core.h (tree_type_common): Add empty_flag.
	(tree_decl_common): Update comments.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Stream
	DECL_PADDING_P.
	(unpack_ts_type_common_value_fields): Stream TYPE_EMPTY_P.
	* tree-streamer-out.c (pack_ts_decl_common_value_fields): Stream
	DECL_PADDING_P.
	(pack_ts_type_common_value_fields): Stream TYPE_EMPTY_P.
	* tree.c (default_is_empty_type): New function.
	(default_is_empty_record): New function.
	(arg_int_size_in_bytes): New function.
	(arg_size_in_bytes): New function.
	(get_ultimate_context): New function.
	* tree.h: Define TYPE_EMPTY_P, DECL_PADDING_P and
	TRANSLATION_UNIT_WARN_EMPTY_P.
	(default_is_empty_record, arg_int_size_in_bytes,
	arg_size_in_bytes, get_ultimate_context): Declare.

	* g++.dg/abi/empty12.C: New test.
	* g++.dg/abi/empty12.h: New test.
	* g++.dg/abi/empty12a.c: New test.
	* g++.dg/abi/empty13.C: New test.
	* g++.dg/abi/empty13.h: New test.
	* g++.dg/abi/empty13a.c: New test.
	* g++.dg/abi/empty14.C: New test.
	* g++.dg/abi/empty14.h: New test.
	* g++.dg/abi/empty14a.c: New test.
	* g++.dg/abi/empty15.C: New test.
	* g++.dg/abi/empty15.h: New test.
	* g++.dg/abi/empty15a.c: New test.
	* g++.dg/abi/empty16.C: New test.
	* g++.dg/abi/empty16.h: New test.
	* g++.dg/abi/empty16a.c: New test.
	* g++.dg/abi/empty17.C: New test.
	* g++.dg/abi/empty17.h: New test.
	* g++.dg/abi/empty17a.c: New test.
	* g++.dg/abi/empty18.C: New test.
	* g++.dg/abi/empty18.h: New test.
	* g++.dg/abi/empty18a.c: New test.
	* g++.dg/abi/empty19.C: New test.
	* g++.dg/abi/empty19.h: New test.
	* g++.dg/abi/empty19a.c: New test.
	* g++.dg/abi/empty20.C: New test.
	* g++.dg/abi/empty21.C: New test.
	* g++.dg/abi/empty22.C: New test.
	* g++.dg/abi/empty22.h: New test.
	* g++.dg/abi/empty22a.c: New test.
	* g++.dg/abi/empty23.C: New test.
	* g++.dg/abi/empty24.C: New test.
	* g++.dg/abi/empty25.C: New test.
	* g++.dg/abi/empty25.h: New test.
	* g++.dg/abi/empty25a.c: New test.
	* g++.dg/abi/empty26.C: New test.
	* g++.dg/abi/empty26.h: New test.
	* g++.dg/abi/empty26a.c: New test.
	* g++.dg/abi/empty27.C: New test.
	* g++.dg/abi/empty28.C: New test.
	* g++.dg/abi/pr60336-1.C: New test.
	* g++.dg/abi/pr60336-10.C: New test.
	* g++.dg/abi/pr60336-11.C: New test.
	* g++.dg/abi/pr60336-12.C: New test.
	* g++.dg/abi/pr60336-2.C: New test.
	* g++.dg/abi/pr60336-3.C: New test.
	* g++.dg/abi/pr60336-4.C: New test.
	* g++.dg/abi/pr60336-5.C: New test.
	* g++.dg/abi/pr60336-6.C: New test.
	* g++.dg/abi/pr60336-7.C: New test.
	* g++.dg/abi/pr60336-8.C: New test.
	* g++.dg/abi/pr60336-9.C: New test.
	* g++.dg/abi/pr68355.C: New test.
	* g++.dg/lto/pr60336_0.C: New test.

Co-Authored-By: H.J. Lu <hongjiu.lu@intel.com>
Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r255066
2017-11-22 16:06:18 +00:00
James E Wilson e7e95821dd Emit a no longer supported warning for gcoff* options.
gcc/
	* common.opt (gcoff): Re-add as ignored option.
	(gcoff1, gcoff2, gcoff3): Likewise.

From-SVN: r254207
2017-10-29 16:01:36 -07:00
James E Wilson 180295ed63 Delete obsolete SDB debug info support.
gcc/
	* Makefile.in (OBJS): Delete sdbout.o.
	(GTFILES): Delete $(srcdir)/sdbout.c.
	* debug.h: Delete sdb_debug_hooks.
	* final.c: Delete sdbout.h include.
	(final_scan_insn): Delete SDB_DEBUG check.
	(rest_of_clean_state): Likewise.
	* output.h: Delete sdb_begin_function_line.
	* sdbout.c: Delete.
	* sdbout.h: Delete.
	* toplev.c: Delete sdbout.h include.
	(process_options): Delete SDB_DEBUG check.
	* tree-core.h (tree_type_common): Delete pointer field of
	tree_type_symtab.
	* tree.c (copy_node): Clear TYPE_SYMTAB_DIE instead of
	TYPE_SYMTAB_POINTER.
	* tree.h (TYPE_SYMTAB_POINTER): Delete.
	(TYPE_SYMTAB_IS_POINTER): Delete.
	(TYPE_SYMTAB_IS_DIE): Renumber.
	* xcoffout.c: Refer to former sdbout.c file.
	(xcoffout_begin_prologue): Use past tense for sdbout.c reference.

	* doc/install.texi (--with-stabs): Delete COFF and ECOFF info.
	* doc/invoke.texi (SEEALSO): Delete adb and sdb references.
	(Debugging Options): Delete -gcoff.
	(-gstabs): Delete SDB reference.
	(-gcoff): Delete.
	(-gcoff@var{level}): Delete.
	* doc/passes.texi (Debugging information output): Delete SDB and
	sdbout.c references.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in (DWARF_CIE_DATA_ALIGNMENT): Delete SDB from xref.
	(SDB and DWARF): Change node name to DWARF and delete SDB and COFF
	references.
	(DEBUGGER_AUTO_OFFSET): Delete COFF and SDB references.
	(PREFERRED_DEBUGGING_TYPE): Delete SDB_DEBUG and -gcoff references.
	(SDB_DEBUGGING_INFO): Delete.
	(PUT_SDB_@dots{}, SDB_DELIM, SDB_ALLOW_UNKNOWN_REFERENCES)
	SDB_ALLOW_FORWARD_REFERENCES, SDB_OUTPUT_SOURCE_LINE): Delete.
	* target.def (output_source_filename): Delete COFF reference.

	* common.opt (gcoff): Delete.
	(gxcoff+): Update Negative chain.
	* defaults.h: Delete all references to SDB_DEBUGGING_INFO and
	SDB_DEBUG.
	* dwarf2out.c (gen_array_type_die): Change SDB to debuggers.
	* flag-types.h (enum debug_info_type): Delete SDB_DEBUG.
	* function.c (number_blocks): Delete SDB_DEBUGGING_INFO, SDB_DEBUG,
	and SDB references.
	(expand_function_start): Change sdb reference to past tense.
	(expand_function_end): Change sdb reference to past tense.
	* gcc.c (cpp_unique_options): Delete gcoff3 reference.
	* opts.c (debug_type_names): Delete coff entry.
	(common_handle_option): Delete OPT_gcoff case.
	* system.h (SDB_DEBUG, SDB_DEBUGGING_INFO): Poison.

	* config/dbxcoff.h (PREFERRED_DEBUGGING_TYPE): Set to DBX_DEBUG.
	* config/cris/cris.h: Delete SDB reference in comment.
	* config/i386/cygming.h: Don't define SDB_DEBUGGING_INFO.
	(ASM_DECLARE_FUNCTION_NAME): Delete SDB reference from comment.
	* config/i386/gas.h: Don't define SDB_DEBUGGING_INFO.
	* config/i386/i386.c (svr4_dbx_register_map): Change SDB references
	to past tense.
	(ix86_expand_prologue): Likewise.
	* config/i386/winnt.c (i386_pe_start_function): Don't check SDB_DEBUG.
	* config/ia64/ia64.h: Likewise.
	* config/m68k/m68kelf.h (DBX_REGISTER_NUMBER): Delete SDB reference.
	* config/mips/mips.h (SUBTARGET_ASM_DEBUGGING_SPEC): Delete gcoff*
	support.
	* config/mmix/mmix.h: Likewise.
	* config/nds32/nds32.c: Likewise.
	* config/stormy/storym16.h: Likewise.
	* config/visium/visium.h: Likewise.
	* config/vx-common.h (SDB_DEBUGGING_INFO): Delete undef.

	gcc/fortran/
	* invoke.texi: Delete adb and sdb references.

	gccc/testsuite/
	* lib/gcc-dg.exp (gcc-dg-debug-runtest): Delete -gcoff.
	* lib/gfortran-dg.exp (gfortran-dg-debug-runtest): Delete
	-gcoff.

From-SVN: r254206
2017-10-29 15:45:41 -07:00
Prathamesh Kulkarni 0fab169b28 Extend ipa-pure-const pass to propagate malloc attribute.
2017-10-27  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* cgraph.h (set_malloc_flag): Declare.
	* cgraph.c (set_malloc_flag_1): New function.
	(set_malloc_flag): Likewise.
	* ipa-fnsummary.h (ipa_call_summary): Add new field is_return_callee.
	* ipa-fnsummary.c (ipa_call_summary::reset): Set is_return_callee to
	false.
	(read_ipa_call_summary): Add support for reading is_return_callee.
	(write_ipa_call_summary): Stream is_return_callee.
	* ipa-inline.c (ipa_inline): Remove call to ipa_free_fn_summary.
	* ipa-pure-const.c: Add headers ssa.h, alloc-pool.h, symbol-summary.h,
	ipa-prop.h, ipa-fnsummary.h.
	(pure_const_names): Change to static.
	(malloc_state_e): Define.
	(malloc_state_names): Define.
	(funct_state_d): Add field malloc_state.
	(varying_state): Set malloc_state to STATE_MALLOC_BOTTOM.
	(check_retval_uses): New function.
	(malloc_candidate_p): Likewise.
	(analyze_function): Add support for malloc attribute.
	(pure_const_write_summary): Stream malloc_state.
	(pure_const_read_summary): Add support for reading malloc_state.
	(dump_malloc_lattice): New function.
	(propagate_malloc): New function.
	(warn_function_malloc): New function.
	(ipa_pure_const::execute): Call propagate_malloc and
	ipa_free_fn_summary.
	(pass_local_pure_const::execute): Add support for malloc attribute.
	* ssa-iterators.h (RETURN_FROM_IMM_USE_STMT): New macro.
	* doc/invoke.texi: Document Wsuggest-attribute=malloc.

testsuite/
	* gcc.dg/ipa/propmalloc-1.c: New test-case.
	* gcc.dg/ipa/propmalloc-2.c: Likewise.
	* gcc.dg/ipa/propmalloc-3.c: Likewise.

From-SVN: r254140
2017-10-27 10:48:49 +00:00
Jakub Jelinek 8008dd1c93 common.opt (gcolumn-info): Enable by default.
* common.opt (gcolumn-info): Enable by default.
	* doc/invoke.texi (gcolumn-info): Document new default.

	* lib/scanasm.exp (dg-function-on-line): Accept optional column info.
	* gcc.dg/debug/dwarf2/pr53948.c: Likewise.
	* g++.dg/debug/dwarf2/pr77363.C: Likewise.
	* gcc.dg/debug/dwarf2/asm-line1.c: Add -gno-column-info to dg-options.
	* gcc.dg/debug/dwarf2/discriminator.c: Likewise.
	* g++.dg/debug/dwarf2/typedef6.C: Likewise.

From-SVN: r254010
2017-10-23 16:10:36 +02:00
Igor Tsimbalist 5c5f0b65ee Add generic part for Intel CET enabling. The spec is available at
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

A proposal is to introduce a target independent flag
-fcf-protection=[none|branch|return|full] with a semantic to
instrument a code to control validness or integrity of control-flow
transfers using jump and call instructions. The main goal is to detect
and block a possible malware execution through transfer the execution
to unknown target address. Implementation could be either software or
target based. Any target platforms can provide their implementation
for instrumentation under this option.

The compiler should instrument any control-flow transfer points in a
program (ex. call/jmp/ret) as well as any landing pads, which are
targets of control-flow transfers.

A new 'nocf_check' attribute is introduced to provide hand tuning
support. The attribute directs the compiler to skip a call to a
function and a function's landing pad from instrumentation. The
attribute can be used for function and pointer to function types,
otherwise it will be ignored.

Currently all platforms except i386 will report the error and do no
instrumentation. i386 will provide the implementation based on a
specification published by Intel for a new technology called
Control-flow Enforcement Technology (CET).

gcc/c-family/
	* c-attribs.c (handle_nocf_check_attribute): New function.
	(c_common_attribute_table): Add 'nocf_check' handling.

gcc/c/
	* gimple-parser.c: Add second argument NULL to
	gimple_build_call_from_tree.

gcc/
	* attrib.c (comp_type_attributes): Check nocf_check attribute.
	* cfgexpand.c (expand_call_stmt): Set REG_CALL_NOCF_CHECK for
	call insn.
	* combine.c (distribute_notes): Add REG_CALL_NOCF_CHECK handling.
	* common.opt: Add fcf-protection flag.
	* emit-rtl.c (try_split): Add REG_CALL_NOCF_CHECK handling.
	* flag-types.h: Add enum cf_protection_level.
	* gimple.c (gimple_build_call_from_tree): Add second parameter.
	Add 'nocf_check' attribute propagation to gimple call.
	* gimple.h (gf_mask): Add GF_CALL_NOCF_CHECK.
	(gimple_build_call_from_tree): Update prototype.
	(gimple_call_nocf_check_p): New function.
	(gimple_call_set_nocf_check): Likewise.
	* gimplify.c: Add second argument to gimple_build_call_from_tree.
	* ipa-icf.c: Add nocf_check attribute in statement hash.
	* recog.c (peep2_attempt): Add REG_CALL_NOCF_CHECK handling.
	* reg-notes.def: Add REG_NOTE (CALL_NOCF_CHECK).
	* toplev.c (process_options): Add flag_cf_protection handling.

From-SVN: r253936
2017-10-20 15:09:38 +02:00
Martin Sebor 7a866e7e31 PR c/82301 - Updated test case g++.dg/ext/attr-ifunc-1.C (and others) in r253041 segfault on powerpc64
PR c/82301 - Updated test case g++.dg/ext/attr-ifunc-1.C (and others) in r253041 segfault on powerpc64
PR c/82435 - new __attribute__((alias)) warning gets in the way

gcc/ChangeLog:

	PR other/82301
	PR c/82435
	* cgraphunit.c (maybe_diag_incompatible_alias): New function.
	(handle_alias_pairs): Call it.
	* common.opt (-Wattribute-alias): New option.
	* doc/extend.texi (ifunc attribute): Discuss C++ specifics.
	* doc/invoke.texi (-Wattribute-alias): Document.

gcc/testsuite/ChangeLog:

	PR other/82301
	PR c/82435
	* g++.dg/ext/attr-ifunc-1.C: Update.
	* g++.dg/ext/attr-ifunc-2.C: Same.
	* g++.dg/ext/attr-ifunc-3.C: Same.
	* g++.dg/ext/attr-ifunc-4.C: Same.
	* g++.dg/ext/attr-ifunc-5.C: Same.
	* g++.dg/ext/attr-ifunc-6.C: New test.
	* g++.old-deja/g++.abi/vtable2.C: Update.
	* gcc.dg/attr-ifunc-6.c: New test.
	* gcc.dg/attr-ifunc-7.c: New test.
	* gcc.dg/pr81854.c: Update.
	* lib/target-supports.exp: Update.

From-SVN: r253688
2017-10-12 11:37:56 -06:00
Jan Hubicka 12b9f3ac92 invoke.texi (Wsuggest-attribute=cold): Document.
* invoke.texi (Wsuggest-attribute=cold): Document.
	* common.opt (Wsuggest-attribute=cold): New
	* ipa-pure-const.c (warn_function_cold): New function.
	* predict.c (compute_function_frequency): Use it.
	* predict.h (warn_function_cold): Declare.

	* gcc.dg/cold-1.c: New testcase.

From-SVN: r253513
2017-10-07 16:48:34 +00:00
Alexandre Oliva 9ed32e2786 enable handling of -gno- command-line options as negated prefixes
This patch that adds -g to the set of negatable prefixes along with -f,
-m and -W.  Besides the mapping from -gno- to negated -g in option_map
and adding g to the [fmW] matches for negatable options, I had to
introduce gno- as an remapping prefix, for the option searching
machinery to backtrack to and recognize as a remapping prefix, instead
of backtracking to -g and stopping at it as if no-* was its Joined
argument.  Adding such remapping prefixes to preempt further
backtracking can be accomplished by introducing the prefix as an
Undocumented option with a Joined argument and without Driver, Target,
Common, or any language-specific option.  Whenever we match such a fake
options prefix, we abandon further backtracking (it matches, after all),
but find_opt returns the same code it would if it hadn't found any
match, so that we resort to option mapping.

I've arranged for such remapping prefixes to not be considered when
looking for and suggesting a correct spelling for misspelled options.
While testing that, I found a few -W-started options that were not
marked as RejectNegative but should (-Wno-a, is not something we'd like
to suggest ;-)  I've also marked as such -g-started options that
it makes no sense to negate, and removed the explicit -gno- ones,
allowing their opposites to be negated.

for  gcc/ChangeLog

	* common.opt (Wa, Wl, Wp, g, gz=): Add
	RejectNegative.
	(gno-column-info): Remove.
	(gcolumn-info): Drop RejectNegative.
	(gno-): New prefix.
	(gno-record-gcc-switches): Remove.
	(grecord-gcc-switches): Drop RejectNegative.
	(gno-split-dwarf): Remove.
	(gsplit-dwarf): Drop RejectNegative.
	(gno-strict-dwarf): Remove.
	(gstrict-dwarf): Drop RejectNegative.
	* config/darwin.opt (gfull, gused): Add RejectNegative.
	* dwarf2out.c (gen_producer_string): Drop
	gno-record-gcc-switches handler.
	* optc-gen.awk: Add g to prefixes with negative forms.
	* opts-common.c (remapping_prefix_p): New.
	(find_opt): Check it.
	(generate_canonical_option): Test g prefix.
	(option_map): Add -gno- mapping.
	(add_misspelling_candidates): Check remapping_prefix_p.

for  gcc/ada/ChangeLog

	* gcc-interface/lang.opt (gant, gnatO, gnat): Add
        RejectNegative.

for  gcc/c-family/ChangeLog

	* c.opt (gen-decls): Add RejectNegative.

From-SVN: r253047
2017-09-21 02:18:02 +00:00
Jeff Law ee8f15c69e common.opt (-fstack-clash-protection): New option.
* common.opt (-fstack-clash-protection): New option.
	* flag-types.h (enum stack_check_type): Note difference between
	-fstack-check= and -fstack-clash-protection.
	* params.def (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE): New PARAM.
	(PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL): Likewise.
	* toplev.c (process_options): Issue warnings/errors for cases
	not handled with -fstack-clash-protection.
	* doc/invoke.texi (-fstack-clash-protection): Document new option.
	(-fstack-check): Note additional problem with -fstack-check=generic.
	Note that -fstack-check is primarily for Ada and refer users
	to -fstack-clash-protection for stack-clash-protection.
	Document new params for stack clash protection.

	* gcc.dg/stack-check-2.c: New test.
	* lib/target-supports.exp
	(check_effective_target_supports_stack_clash_protection): New function.
	(check_effective_target_frame_pointer_for_non_leaf): Likewise.
	(check_effective_target_caller_implicit_probes): Likewise.

From-SVN: r252994
2017-09-19 22:56:54 -06:00