Commit Graph

329 Commits

Author SHA1 Message Date
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 0dba79602a re PR bootstrap/78817 (stage2 bootstrap failure in vec.h:1613:5: error: argument 1 null where non-null expected after r243661)
PR bootstrap/78817
	* tree-pass.h (make_pass_post_ipa_warn): Declare.
	* builtins.c (validate_arglist): Adjust get_nonnull_args call.
	Check for NULL pointer argument to nonnull arg here.
	(validate_arg): Revert 2016-12-14 changes.
	* calls.h (get_nonnull_args): Remove declaration.
	* tree-ssa-ccp.c: Include diagnostic-core.h.
	(pass_data_post_ipa_warn): New variable.
	(pass_post_ipa_warn): New class.
	(pass_post_ipa_warn::execute): New method.
	(make_pass_post_ipa_warn): New function.
	* tree.h (get_nonnull_args): Declare.
	* tree.c (get_nonnull_args): New function.
	* calls.c (maybe_warn_null_arg): Removed.
	(maybe_warn_null_arg): Removed.
	(initialize_argument_information): Revert 2016-12-14 changes.
	* passes.def: Add pass_post_ipa_warn after first ccp after IPA.
c-family/
	* c-common.c (struct nonnull_arg_ctx): New type.
	(check_function_nonnull): Return bool instead of void.  Use
	nonnull_arg_ctx as context rather than just location_t.
	(check_nonnull_arg): Adjust for the new context type, set
	warned_p to true if a warning has been diagnosed.
	(check_function_arguments): Return bool instead of void.
	* c-common.h (check_function_arguments): Adjust prototype.
c/
	* c-typeck.c (build_function_call_vec): If check_function_arguments
	returns true, set TREE_NO_WARNING on CALL_EXPR.
cp/
	* typeck.c (cp_build_function_call_vec): If check_function_arguments
	returns true, set TREE_NO_WARNING on CALL_EXPR.
	* call.c (build_over_call): Likewise.

From-SVN: r243874
2016-12-21 23:15:59 +01:00
Alexander Monakov 9669b00bfb OpenMP offloading to NVPTX: middle-end changes
* internal-fn.c (expand_GOMP_SIMT_LANE): New.
	(expand_GOMP_SIMT_VF): New.
	(expand_GOMP_SIMT_LAST_LANE): New.
	(expand_GOMP_SIMT_ORDERED_PRED): New.
	(expand_GOMP_SIMT_VOTE_ANY): New.
	(expand_GOMP_SIMT_XCHG_BFLY): New.
	(expand_GOMP_SIMT_XCHG_IDX): New.
	* internal-fn.def (GOMP_SIMT_LANE): New.
	(GOMP_SIMT_VF): New.
	(GOMP_SIMT_LAST_LANE): New.
	(GOMP_SIMT_ORDERED_PRED): New.
	(GOMP_SIMT_VOTE_ANY): New.
	(GOMP_SIMT_XCHG_BFLY): New.
	(GOMP_SIMT_XCHG_IDX): New.
	* omp-low.c (omp_maybe_offloaded_ctx): New, outlined from...
	(create_omp_child_function): ...here.  Set "omp target entrypoint"
	or "omp declare target" attribute based on is_gimple_omp_offloaded.
	(omp_max_simt_vf): New.  Use it...
	(omp_max_vf): ...here.
	(lower_rec_input_clauses): Add reduction lowering for SIMT execution.
	(lower_lastprivate_clauses): Likewise, for "lastprivate" lowering.
	(lower_omp_ordered): Likewise, for "ordered" lowering.
	(expand_omp_simd): Add SIMT transforms.
	(pass_data_lower_omp): Add PROP_gimple_lomp_dev.
	(execute_omp_device_lower): New.
	(pass_data_omp_device_lower): New.
	(pass_omp_device_lower): New pass.
	(make_pass_omp_device_lower): New.
	* passes.def (pass_omp_device_lower): Position new pass.
	* tree-pass.h (PROP_gimple_lomp_dev): Define.
	(make_pass_omp_device_lower): Declare.

From-SVN: r242710
2016-11-22 19:57:29 +03:00
Kyrylo Tkachov f663d9ad6e GIMPLE store merging pass
2016-10-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	PR middle-end/22141
	* Makefile.in (OBJS): Add gimple-ssa-store-merging.o.
	* common.opt (fstore-merging): New Optimization option.
	* opts.c (default_options_table): Add entry for
	OPT_ftree_store_merging.
	* fold-const.h (can_native_encode_type_p): Declare prototype.
	* fold-const.c (can_native_encode_type_p): Define.
	* params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define.
	(PARAM_MAX_STORES_TO_MERGE): Likewise.
	* timevar.def (TV_GIMPLE_STORE_MERGING): New timevar.
	* passes.def: Insert pass_tree_store_merging.
	* tree-pass.h (make_pass_store_merging): Declare extern
	prototype.
	* gimple-ssa-store-merging.c: New file.
	* doc/invoke.texi (Optimization Options): Document
	-fstore-merging.
	(--param documentation): Document store-merging-allow-unaligned
	and max-stores-to-merge.

2016-10-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
            Jakub Jelinek  <jakub@redhat.com>
            Andrew Pinski  <pinskia@gmail.com>

	PR middle-end/22141
	PR rtl-optimization/23684
	* gcc.c-torture/execute/pr22141-1.c: New test.
	* gcc.c-torture/execute/pr22141-2.c: Likewise.
	* gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging.
	* gcc.target/aarch64/ldp_stp_4.c: Likewise.
	* gcc.dg/store_merging_1.c: New test.
	* gcc.dg/store_merging_2.c: Likewise.
	* gcc.dg/store_merging_3.c: Likewise.
	* gcc.dg/store_merging_4.c: Likewise.
	* gcc.dg/store_merging_5.c: Likewise.
	* gcc.dg/store_merging_6.c: Likewise.
	* gcc.dg/store_merging_7.c: Likewise.
	* gcc.target/i386/pr22141.c: Likewise.
	* gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options.
	* g++.dg/init/new17.C: Likewise.



Co-Authored-By: Andrew Pinski <pinskia@gmail.com>
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r241649
2016-10-28 14:18:50 +00:00
Michael Matz 28df87300a loop splitting
(approved at https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00648.html )

	* common.opt (-fsplit-loops): New flag.
	* passes.def (pass_loop_split): Add.
	* opts.c (default_options_table): Add OPT_fsplit_loops entry at -O3.
	(enable_fdo_optimizations): Add loop splitting.
	* timevar.def (TV_LOOP_SPLIT): Add.
	* tree-pass.h (make_pass_loop_split): Declare.
	* tree-ssa-loop-manip.h (rewrite_into_loop_closed_ssa_1): Declare.
	* tree-ssa-loop-unswitch.c: Include tree-ssa-loop-manip.h,
	* tree-ssa-loop-split.c: New file.
	* Makefile.in (OBJS): Add tree-ssa-loop-split.o.
	* doc/invoke.texi (fsplit-loops): Document.
	* doc/passes.texi (Loop optimization): Add paragraph about loop
	splitting.

testsuite/
	* gcc.dg/loop-split.c: New test.
	* gcc.dg/tree-ssa/ifc-9.c: Update.
	* gcc.dg/tree-ssa/ifc-10.c: Update.

From-SVN: r241374
2016-10-20 12:18:32 +00:00
Aldy Hernandez adc577c558 Makefile.in (OBJS): Add gimple-ssa-warn-alloca.o.
* Makefile.in (OBJS): Add gimple-ssa-warn-alloca.o.
	* passes.def: Add two instances of pass_walloca.
	* tree-pass.h (make_pass_walloca): New.
	* gimple-ssa-warn-walloca.c: New file.
	* doc/invoke.texi: Document -Walloca, -Walloca-larger-than=, and
	-Wvla-larger-than= options.

From-SVN: r241318
2016-10-18 21:40:58 +00:00
Martin Sebor 88d0c3f0a1 PR middle-end/49905 - Better sanity checking on sprintf src & dest to
gcc/ChangeLog:

	PR middle-end/49905
	* Makefile.in (OBJS): Add gimple-ssa-sprintf.o.
	* config/linux.h (TARGET_PRINTF_POINTER_FORMAT): Redefine.
	* config/linux.c (gnu_libc_printf_pointer_format): New function.
	* config/sol2.h (TARGET_PRINTF_POINTER_FORMAT): Same.
	* config/sol2.c (solaris_printf_pointer_format): New function.
	* doc/invoke.texi (-Wformat-length, -fprintf-return-value): New
	options.
	* doc/tm.texi.in (TARGET_PRINTF_POINTER_FORMAT): Document.
	* doc/tm.texi: Regenerate.
	* gimple-fold.h (get_range_strlen): New function.
	(get_maxval_strlen): Declare existing function.
	* gimple-fold.c (get_range_strlen): Add arguments and compute both
	maximum and minimum.
	 (get_range_strlen): Define overload.
	(get_maxval_strlen): Adjust.
	* gimple-ssa-sprintf.c: New file and pass.
	* passes.def (pass_sprintf_length): Add new pass.
	* targhooks.h (default_printf_pointer_format): Declare new function.
	(gnu_libc_printf_pointer_format): Same.
	(solaris_libc_printf_pointer_format): Same.
	* targhooks.c (default_printf_pointer_format): Define new function.
	* tree-pass.h (make_pass_sprintf_length): Declare new function.
	* print-tree.c: Increase buffer size.

gcc/c-family/ChangeLog:

	PR middle-end/49905
	* c.opt: Add -Wformat-length and -fprintf-return-value.

gcc/testsuite/ChangeLog:

	PR middle-end/49905
	* gcc.dg/builtin-stringop-chk-1.c: Adjust.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-2.c: New test.

From-SVN: r240298
2016-09-20 19:39:27 -06:00
Kugan Vivekanandarajah 973625a04b Add Early VRP
gcc/ChangeLog:

2016-09-21  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* doc/invoke.texi: Document -fdump-tree-evrp.
	* passes.def: Define new pass_early_vrp.
	* timevar.def: Define new TV_TREE_EARLY_VRP.
	* tree-pass.h (make_pass_early_vrp): New.
	* tree-ssa-propagate.c: Make replace_uses_in non static.
	* tree-ssa-propagate.h: Export replace_uses_in.
	* tree-vrp.c (extract_range_for_var_from_comparison_expr): New.
	(extract_range_from_assert): Factor out
	extract_range_for_var_from_comparison_expr.
	(vrp_initialize_lattice): New.
	(vrp_initialize): Factor out vrp_initialize_lattice.
	(vrp_valueize): Fix it to reject complex value ranges.
	(vrp_free_lattice): New.
	(evrp_dom_walker::before_dom_children): Likewise.
	(evrp_dom_walker::after_dom_children): Likewise.
	(evrp_dom_walker::push_value_range): Likewise.
	(evrp_dom_walker::pop_value_range): Likewise.
	(execute_early_vrp): Likewise.
	(execute_vrp): Call vrp_initialize_lattice and
	vrp_free_lattice.
	(make_pass_early_vrp): New.


gcc/testsuite/ChangeLog:

2016-09-21  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* g++.dg/tree-ssa/pr31146-2.C: Run with -fno-tree-evrp as evrp also
	does the same transformation.
	* g++.dg/warn/pr33738.C: XFAIL as optimization now happens in ccp.
	* gcc.dg/tree-ssa/evrp1.c: New test.
	* gcc.dg/tree-ssa/evrp2.c: New test.
	* gcc.dg/tree-ssa/evrp3.c: New test.
	* gcc.dg/tree-ssa/pr20657.c: Check for the pattern in evrp dump.
	* gcc.dg/tree-ssa/pr22117.c: Likewise.
	* gcc.dg/tree-ssa/pr61839_2.c: Likewise.
	* gcc.dg/tree-ssa/pr64130.c: Likewise.
	* gcc.dg/tree-ssa/pr37508.c: Change the pattern to be checked as
	foling now happens early.
	* gcc.dg/tree-ssa/vrp04.c: Likewise.
	* gcc.dg/tree-ssa/vrp06.c: Likewise.
	* gcc.dg/tree-ssa/vrp16.c: Likewise.
	* gcc.dg/tree-ssa/vrp25.c: Likewise.
	* gcc.dg/tree-ssa/vrp67.c: Likewise.

From-SVN: r240291
2016-09-20 23:23:55 +00:00
Jan Hubicka b720e91919 passes.def (pass_early_thread_jumps): Schedule after forwprop.
* passes.def (pass_early_thread_jumps): Schedule after forwprop.
	* tree-pass.h (make_pass_early_thread_jumps): Declare.
	* tree-ssa-threadbackward.c (fsm_find_thread_path,
	fsm_find_thread_path, profitable_jump_thread_path,
	fsm_find_control_statement_thread_paths,
	find_jump_threads_backwards): Add speed_p parameter.
	(pass_data_early_thread_jumps): New pass.
	(make_pass_early_thread_jumps): New function.

	* g++.dg/predict-loop-exit-1.C: Disable early jump threading.
	* g++.dg/predict-loop-exit-2.C: Disable early jump threading.
	* g++.dg/predict-loop-exit-3.C: Disable early jump threading.
	* gcc.dg/tree-ssa/pr69196-1.c: Disable early jump threading.
	* gcc.dg/tree-ssa/vrp01.c: Disable early jump threading.
	* gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Disable early jump threading.
	* gcc.dg/tree-ssa/pr68198.c: Scan ethread dump.
	* gcc.dg/tree-ssa/ssa-thread-13.c: Scan ethread dump.
	* gcc.dg/tree-ssa/vrp56.c: Scan ethread dump.
	* gcc.dg/tree-ssa/vrp92.c: Scan ethread dump.
	* gcc.dg/uninit-15.c: Swap xfailed and non-xfailed alternative.

From-SVN: r240221
2016-09-18 18:44:53 +00:00
Richard Biener f02510201a tree-pass.h (make_pass_materialize_all_clones): Declare.
2016-08-18  Richard Biener  <rguenther@suse.de>

	* tree-pass.h (make_pass_materialize_all_clones): Declare.
	* ipa.c (pass_data_materialize_all_clones, pass_materialize_all_clones,
	make_pass_materialize_all_clones): New simple IPA pass encapsulating
	clone materialization.
	* passes.def (all_late_ipa_passes): Start with
	pass_materialize_all_clones.
	* cgraphunit.c (symbol_table::compile): Remove call to
	materialize_all_clones.
	* tree-into-ssa.c: Include statistics.h.
	(update_ssa): Count number of times we do incremental/rewrite
	SSA update.

From-SVN: r239567
2016-08-18 10:41:53 +00:00
Jeff Law 8b2ef235c0 tree-ssa-threadedge.c: Remove include of tree-ssa-threadbackward.h.
* tree-ssa-threadedge.c: Remove include of tree-ssa-threadbackward.h.
	(thread_across_edge): Remove calls to find_jump_threads_backwards.
	* passes.def: Add jump threading passes before DOM/VRP.
	* tree-ssa-threadbackward.c (find_jump_threads_backwards): Change
	argument to a basic block from an edge.  Remove tests which are
	handled elsewhere.
	(pass_data_thread_jumps, class pass_thread_jumps): New.
	(pass_thread_jumps::gate, pass_thread_jumps::execute): New.
	(make_pass_thread_jumps): Likewise.
	* tree-pass.h (make_pass_thread_jumps): Declare.

	* gcc.dg/tree-ssa/pr21417.c: Update expected output.
	* gcc.dg/tree-ssa/pr66752-3.c: Likewise.
	* gcc.dg/tree-ssa/pr68198.c: Likewise.
	* gcc.dg/tree-ssa/pr69196-1.c: Likewise.
	* gcc.dg/tree-ssa/pr69270-3.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-2g.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-2h.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-6.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-12.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-thread-13.c: Likewise.
	* gcc.dg/tree-ssa/vrp56.c: Likewise.

From-SVN: r236831
2016-05-27 10:32:38 -06:00
Richard Biener 381cdae497 gimplify.h (get_initialized_tmp_var): Add allow_ssa parameter default true.
2016-05-03  Richard Biener  <rguenther@suse.de>

	* gimplify.h (get_initialized_tmp_var): Add allow_ssa parameter
	default true.
	(gimplify_arg): Likewise.
	* gimplify.c (gimplify_expr): Add overload with allow_ssa parameter,
	re-writing the result to a decl if required.
	(internal_get_tmp_var): Add allow_ssa parameter
	and override into_ssa with it.
	(get_formal_tmp_var): Adjust.
	(get_initialized_tmp_var): Add allow_ssa parameter.
	(gimplify_arg): Add allow_ssa parameter and avoid generating
	SSA names for the result false.
	(gimplify_call_expr): If the call may return twice do not
	gimplify parameters into SSA.
	(prepare_gimple_addressable): Do not allow an SSA name as
	temporary.
	(gimplify_modify_expr): Adjust assert.  For noreturn calls
	with a SSA name LHS adjust its def.
	(gimplify_save_expr): Do not allow an SSA name as save-expr
	result.
	(gimplify_one_sizepos): Do not allow an SSA name as a sizepos.
	(gimplify_body): Init GIMPLE SSA data structures and gimplify
	into-SSA.
	(gimplify_scan_omp_clauses): Make sure OMP_CLAUSE_SIZE is not
	an SSA name.  Likewise for OMP_CLAUSE_REDUCTION operands.
	(gimplify_omp_for): Likewise for OMP_CLAUSE_DECL.  Likewise
	for OMP_FOR_COND,  OMP_FOR_INCR and OMP_CLAUSE_LINEAR_STEP.
	(optimize_target_teams): Do not allow SSA names for clause operands.
	(gimplify_expr): Likewise for where we mark the result addressable.
	* passes.def (pass_init_datastructures): Remove.
	* tree-into-ssa.c (mark_def_sites): Ignore existing SSA names.
	(rewrite_stmt): Likewise.
	* tree-inline.c (initialize_cfun): Properly transfer SSA state.
	(replace_locals_op): Replace SSA names.
	(copy_gimple_seq_and_replace_locals): Init src_cfun.
	* gimple-low.c (lower_builtin_setjmp): Deal with SSA.
	* cgraph.c (release_function_body): Free CFG annotations only
	when we have a CFG.  Simplify.
	* gimple-fold.c (gimplify_and_update_call_from_tree): Use
	force_gimple_operand instead of get_initialized_tmp_var.
	* tree-pass.h (make_pass_init_datastructures): Remove.
	* tree-ssa.c (execute_init_datastructures): Remove.
	(pass_data_init_datastructures): Likewise.
	(class pass_init_datastructures): Likewise.
	(make_pass_init_datastructures): Likewise.
	* omp-low.c (create_omp_child_function): Init SSA data structures.
	(grid_expand_target_grid_body): Likewise.
	* tree-cfg.c (move_block_to_fn): Double-check the DEF is an SSA
	name before adding it to names_to_release.
	(remove_bb): Always release SSA defs.
	* tree-ssa-ccp.c (get_default_value): Check SSA_NAME_VAR
	before dereferencing it.
	* cgraphunit.c (init_lowered_empty_function): Always
	int SSA data structures.
	* tree-ssanames.c (release_defs): Remove assert that we are in
	SSA form.
	* trans-mem.c (diagnose_tm_1): Handle SSA name function.

	c-family/
	* cilk.c (cilk_gimplify_call_params_in_spawned_fn): Do not
	allow call args to gimplify to SSA names.

	* gcc.dg/pr30172-1.c: Adjust.
	* gcc.dg/pr63743.c: Likewise.
	* gcc.dg/tm/pr51696.c: Likewise.
	* c-c++-common/tm/safe-1.c: Likewise.
	* gcc.dg/tree-prof/val-prof-3.c: Likewise.
	* gcc.dg/plugin/self-assign-test-1.c: XFAIL case that needs CSE.
	* g++.dg/plugin/self-assign-test-1.C: Likewise.
	* g++.dg/plugin/self-assign-test-2.C: Likewise.

From-SVN: r235817
2016-05-03 12:06:19 +00:00
Tom de Vries 182c78687e Only finalize dot files that have been initialized
2016-04-17  Tom de Vries  <tom@codesourcery.com>

	PR other/70185
	* tree-pass.h (class opt_pass): Remove graph_dump_initialized member.
	* dumpfile.h (struct dump_file_info): Add graph_dump_initialized field.
	* dumpfile.c (dump_files): Initialize graph_dump_initialized field.
	* passes.c (finish_optimization_passes): Only call
	finish_graph_dump_file if dfi->graph_dump_initialized.
	(execute_function_dump, pass_init_dump_file): Use
	dfi->graph_dump_initialized instead of pass->graph_dump_initialized.

From-SVN: r235074
2016-04-17 05:22:33 +00:00
Jakub Jelinek bf14eba23b re PR c/69835 (-Wnonnull diagnoses parameter comparisons with NULL even when those could have changed)
PR c/69835
	* common.opt (Wnonnull-compare): New warning.
	* doc/invoke.texi (-Wnonnull): Remove text about comparison
	of arguments against NULL.
	(-Wnonnull-compare): Document.
	* Makefile.in (OBJS): Add gimple-ssa-nonnull-compare.o.
	* tree-pass.h (make_pass_warn_nonnull_compare): Declare.
	* passes.def (pass_warn_nonnull_compare): Add.
	* gimple-ssa-nonnull-compare.c: New file.
c-family/
	* c.opt (Wnonnull-compare): Enable for -Wall.
c/
	* c-typeck.c (build_binary_op): Revert 2015-09-09 change.
cp/
	* typeck.c (cp_build_binary_op): Revert 2015-09-09 change.
testsuite/
	* c-c++-common/nonnull-1.c: Use -Wnonnull-compare instead of
	-Wnonnull in dg-options.
	* c-c++-common/nonnull-2.c: New test.

From-SVN: r233472
2016-02-16 21:46:17 +01:00
Martin Jambor b2b4005150 Merge of HSA
2016-01-19  Martin Jambor  <mjambor@suse.cz>
	    Martin Liska  <mliska@suse.cz>
	    Michael Matz <matz@suse.de>

libgomp/
	* plugin/Makefrag.am: Add HSA plugin requirements.
	* plugin/configfrag.ac (HSA_RUNTIME_INCLUDE): New variable.
	(HSA_RUNTIME_LIB): Likewise.
	(HSA_RUNTIME_CPPFLAGS): Likewise.
	(HSA_RUNTIME_INCLUDE): New substitution.
	(HSA_RUNTIME_LIB): Likewise.
	(HSA_RUNTIME_LDFLAGS): Likewise.
	(hsa-runtime): New configure option.
	(hsa-runtime-include): Likewise.
	(hsa-runtime-lib): Likewise.
	(PLUGIN_HSA): New substitution variable.
	Fill HSA_RUNTIME_INCLUDE and HSA_RUNTIME_LIB according to the new
	configure options.
	(PLUGIN_HSA_CPPFLAGS): Likewise.
	(PLUGIN_HSA_LDFLAGS): Likewise.
	(PLUGIN_HSA_LIBS): Likewise.
	Check that we have access to HSA run-time.
	* libgomp-plugin.h (offload_target_type): New element
	OFFLOAD_TARGET_TYPE_HSA.
	* libgomp.h (gomp_target_task): New fields firstprivate_copies and
	args.
	(bool gomp_create_target_task): Updated.
	(gomp_device_descr): Extra parameter of run_func and async_run_func,
	new field can_run_func.
	* libgomp_g.h (GOMP_target_ext): Update prototype.
	* oacc-host.c (host_run): Added a new parameter args.
	* target.c (calculate_firstprivate_requirements): New function.
	(copy_firstprivate_data): Likewise.
	(gomp_target_fallback_firstprivate): Use them.
	(gomp_target_unshare_firstprivate): New function.
	(gomp_get_target_fn_addr): Allow returning NULL for shared memory
	devices.
	(GOMP_target): Do host fallback for all shared memory devices.  Do not
	pass any args to plugins.
	(GOMP_target_ext): Introduce device-specific argument parameter args.
	Allow host fallback if device shares memory.  Do not remap data if
	device has shared memory.
	(gomp_target_task_fn): Likewise.  Also treat shared memory devices
	like host fallback for mappings.
	(GOMP_target_data): Treat shared memory devices like host fallback.
	(GOMP_target_data_ext): Likewise.
	(GOMP_target_update): Likewise.
	(GOMP_target_update_ext): Likewise.  Also pass NULL as args to
	gomp_create_target_task.
	(GOMP_target_enter_exit_data): Likewise.
	(omp_target_alloc): Treat shared memory devices like host fallback.
	(omp_target_free): Likewise.
	(omp_target_is_present): Likewise.
	(omp_target_memcpy): Likewise.
	(omp_target_memcpy_rect): Likewise.
	(omp_target_associate_ptr): Likewise.
	(gomp_load_plugin_for_device): Also load can_run.
	* task.c (GOMP_PLUGIN_target_task_completion): Free
	firstprivate_copies.
	(gomp_create_target_task): Accept new argument args and store it to
	ttask.
	* plugin/plugin-hsa.c: New file.

gcc/
	* Makefile.in (OBJS): Add new source files.
	(GTFILES): Add hsa.c.
	* common.opt (disable_hsa): New variable.
	(-Whsa): New warning.
	* config.in (ENABLE_HSA): New.
	* configure.ac: Treat hsa differently from other accelerators.
	(OFFLOAD_TARGETS): Define ENABLE_OFFLOADING according to
	$enable_offloading.
	(ENABLE_HSA): Define ENABLE_HSA according to $enable_hsa.
	* doc/install.texi (Configuration): Document --with-hsa-runtime,
	--with-hsa-runtime-include, --with-hsa-runtime-lib and
	--with-hsa-kmt-lib.
	* doc/invoke.texi (-Whsa): Document.
	(hsa-gen-debug-stores): Likewise.
	* lto-wrapper.c (compile_images_for_offload_targets): Do not attempt
	to invoke offload compiler for hsa acclerator.
	* opts.c (common_handle_option): Determine whether HSA offloading
	should be performed.
	* params.def (PARAM_HSA_GEN_DEBUG_STORES): New parameter.
	* builtin-types.def (BT_FN_VOID_UINT_PTR_INT_PTR): New.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): Removed.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_PTR): New.
	* gimple-low.c (lower_stmt): Also handle GIMPLE_OMP_GRID_BODY.
	* gimple-pretty-print.c (dump_gimple_omp_for): Also handle
	GF_OMP_FOR_KIND_GRID_LOOP.
	(dump_gimple_omp_block): Also handle GIMPLE_OMP_GRID_BODY.
	(pp_gimple_stmt_1): Likewise.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* gimple.c (gimple_build_omp_grid_body): New function.
	(gimple_copy): Also handle GIMPLE_OMP_GRID_BODY.
	* gimple.def (GIMPLE_OMP_GRID_BODY): New.
	* gimple.h (enum gf_mask): Added GF_OMP_PARALLEL_GRID_PHONY,
	GF_OMP_FOR_KIND_GRID_LOOP, GF_OMP_FOR_GRID_PHONY and
	GF_OMP_TEAMS_GRID_PHONY.
	(gimple_statement_omp_single_layout): Updated comments.
	(gimple_build_omp_grid_body): New function.
	(gimple_has_substatements): Also handle GIMPLE_OMP_GRID_BODY.
	(gimple_omp_for_grid_phony): New function.
	(gimple_omp_for_set_grid_phony): Likewise.
	(gimple_omp_parallel_grid_phony): Likewise.
	(gimple_omp_parallel_set_grid_phony): Likewise.
	(gimple_omp_teams_grid_phony): Likewise.
	(gimple_omp_teams_set_grid_phony): Likewise.
	(gimple_return_set_retbnd): Also handle GIMPLE_OMP_GRID_BODY.
	* omp-builtins.def (BUILT_IN_GOMP_OFFLOAD_REGISTER): New.
	(BUILT_IN_GOMP_OFFLOAD_UNREGISTER): Likewise.
	(BUILT_IN_GOMP_TARGET): Updated type.
	* omp-low.c: Include symbol-summary.h, hsa.h and params.h.
	(adjust_for_condition): New function.
	(get_omp_for_step_from_incr): Likewise.
	(extract_omp_for_data): Moved parts to adjust_for_condition and
	get_omp_for_step_from_incr.
	(build_outer_var_ref): Handle GIMPLE_OMP_GRID_BODY.
	(fixup_child_record_type): Bail out if receiver_decl is NULL.
	(scan_sharing_clauses): Handle OMP_CLAUSE__GRIDDIM_.
	(scan_omp_parallel): Do not create child functions for phony
	constructs.
	(check_omp_nesting_restrictions): Handle GIMPLE_OMP_GRID_BODY.
	(scan_omp_1_op): Checking assert we are not remapping to
	ERROR_MARK.  Also also handle GIMPLE_OMP_GRID_BODY.
	(parallel_needs_hsa_kernel_p): New function.
	(expand_parallel_call): Register apprpriate parallel child
	functions as HSA kernels.
	(grid_launch_attributes_trees): New type.
	(grid_attr_trees): New variable.
	(grid_create_kernel_launch_attr_types): New function.
	(grid_insert_store_range_dim): Likewise.
	(grid_get_kernel_launch_attributes): Likewise.
	(get_target_argument_identifier_1): Likewise.
	(get_target_argument_identifier): Likewise.
	(get_target_argument_value): Likewise.
	(push_target_argument_according_to_value): Likewise.
	(get_target_arguments): Likewise.
	(expand_omp_target): Call get_target_arguments instead of looking
	up for teams and thread limit.
	(grid_expand_omp_for_loop): New function.
	(grid_arg_decl_map): New type.
	(grid_remap_kernel_arg_accesses): New function.
	(grid_expand_target_kernel_body): New function.
	(expand_omp): Call it.
	(lower_omp_for): Do not emit phony constructs.
	(lower_omp_taskreg): Do not emit phony constructs but create for them
	a temporary variable receiver_decl.
	(lower_omp_taskreg): Do not emit phony constructs.
	(lower_omp_teams): Likewise.
	(lower_omp_grid_body): New function.
	(lower_omp_1): Call it.
	(grid_reg_assignment_to_local_var_p): New function.
	(grid_seq_only_contains_local_assignments): Likewise.
	(grid_find_single_omp_among_assignments_1): Likewise.
	(grid_find_single_omp_among_assignments): Likewise.
	(grid_find_ungridifiable_statement): Likewise.
	(grid_target_follows_gridifiable_pattern): Likewise.
	(grid_remap_prebody_decls): Likewise.
	(grid_copy_leading_local_assignments): Likewise.
	(grid_process_kernel_body_copy): Likewise.
	(grid_attempt_target_gridification): Likewise.
	(grid_gridify_all_targets_stmt): Likewise.
	(grid_gridify_all_targets): Likewise.
	(execute_lower_omp): Call grid_gridify_all_targets.
	(make_gimple_omp_edges): Handle GIMPLE_OMP_GRID_BODY.
	* tree-core.h (omp_clause_code): Added OMP_CLAUSE__GRIDDIM_.
	(tree_omp_clause): Added union field dimension.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE__GRIDDIM_.
	* tree.c (omp_clause_num_ops): Added number of arguments of
	OMP_CLAUSE__GRIDDIM_.
	(omp_clause_code_name): Added name of OMP_CLAUSE__GRIDDIM_.
	(walk_tree_1): Handle OMP_CLAUSE__GRIDDIM_.
	* tree.h (OMP_CLAUSE_GRIDDIM_DIMENSION): New.
	(OMP_CLAUSE_SET_GRIDDIM_DIMENSION): Likewise.
	(OMP_CLAUSE_GRIDDIM_SIZE): Likewise.
	(OMP_CLAUSE_GRIDDIM_GROUP): Likewise.
	* passes.def: Schedule pass_ipa_hsa and pass_gen_hsail.
	* tree-pass.h (make_pass_gen_hsail): Declare.
	(make_pass_ipa_hsa): Likewise.
	* ipa-hsa.c: New file.
	* lto-section-in.c (lto_section_name): Add hsa section name.
	* lto-streamer.h (lto_section_type): Add hsa section.
	* timevar.def (TV_IPA_HSA): New.
        * hsa-brig-format.h: New file.
	* hsa-brig.c: New file.
	* hsa-dump.c: Likewise.
	* hsa-gen.c: Likewise.
	* hsa.c: Likewise.
	* hsa.h: Likewise.
	* toplev.c (compile_file): Call hsa_output_brig.
	* hsa-regalloc.c: New file.

gcc/fortran/
	* types.def (BT_FN_VOID_UINT_PTR_INT_PTR): New.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): Removed.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_PTR): New.

gcc/lto/
	* lto-partition.c: Include "hsa.h"
	(add_symbol_to_partition_1): Put hsa implementations into the
	same partition as host implementations.

liboffloadmic/
	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_async_run): New
	unused parameter.
	(GOMP_OFFLOAD_run): Likewise.

include/
	* gomp-constants.h (GOMP_DEVICE_HSA): New macro.
	(GOMP_VERSION_HSA): Likewise.
	(GOMP_TARGET_ARG_DEVICE_MASK): Likewise.
	(GOMP_TARGET_ARG_DEVICE_ALL): Likewise.
	(GOMP_TARGET_ARG_SUBSEQUENT_PARAM): Likewise.
	(GOMP_TARGET_ARG_ID_MASK): Likewise.
	(GOMP_TARGET_ARG_NUM_TEAMS): Likewise.
	(GOMP_TARGET_ARG_THREAD_LIMIT): Likewise.
	(GOMP_TARGET_ARG_VALUE_SHIFT): Likewise.
	(GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES): Likewise.

From-SVN: r232549
2016-01-19 11:35:10 +01:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Tom de Vries 597a8ab9c6 Add pass_oacc_ipa
2015-12-16  Tom de Vries  <tom@codesourcery.com>

	* opts.c (default_options_optimization): Set fipa-pta on by default for
	fopenacc.
	* passes.def: Move kernels pass group to pass_ipa_oacc.
	* tree-pass.h (make_pass_oacc_kernels2): Remove.
	(make_pass_ipa_oacc, make_pass_ipa_oacc_kernels): Declare.
	* tree-ssa-loop.c (pass_oacc_kernels2, make_pass_oacc_kernels2): Remove.
	(pass_ipa_oacc, pass_ipa_oacc_kernels): New pass.
	(make_pass_ipa_oacc, make_pass_ipa_oacc_kernels): New function.
	* tree-ssa-structalias.c (pass_ipa_pta::clone): New function.

	* g++.dg/ipa/devirt-37.C: Update for new fre2 pass.
	* g++.dg/ipa/devirt-40.C: Same.
	* g++.dg/tree-ssa/pr61034.C: Same.
	* gcc.dg/ipa/ipa-pta-1.c: Update for new pta1 pass.
	* gcc.dg/ipa/ipa-pta-10.c: Same.
	* gcc.dg/ipa/ipa-pta-11.c: Same.
	* gcc.dg/ipa/ipa-pta-14.c: Same.
	* gcc.dg/ipa/ipa-pta-16.c: Same.
	* gcc.dg/ipa/ipa-pta-2.c: Same.
	* gcc.dg/ipa/ipa-pta-5.c: Same.
	* gcc.dg/ipa/ipa-pta-6.c: Same.
	* gcc.dg/torture/ipa-pta-1.c: Same.
	* gcc.dg/ipa/ipa-pta-13.c: Update for new fre2 and pta1 pass.
	* gcc.dg/ipa/ipa-pta-3.c: Same.
	* gcc.dg/ipa/ipa-pta-4.c: Same.

From-SVN: r231690
2015-12-16 13:49:07 +00:00
Ilya Verbin 4a38b02b4e c-common.c (c_common_attribute_table): Handle "omp declare target link" attribute.
gcc/c-family/
	* c-common.c (c_common_attribute_table): Handle "omp declare target
	link" attribute.
gcc/
	* cgraphunit.c (output_in_order): Do not assemble "omp declare target
	link" variables in ACCEL_COMPILER.
	* gimplify.c (gimplify_adjust_omp_clauses): Do not remove mapping of
	"omp declare target link" variables.
	* omp-low.c (scan_sharing_clauses): Do not remove mapping of "omp
	declare target link" variables.
	(add_decls_addresses_to_decl_constructor): For "omp declare target link"
	variables output address of the artificial pointer instead of address of
	the variable.  Set most significant bit of the size to mark them.
	(pass_data_omp_target_link): New pass_data.
	(pass_omp_target_link): New class.
	(find_link_var_op): New static function.
	(make_pass_omp_target_link): New function.
	* passes.def: Add pass_omp_target_link.
	* tree-pass.h (make_pass_omp_target_link): Declare.
	* varpool.c (symbol_table::output_variables): Do not assemble "omp
	declare target link" variables in ACCEL_COMPILER.
gcc/lto/
	* lto.c: Include stringpool.h and fold-const.h.
	(offload_handle_link_vars): New static function.
	(lto_main): Call offload_handle_link_vars.
libgomp/
	* libgomp.h (REFCOUNT_LINK): Define.
	(struct splay_tree_key_s): Add link_key.
	* target.c (gomp_map_vars): Treat REFCOUNT_LINK objects as not mapped.
	Replace target address of the pointer with target address of newly
	mapped object in the splay tree.  Set link pointer on target to the
	device address of the mapped object.
	(gomp_unmap_vars): Restore target address of the pointer in the splay
	tree for REFCOUNT_LINK objects after unmapping.
	(gomp_load_image_to_device): Set refcount to REFCOUNT_LINK for "omp
	declare target link" objects.
	(gomp_unload_image_from_device): Replace j with i.  Force unmap of all
	"omp declare target link" objects, which were mapped for the image.
	(gomp_exit_data): Restore target address of the pointer in the splay
	tree for REFCOUNT_LINK objects after unmapping.
	* testsuite/libgomp.c/target-link-1.c: New file.

From-SVN: r231655
2015-12-15 14:56:50 +00:00
Dmitry Vyukov 95e7bbb8d6 Add fuzzing coverage support
* sancov.c: New file.
	* Makefile.in (OBJS): Add sancov.o.
	* invoke.texi (-fsanitize-coverage=trace-pc): Describe.
	* passes.def (sancov_pass): Add.
	* tree-pass.h  (sancov_pass): Add.
	* common.opt (-fsanitize-coverage=trace-pc): Add.
	* sanitizer.def (BUILT_IN_SANITIZER_COV_TRACE_PC): Add.
	* builtins.def (DEF_SANITIZER_BUILTIN): Enable for
	flag_sanitize_coverage.

From-SVN: r231296
2015-12-04 10:27:54 -08:00
Tom de Vries 896522eec5 Add pass_oacc_kernels
2015-11-25  Tom de Vries  <tom@codesourcery.com>

	* tree-pass.h (make_pass_oacc_kernels, make_pass_oacc_kernels2):
	Declare.
	* tree-ssa-loop.c (gate_oacc_kernels): New static function.
	(pass_data_oacc_kernels, pass_data_oacc_kernels2): New pass_data.
	(class pass_oacc_kernels, class pass_oacc_kernels2): New pass.
	(make_pass_oacc_kernels, make_pass_oacc_kernels2): New function.

From-SVN: r230906
2015-11-25 21:26:24 +00:00
Tom de Vries 7cf76184c4 Remove first_pass_instance
2015-11-16  Tom de Vries  <tom@codesourcery.com>

	* passes.c (first_pass_instance): Remove variable.
	(execute_todo): Remove setting of first_pass_instance.
	* tree-pass.h (first_pass_instance): Remove declaration.

From-SVN: r230420
2015-11-16 12:40:50 +00:00
Tom de Vries 5ce8d99a1b Remove first_pass_instance from pass_dominator
2015-11-16  Tom de Vries  <tom@codesourcery.com>

	* passes.def: Add arg to pass_dominator pass instantiation.
	* tree-pass.h (first_pass_instance): Remove pass_dominator-related bit
	of comment.
	* tree-ssa-dom.c (pass_dominator::pass_dominator): Initialize
	may_peel_loop_headers_p.
	(pass_dominator::set_pass_param): New member function.  Set
	may_peel_loop_headers_p.
	(pass_dominator::may_peel_loop_headers_p): New private member.
	(pass_dominator::execute): Use may_peel_loop_headers_p instead of
	first_pass_instance.

From-SVN: r230417
2015-11-16 12:40:24 +00:00
Tom de Vries b0c77505dd Remove first_pass_instance from pass_vrp
2015-11-16  Tom de Vries  <tom@codesourcery.com>

	* gdbhooks.py (class PassNames): Handle extra arg NEXT_PASS argument.
	* gen-pass-instances.awk (handle_line): Same.
	* pass_manager.h (class pass_manager): Define and undefine
	NEXT_PASS_WITH_ARG.
	* passes.c (opt_pass::set_pass_param): New function.
	(pass_manager::pass_manager): Define and undefine NEXT_PASS_WITH_ARG.
	* passes.def: Add extra arg to NEXT_PASS (pass_vrp).
	* tree-pass.h (gimple_opt::set_pass_param): Declare.
	* tree-vrp.c (vrp_finalize, execute_vrp): Add and handle
	warn_array_bounds_p parameter.
	(pass_vrp::pass_vrp): Initialize warn_array_bounds_p.
	(pass_vrp::set_pass_param): New function.
	(pass_vrp::execute): Add warn_array_bounds_p arg to execute_vrp call.
	(pass_vrp::warn_array_bounds_p): New private member.

From-SVN: r230415
2015-11-16 12:40:05 +00:00
Ajit Agarwal 8fe17e23b0 [Patch,tree-optimization]: Add new path Splitting pass on tree ssa
representation

	* Makefile.in (OBJS): Add gimple-ssa-split-paths.o
	* common.opt (-fsplit-paths): New flag controlling path splitting.
	* doc/invoke.texi (fsplit-paths): Document.
	* opts.c (default_options_table): Add -fsplit-paths to -O2.
	* passes.def: Add split_paths pass.
	* timevar.def (TV_SPLIT_PATHS): New timevar.
	* tracer.c: Include "tracer.h"
	(ignore_bb_p): No longer static.
	(transform_duplicate): New function, broken out of tail_duplicate.
	(tail_duplicate): Use transform_duplicate.
	* tracer.h (ignore_bb_p): Declare
	(transform_duplicate): Likewise.
	* tree-pass.h (make_pass_split_paths): Declare.
	* gimple-ssa-split-paths.c: New file.

	* gcc.dg/tree-ssa/split-path-1.c: New test.

Co-Authored-By: Jeff Law <law@redhat.com>

From-SVN: r230364
2015-11-13 16:31:51 -07:00
Martin Liska be373510f8 Pass manager: add support for termination of pass list
* cgraphunit.c (cgraph_node::expand_thunk): Call
	allocate_struct_function before init_function_start.
	(cgraph_node::expand): Use push_cfun and pop_cfun.
	* config/i386/i386.c (ix86_code_end): Call
	allocate_struct_function before init_function_start.
	* config/rs6000/rs6000.c (rs6000_code_end): Likewise.
	* function.c (init_function_start): Move preamble to all
	callers.
	* passes.c (do_per_function_toporder): Use push_cfun and pop_cfun.
	(execute_one_pass): Handle newly added TODO_discard_function.
	(execute_pass_list_1): Terminate if cfun equals to NULL.
	(execute_pass_list): Do not push and pop cfun, expect that
	cfun is set.
	* tree-pass.h (TODO_discard_function): Define.

From-SVN: r229764
2015-11-04 16:50:45 +00:00
Evgeny Stupachenko 3b1661a9b9 Makefile.in (OBJS): Add multiple_target.o.
2015-10-30  Evgeny Stupachenko  <evstupac@gmail.com>

gcc/
	* Makefile.in (OBJS): Add multiple_target.o.
	* attrib.c (make_attribute): Moved from config/i386/i386.c
	* config/i386/i386.c (make_attribute): Deleted.
	* multiple_target.c (create_dispatcher_calls): New.
	(get_attr_len): Ditto.
	(get_attr_str): Ditto.
	(separate_attrs): Ditto.
	(is_valid_asm_symbol): Ditto.
	(create_new_asm_name): Ditto.
	(create_target_clone): Ditto.
	(expand_target_clones): Ditto.
	(ipa_target_clone): Ditto.
	(ipa_dispatcher_calls): Ditto.
	* passes.def (pass_target_clone): Two new ipa passes.
	* tree-pass.h (make_pass_target_clone): Ditto.
	* doc/extend.texi (target_clones): New attribute description.
gcc/c-family/
	* c-common.c (handle_target_clones_attribute): New.
	(c_common_attribute_table): Add handle_target_clones_attribute.
	(handle_always_inline_attribute): Add check on target_clones attribute.
	(handle_target_attribute): Ditto.
gcc/testsuite/
	* gcc.dg/mvc1.c: New test for multiple targets cloning.
	* gcc.dg/mvc2.c: Ditto.
	* gcc.dg/mvc3.c: Ditto.
	* gcc.dg/mvc4.c: Ditto.
	* gcc.dg/mvc5.c: Ditto.
	* gcc.dg/mvc6.c: Ditto.
	* gcc.dg/mvc7.c: Ditto.
	* g++.dg/ext/mvc1.C: Ditto.
	* g++.dg/ext/mvc2.C: Ditto.
	* g++.dg/ext/mvc3.C: Ditto.
	* g++.dg/ext/mvc4.C: Ditto.

From-SVN: r229595
2015-10-30 18:17:43 +00:00
Richard Sandiford 6a75d560c8 Add a pass to back-propagate use information
This patch adds a pass that collects information that is common to
all uses of an SSA name X and back-propagates that information up
the statements that generate X.  The general idea is to use the
information to simplify instructions (rather than a pure DCE) so
I've simply called it gimple-ssa-backprop.c, to go with
tree-ssa-forwprop.c.

At the moment the only use of the pass is to remove unnecessary
sign operations, so that it's effectively a global version of
fold_strip_sign_ops.  I'm hoping it could be extended in future
to record which bits of an integer are significant.  There are
probably other potential uses too.

A later patch gets rid of fold_strip_sign_ops.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* doc/invoke.texi (-fdump-tree-backprop, -fssa-backprop): Document.
	* Makefile.in (OBJS): Add gimple-ssa-backprop.o.
	* common.opt (fssa-backprop): New option.
	* fold-const.h (negate_mathfn_p): Declare.
	* fold-const.c (negate_mathfn_p): Make public.
	* timevar.def (TV_TREE_BACKPROP): New.
	* tree-pass.h (make_pass_backprop): Declare.
	* passes.def (pass_backprop): Add.
	* gimple-ssa-backprop.c: New file.

gcc/testsuite/
	* gcc.dg/tree-ssa/backprop-1.c, gcc.dg/tree-ssa/backprop-2.c,
	gcc.dg/tree-ssa/backprop-3.c, gcc.dg/tree-ssa/backprop-4.c,
	gcc.dg/tree-ssa/backprop-5.c, gcc.dg/tree-ssa/backprop-6.c: New tests.

From-SVN: r229139
2015-10-21 20:11:33 +00:00
Richard Sandiford 53f3cd25de PR67945: Fix oscillation between pow representations
This patch fixes some fallout from my patch to move the sqrt and cbrt
folding rules to match.pd.  The rules included canonicalisations like:

       sqrt(sqrt(x))->pow(x,1/4)

which in the original code was only ever done at the generic level.
My patch meant that we'd do it whenever we tried to fold a gimple
statement, and eventually it would win over the sincos optimisation
that replaces pow(x,1/4) with sqrt(sqrt(x)).

Following a suggestion from Richard B, the patch adds a new
PROP_gimple_* flag to say whether fp routines have been optimised
for the target.  If so, match.pd should only transform calls to math
functions if the result is actually an optimisation, not just an
IL simplification or canonicalisation.  The question then of course
is: which rules are which?  I've added block comments that describe
the criteria I was using.

A slight wart is that we need to use the cfun global to access
the PROP_gimple_* flag; there's no local function pointer available.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
on powerc64-linux-gnu.

gcc/
	PR tree-optimization/67945
	* tree-pass.h (PROP_gimple_opt_math): New property flag.
	* generic-match-head.c (canonicalize_math_p): New function.
	* gimple-match-head.c: Include tree-pass.h.
	(canonicalize_math_p): New function.
	* match.pd: Group math built-in rules into simplifications
	and canonicalizations.  Guard the latter with canonicalize_math_p.
	* tree-ssa-math-opts.c (pass_data_cse_sincos): Provide the
	PROP_gimple_opt_math property.

From-SVN: r228840
2015-10-15 09:50:07 +00:00
Nathan Sidwell 94829f87ca nvptx.c (nvptx_goacc_validate_dims): New.
* config/nvptx/nvptx.c (nvptx_goacc_validate_dims): New.
	(TARGET_GOACC_VALIDATE_DIMS): Override.
	* target.def (TARGET_GOACC): New target hook prefix.
	(validate_dims): New hook.
	* targhooks.h (default_goacc_validate_dims): New.
	* omp-low.c (oacc_validate_dims): New.
	(execute_oacc_device_lower): New.
	(default_goacc_validate_dims): New.
	(pass_data_oacc_device_lower): New.
	(pass_oacc_device_lower): New pass.
	(make_pass_oacc_device_lower): New.
	* tree-pass.h (make_pass_oacc_device_lower): Declare.
	* passes.def (pass_oacc_device_lower): Add it.
	* doc/tm.texi: Rebuilt.
	* doc/tm.texi.in (TARGET_GOACC_VALIDATE_DIMS): Add hook.
	* doc/invoke.texi (oaccdevlow): Document tree dump flag.

Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>

From-SVN: r228304
2015-09-30 19:16:29 +00:00
Trevor Saunders 355fe0884b switch from gimple to gimple*
This renames the gimple_statement_base struct to gimple removes the
typedef of gimple_statement_base * to gimple, and then adjusts all of
the places that use the type.

gcc/ChangeLog:

2015-09-19  Trevor Saunders  <tbsaunde@tbsaunde.org>

	* coretypes.h (gimple): Change typedef to be a forward
	declaration.
	* gimple.h (gimple_statement_base): rename to gimple.
	* (all functions and types using gimple): Adjust.
	* *.[ch]: Likewise.

gcc/cp/ChangeLog:

2015-09-19  Trevor Saunders  <tbsaunde@tbsaunde.org>

	* cp-gimplify.c (gimplify_must_not_throw_expr): Adjust.

From-SVN: r227941
2015-09-20 00:52:59 +00:00
Bernd Edlinger 0358f01b2e tree-pass.h (get_current_pass_name): Removed.
2015-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * tree-pass.h (get_current_pass_name): Removed.

From-SVN: r226121
2015-07-23 19:01:03 +00:00
Marek Polacek ca87c493f7 re PR tree-optimization/66718 (Non-invariant ADDR_EXPR not vectorized)
PR tree-optimization/66718
	* Makefile.in (OBJS): Add gimple-laddress.o. 
	* passes.def: Schedule pass_laddress.
	* timevar.def (DEFTIMEVAR): Add TV_GIMPLE_LADDRESS.
	* tree-pass.h (make_pass_laddress): Declare.
	* gimple-laddress.c: New file.

	* gcc.dg/vect/vect-126.c: New test.

From-SVN: r225604
2015-07-09 09:01:51 +00:00
Alan Lawrence 4f9a2b4e88 tree-pass.h (make_pass_ch_vect): New.
gcc/:

	* tree-pass.h (make_pass_ch_vect): New.
	* passes.def: Add pass_ch_vect just before pass_if_conversion.

	* tree-ssa-loop-ch.c (ch_base, pass_ch_vect, pass_data_ch_vect,
	pass_ch::process_loop_p, pass_ch_vect::process_loop_p,
	make_pass_ch_vect): New.
	(pass_ch): Extend ch_base.

	(pass_ch::execute): Move all but loop_optimizer_init/finalize to...
	(ch_base::copy_headers): ...here.

gcc/testsuite/:

	* gcc.dg/vect/vect-strided-a-u16-i4.c (main1): Narrow scope of x,y,z,w.
	* gcc.dg/vect/vect-ifcvt-11.c: New testcase.

From-SVN: r225311
2015-07-02 11:47:31 +00:00
Jakub Jelinek 8c8b9f3265 re PR middle-end/66429 (ICE in expand_GOMP_SIMD_LAST_LANE)
PR middle-end/66429
	* omp-low.c (expand_omp_taskreg): Use child_cfun instead of
	DECL_STRUCT_FUNCTION (child_fn).  Or in has_simduid_loops
	and has_force_vectorize_loops flags from cfun into
	child_cfun.
	(expand_omp_simd): For broken loop, set cfun->has_simduid_loops
	if simduid is non-NULL.
	* tree-pass.h (make_pass_simduid_cleanup): New prototype.
	* passes.def (pass_simduid_cleanup): Add new pass after loop
	passes.
	* tree-vectorizer.c (adjust_simduid_builtins): Remove one unnecessary
	indirection from htab argument's type.
	(shrink_simd_arrays): New function.
	(vectorize_loops): Use it.  Adjust adjust_simduid_builtins caller.
	Don't call adjust_simduid_builtins if there are no loops.
	(pass_data_simduid_cleanup, pass_simduid_cleanup): New variables.
	(pass_simduid_cleanup::execute): New method.
	(make_pass_simduid_cleanup): New function.

	* c-c++-common/gomp/pr66429.c: New test.

From-SVN: r224568
2015-06-17 19:59:25 +02:00
Tom de Vries f8e89441bc Postpone expanding va_arg until pass_stdarg
2015-04-17  Tom de Vries  <tom@codesourcery.com>
	    Michael Matz  <matz@suse.de>

	* gimple-iterator.c (update_modified_stmts): Remove static.
	* gimple-iterator.h (update_modified_stmts): Declare.
	* gimplify.c (gimplify_modify_expr): Handle IFN_VA_ARG.
	(gimplify_va_arg_internal): New function.
	(gimplify_va_arg_expr): Use IFN_VA_ARG.
	* gimplify.h (gimplify_va_arg_internal): Declare.
	* internal-fn.c (expand_VA_ARG): New unreachable function.
	* internal-fn.def (VA_ARG): New DEF_INTERNAL_FN.
	* tree-stdarg.c (gimple_call_ifn_va_arg_p, expand_ifn_va_arg_1)
	(expand_ifn_va_arg): New function.
	(pass_data_stdarg): Add PROP_gimple_lva to properties_provided field.
	(pass_stdarg::execute): Call expand_ifn_va_arg.
	(pass_data_lower_vaarg): New pass_data.
	(pass_lower_vaarg): New gimple_opt_pass.
	(pass_lower_vaarg::gate, pass_lower_vaarg::execute)
	(make_pass_lower_vaarg): New function.
	* cfgexpand.c (pass_data_expand): Add PROP_gimple_lva to
	properties_required field.
	* passes.def (all_passes): Add pass_lower_vaarg.
	* tree-pass.h (PROP_gimple_lva): Add define.
	(make_pass_lower_vaarg): Declare.

	* gcc.dg/tree-ssa/stdarg-2.c: Change f15 scan-tree-dump for target
	x86_64-*-*.

Co-Authored-By: Michael Matz <matz@suse.de>

From-SVN: r222173
2015-04-17 09:26:59 +00:00
Jan Hubicka 38147a2a4e re PR ipa/65076 (16% tramp3d-v4.cpp compile time regression)
PR ipa/65076
	* passes.def: Add pass_nothrow.
	* ipa-pure-const.c: (pass_data_nothrow): New.
	(pass_nothrow): New.
	(pass_nothrow::execute): New.
	(make_pass_nothrow): New.
	* tree-pass.h (make_pass_nothrow): Declare.

From-SVN: r221719
2015-03-27 04:02:28 +00:00
Ilya Enkovich c11d86b47f ipa-chkp.c (chkp_produce_thunks): Add early param to split thunks production into two passes.
gcc/

	* ipa-chkp.c (chkp_produce_thunks): Add early param
	to split thunks production into two passes.  Keep
	'always_inline' function bodies after the first pass.
	(pass_data_ipa_chkp_early_produce_thunks): New.
	(pass_ipa_chkp_early_produce_thunks): New.
	(pass_ipa_chkp_produce_thunks::execute): Adjust to new
	chkp_produce_thunks signature.
	(make_pass_ipa_chkp_early_produce_thunks): New.
	* passes.def (pass_ipa_chkp_early_produce_thunks): New.
	(pass_ipa_chkp_produce_thunks): Move after local optimizations.
	* tree-pass.h (make_pass_ipa_chkp_early_produce_thunks): New.

gcc/testsuite/

	* gcc.target/i386/chkp-always_inline.c: New.

From-SVN: r219834
2015-01-19 10:26:52 +00:00
Ilya Verbin 837bac8cb6 cgraphunit.c (ipa_passes): Remove argument from ipa_write_summaries.
gcc/
	* cgraphunit.c (ipa_passes): Remove argument from ipa_write_summaries.
	* lto-cgraph.c (select_what_to_stream): Remove argument, use
	lto_stream_offload_p instead.
	* lto-streamer.h (select_what_to_stream): Remove argument.
	* passes.c (ipa_write_summaries): Likewise.
	* tree-pass.h (ipa_write_summaries): Likewise.
gcc/lto/
	* lto-partition.c (lto_promote_cross_file_statics): Remove argument
	from select_what_to_stream.

From-SVN: r219605
2015-01-14 15:15:21 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Bin Cheng b16abbcb85 timevar.def (TV_SCHED_FUSION): New time var.
* timevar.def (TV_SCHED_FUSION): New time var.
	* passes.def (pass_sched_fusion): New pass.
	* config/arm/arm.c (TARGET_SCHED_FUSION_PRIORITY): New.
	(extract_base_offset_in_addr, fusion_load_store): New.
	(arm_sched_fusion_priority): New.
	(arm_option_override): Disable scheduling fusion by default
	on non-armv7 processors or ldrd/strd isn't preferred.
	* sched-int.h (struct _haifa_insn_data): New field.
	(INSN_FUSION_PRIORITY, FUSION_MAX_PRIORITY, sched_fusion): New.
	* sched-rgn.c (rest_of_handle_sched_fusion): New.
	(pass_data_sched_fusion, pass_sched_fusion): New.
	(make_pass_sched_fusion): New.
	* haifa-sched.c (sched_fusion): New.
	(insn_cost): Handle sched_fusion.
	(priority): Handle sched_fusion by calling target hook.
	(enum rfs_decision): New enum value.
	(rfs_str): New element for RFS_FUSION.
	(rank_for_schedule): Support sched_fusion.
	(schedule_insn, max_issue, prune_ready_list): Handle sched_fusion.
	(schedule_block, fix_tick_ready): Handle sched_fusion.
	* common.opt (flag_schedule_fusion): New.
	* tree-pass.h (make_pass_sched_fusion): New.
	* target.def (fusion_priority): New.
	* doc/tm.texi.in (TARGET_SCHED_FUSION_PRIORITY): New.
	* doc/tm.texi: Regenerated.
	* doc/invoke.texi (-fschedule-fusion): New.

	testsuite:
	* gcc.target/arm/ldrd-strd-pair-1.c: New test.
	* gcc.target/arm/vfp-1.c: Improve scanning string.

From-SVN: r217533
2014-11-14 02:32:38 +00:00
Ilya Verbin 1f6be68256 [PATCH 2/7] OpenMP 4.0 offloading infrastructure: LTO streaming.
gcc/
	* cgraph.c: Include context.h.
	(cgraph_node::create): Set node->offloadable and g->have_offload if
	decl have "omp declare target" attribute.
	* cgraph.h (symtab_node): Add need_lto_streaming and offloadable flags.
	* cgraphunit.c: Include lto-section-names.h.
	(ipa_passes): Call ipa_write_summaries if there is something to write to
	OFFLOAD_SECTION_NAME_PREFIX sections.
	(symbol_table::compile): Set flag_generate_lto if there is something to
	offload.
	Replace flag_lto with flag_generate_lto before lto_streamer_hooks_init.
	* context.c (gcc::context::context): Initialize have_offload with false.
	* context.h (class context): Add have_offload flag.
	* ipa-inline-analysis.c (inline_generate_summary): Do not exit under
	flag_generate_lto.
	(inline_free_summary): Always remove hooks.
	* lto-cgraph.c (referenced_from_other_partition_p): Ignore references
	from non-offloadable nodes while streaming a node into offload section.
	(reachable_from_other_partition_p): Likewise.
	(select_what_to_stream): New function.
	(compute_ltrans_boundary): Do not call
	lto_set_symtab_encoder_in_partition if the node should not be streamed.
	* lto-section-names.h (OFFLOAD_SECTION_NAME_PREFIX): Define.
	(section_name_prefix): Declare.
	* lto-streamer.c (section_name_prefix): New variable.
	(lto_get_section_name): Use section_name_prefix instead of
	LTO_SECTION_NAME_PREFIX.
	* lto-streamer.h (select_what_to_stream): Declare.
	* omp-low.c: Include context.h.
	(is_targetreg_ctx): New function.
	(scan_sharing_clauses): Use offloadable flag, instead of an attribute.
	(create_omp_child_function, check_omp_nesting_restrictions): Use new
	is_targetreg_ctx function.  Replace usage of "omp declare target"
	attribute with a cgraph_node flag offloadable.
	(expand_omp_target): Set mark_force_output for offloadable functions.
	(lower_omp_critical): Set offloadable flag for omp critical symbol.
	* passes.c (ipa_write_summaries): New argument offload_lto_mode.  Call
	select_what_to_stream.  Do not call lto_set_symtab_encoder_in_partition
	if the node should not be streamed out.
	* tree-pass.h (ipa_write_summaries): New bool argument.
	* varpool.c: Include context.h.
	(varpool_node::get_create): Set node->offloadable and g->have_offload if
	decl have "omp declare target" attribute.

gcc/lto/
	* lto-object.c (lto_obj_add_section): Use section_name_prefix instead of
	LTO_SECTION_NAME_PREFIX.
	* lto-partition.c (lto_promote_cross_file_statics): Call
	select_what_to_stream.
	* lto.c (lto_section_with_id): Use section_name_prefix instead of
	LTO_SECTION_NAME_PREFIX.
	(read_cgraph_and_symbols): Read OFFLOAD_SECTION_NAME_PREFIX sections, if
	being built as an offload compiler.

Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>

From-SVN: r217486
2014-11-13 13:37:38 +00:00
Tom de Vries 187518942c Run pass_expand_omp_ssa after pass_paralellize_loops
2014-11-13  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (pass_data_expand_omp): Set properties_provided to
	PROP_gimple_eomp.
	(pass_expand_omp::gate): Remove function.  Move gate expression to ...
	(pass_expand_omp::execute): ... here, as new variable gate.  Add early
	exit if gate is false.
	(pass_data pass_data_expand_omp_ssa): New pass_data.
	(class pass_expand_omp_ssa): New pass.
	(make_pass_expand_omp_ssa): New function.
	* passes.def (pass_parallelize_loops): Use PUSH_INSERT_PASSES_WITHIN
	instead of NEXT_PASS.
	(pass_expand_omp_ssa): Add after pass_parallelize_loops.
	* tree-parloops.c (gen_parallel_loop): Remove call to omp_expand_local.
	(pass_parallelize_loops::execute): Don't do cleanups TODO_cleanup_cfg
	and TODO_rebuild_alias yet.  Add TODO_update_ssa.  Set
	cfun->omp_expand_needed.
	* tree-pass.h: Add define PROP_gimple_eomp.
	(make_pass_expand_omp_ssa): Declare.

From-SVN: r217474
2014-11-13 10:51:58 +00:00
Ilya Enkovich d5e254e19c ipa-chkp.c: New.
gcc/

2014-11-05  Ilya Enkovich  <ilya.enkovich@intel.com>

	* ipa-chkp.c: New.
	* ipa-chkp.h: New.
	* tree-chkp.c: New.
	* tree-chkp.h: New.
	* tree-chkp-opt.c: New.
	* rtl-chkp.c: New.
	* rtl-chkp.h: New.
	* Makefile.in (OBJS): Add ipa-chkp.o, rtl-chkp.o, tree-chkp.o
	tree-chkp-opt.o.
	(GTFILES): Add tree-chkp.c.
	* mode-classes.def (MODE_POINTER_BOUNDS): New.
	* tree.def (POINTER_BOUNDS_TYPE): New.
	* genmodes.c (complete_mode): Support MODE_POINTER_BOUNDS.
	(POINTER_BOUNDS_MODE): New.
	(make_pointer_bounds_mode): New.
	* machmode.h (POINTER_BOUNDS_MODE_P): New.
	* stor-layout.c (int_mode_for_mode): Support MODE_POINTER_BOUNDS.
	(layout_type): Support POINTER_BOUNDS_TYPE.
	* tree-pretty-print.c (dump_generic_node): Support POINTER_BOUNDS_TYPE.
	* tree-core.h (tree_index): Add TI_POINTER_BOUNDS_TYPE.
	* tree.c (build_int_cst_wide): Support POINTER_BOUNDS_TYPE.
	(type_contains_placeholder_1): Likewise.
	(build_common_tree_nodes): Initialize
	pointer_bounds_type_node.
	* tree.h (POINTER_BOUNDS_TYPE_P): New.
	(pointer_bounds_type_node): New.
	(POINTER_BOUNDS_P): New.
	(BOUNDED_TYPE_P): New.
	(BOUNDED_P): New.
	(CALL_WITH_BOUNDS_P): New.
	* gimple.h (gf_mask): Add GF_CALL_WITH_BOUNDS.
	(gimple_call_with_bounds_p): New.
	(gimple_call_set_with_bounds): New.
	(gimple_return_retbnd): New.
	(gimple_return_set_retbnd): New
	* gimple.c (gimple_build_return): Increase number of ops
	for return statement.
	(gimple_build_call_from_tree): Propagate CALL_WITH_BOUNDS_P
	flag.
	* gimple-pretty-print.c (dump_gimple_return): Print second op.
	* rtl.h (CALL_EXPR_WITH_BOUNDS_P): New.
	* gimplify.c (gimplify_init_constructor): Avoid infinite
	loop during gimplification of bounds initializer.
	* calls.c: Include tree-chkp.h, rtl-chkp.h, bitmap.h.
	(special_function_p): Use original decl name when analyzing
	instrumentation clone.
	(arg_data): Add fields special_slot, pointer_arg and
	pointer_offset.
	(store_bounds): New.
	(emit_call_1): Propagate instrumentation flag for CALL.
	(initialize_argument_information): Compute pointer_arg,
	pointer_offset and special_slot for pointer bounds arguments.
	(finalize_must_preallocate): Preallocate when storing bounds
	in bounds table.
	(compute_argument_addresses): Skip pointer bounds.
	(expand_call): Store bounds into tables separately.  Return
	result joined with resulting bounds.
	* cfgexpand.c: Include tree-chkp.h, rtl-chkp.h.
	(expand_call_stmt): Propagate bounds flag for CALL_EXPR.
	(expand_return): Add returned bounds arg.  Handle returned bounds.
	(expand_gimple_stmt_1): Adjust to new expand_return signature.
	(gimple_expand_cfg): Reset rtx bounds map.
	* expr.c: Include tree-chkp.h, rtl-chkp.h.
	(expand_assignment): Handle returned bounds.
	(store_expr_with_bounds): New.  Replaces store_expr with new bounds
	target argument.  Handle bounds returned by calls.
	(store_expr): Now wraps store_expr_with_bounds.
	* expr.h (store_expr_with_bounds): New.
	* function.c: Include tree-chkp.h, rtl-chkp.h.
	(bounds_parm_data): New.
	(use_register_for_decl): Do not registerize decls used for bounds
	stores and loads.
	(assign_parms_augmented_arg_list): Add bounds of the result
	structure pointer as the second argument.
	(assign_parm_find_entry_rtl): Mark bounds are never passed on
	the stack.
	(assign_parm_is_stack_parm): Likewise.
	(assign_parm_load_bounds): New.
	(assign_bounds): New.
	(assign_parms): Load bounds and determine a location for
	returned bounds.
	(diddle_return_value_1): New.
	(diddle_return_value): Handle returned bounds.
	* function.h (rtl_data): Add field for returned bounds.
	* varasm.c: Include tree-chkp.h.
	(output_constant): Support POINTER_BOUNDS_TYPE.
	(output_constant_pool_2): Support MODE_POINTER_BOUNDS.
	(ultimate_transparent_alias_target): Move up.
	(make_decl_rtl): For instrumented function use
	name of the original decl.
	(assemble_start_function): Mark function as global
	in case it is instrumentation clone of the global
	function.
	(do_assemble_alias): Follow transparent alias chain
	for identifier.  Check if original alias is public.
	(maybe_assemble_visibility): Use visibility of the
	original function for instrumented version.
	(default_unique_section): Likewise.
	* emit-rtl.c (immed_double_const): Support MODE_POINTER_BOUNDS.
	(init_emit_once): Build pointer bounds zero constants.
	* explow.c (trunc_int_for_mode): Support MODE_POINTER_BOUNDS.
	* target.def (builtin_chkp_function): New.
	(chkp_bound_type): New.
	(chkp_bound_mode): New.
	(chkp_make_bounds_constant): New.
	(chkp_initialize_bounds): New.
	(load_bounds_for_arg): New.
	(store_bounds_for_arg): New.
	(load_returned_bounds): New.
	(store_returned_bounds): New.
	(chkp_function_value_bounds): New.
	(setup_incoming_vararg_bounds): New.
	(function_arg): Update hook description with new possible return
	value CONST_INT.
	* targhooks.h (default_load_bounds_for_arg): New.
	(default_store_bounds_for_arg): New.
	(default_load_returned_bounds): New.
	(default_store_returned_bounds): New.
	(default_chkp_bound_type): New.
	(default_chkp_bound_mode): New.
	(default_builtin_chkp_function): New.
	(default_chkp_function_value_bounds): New.
	(default_chkp_make_bounds_constant): New.
	(default_chkp_initialize_bounds): New.
	(default_setup_incoming_vararg_bounds): New.
	* targhooks.c (default_load_bounds_for_arg): New.
	(default_store_bounds_for_arg): New.
	(default_load_returned_bounds): New.
	(default_store_returned_bounds): New.
	(default_chkp_bound_type): New.
	(default_chkp_bound_mode); New.
	(default_builtin_chkp_function): New.
	(default_chkp_function_value_bounds): New.
	(default_chkp_make_bounds_constant): New.
	(default_chkp_initialize_bounds): New.
	(default_setup_incoming_vararg_bounds): New.
	* builtin-types.def (BT_BND): New.
	(BT_FN_PTR_CONST_PTR): New.
	(BT_FN_CONST_PTR_CONST_PTR): New.
	(BT_FN_BND_CONST_PTR): New.
	(BT_FN_CONST_PTR_BND): New.
	(BT_FN_PTR_CONST_PTR_SIZE): New.
	(BT_FN_PTR_CONST_PTR_CONST_PTR): New.
	(BT_FN_VOID_PTRPTR_CONST_PTR): New.
	(BT_FN_VOID_CONST_PTR_SIZE): New.
	(BT_FN_VOID_PTR_BND): New.
	(BT_FN_CONST_PTR_CONST_PTR_CONST_PTR): New.
	(BT_FN_BND_CONST_PTR_SIZE): New.
	(BT_FN_PTR_CONST_PTR_CONST_PTR_SIZE): New.
	(BT_FN_VOID_CONST_PTR_BND_CONST_PTR): New.
	* chkp-builtins.def: New.
	* builtins.def: include chkp-builtins.def.
	(DEF_CHKP_BUILTIN): New.
	* builtins.c: Include tree-chkp.h and rtl-chkp.h.
	(expand_builtin): Support BUILT_IN_CHKP_INIT_PTR_BOUNDS,
	BUILT_IN_CHKP_NULL_PTR_BOUNDS, BUILT_IN_CHKP_COPY_PTR_BOUNDS,
	BUILT_IN_CHKP_CHECK_PTR_LBOUNDS, BUILT_IN_CHKP_CHECK_PTR_UBOUNDS,
	BUILT_IN_CHKP_CHECK_PTR_BOUNDS, BUILT_IN_CHKP_SET_PTR_BOUNDS,
	BUILT_IN_CHKP_NARROW_PTR_BOUNDS, BUILT_IN_CHKP_STORE_PTR_BOUNDS,
	BUILT_IN_CHKP_GET_PTR_LBOUND, BUILT_IN_CHKP_GET_PTR_UBOUND,
	BUILT_IN_CHKP_BNDMK, BUILT_IN_CHKP_BNDSTX, BUILT_IN_CHKP_BNDCL,
	BUILT_IN_CHKP_BNDCU, BUILT_IN_CHKP_BNDLDX, BUILT_IN_CHKP_BNDRET,
	BUILT_IN_CHKP_INTERSECT, BUILT_IN_CHKP_NARROW,
	BUILT_IN_CHKP_EXTRACT_LOWER, BUILT_IN_CHKP_EXTRACT_UPPER.
	(std_expand_builtin_va_start): Init bounds for va_list.
	* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add
	__CHKP__ macro when Pointer Bounds Checker is on.
	* params.def (PARAM_CHKP_MAX_CTOR_SIZE): New.
	* passes.def (pass_ipa_chkp_versioning): New.
	(pass_early_local_passes): Renamed to pass_build_ssa_passes.
	(pass_fixup_cfg): Moved to pass_chkp_instrumentation_passes.
	(pass_chkp_instrumentation_passes): New.
	(pass_ipa_chkp_produce_thunks): New.
	(pass_local_optimization_passes): New.
	(pass_chkp_opt): New.
	* tree-pass.h (make_pass_ipa_chkp_versioning): New.
	(make_pass_ipa_chkp_produce_thunks): New.
	(make_pass_chkp): New.
	(make_pass_chkp_opt): New.
	(make_pass_early_local_passes): Renamed to ...
	(make_pass_build_ssa_passes): This.
	(make_pass_chkp_instrumentation_passes): New.
	(make_pass_local_optimization_passes): New.
	* passes.c (pass_manager::execute_early_local_passes): Execute
	early passes in three steps.
	(execute_all_early_local_passes): Renamed to ...
	(execute_build_ssa_passes): This.
	(pass_data_early_local_passes): Renamed to ...
	(pass_data_build_ssa_passes): This.
	(pass_early_local_passes): Renamed to ...
	(pass_build_ssa_passes): This.
	(pass_data_chkp_instrumentation_passes): New.
	(pass_chkp_instrumentation_passes): New.
	(pass_data_local_optimization_passes): New.
	(pass_local_optimization_passes): New.
	(make_pass_early_local_passes): Renamed to ...
	(make_pass_build_ssa_passes): This.
	(make_pass_chkp_instrumentation_passes): New.
	(make_pass_local_optimization_passes): New.
	* c-family/c.opt (fcheck-pointer-bounds): New.
	(fchkp-check-incomplete-type): New.
	(fchkp-zero-input-bounds-for-main): New.
	(fchkp-first-field-has-own-bounds): New.
	(fchkp-narrow-bounds): New.
	(fchkp-narrow-to-innermost-array): New.
	(fchkp-optimize): New.
	(fchkp-use-fast-string-functions): New.
	(fchkp-use-nochk-string-functions): New.
	(fchkp-use-static-bounds): New.
	(fchkp-use-static-const-bounds): New.
	(fchkp-treat-zero-dynamic-size-as-infinite): New.
	(fchkp-check-read): New.
	(fchkp-check-write): New.
	(fchkp-store-bounds): New.
	(fchkp-instrument-calls): New.
	(fchkp-instrument-marked-only): New.
	(Wchkp): New.
	* c-family/c-common.c (handle_bnd_variable_size_attribute): New.
	(handle_bnd_legacy): New.
	(handle_bnd_instrument): New.
	(c_common_attribute_table): Add bnd_variable_size, bnd_legacy
	and bnd_instrument.  Fix documentation.
	(c_common_format_attribute_table): Likewsie.
	* toplev.c: include tree-chkp.h.
	(process_options): Check Pointer Bounds Checker is supported.
	(compile_file): Add chkp_finish_file call.
	* ipa-cp.c (initialize_node_lattices): Use cgraph_local_p
	to handle instrumentation clones properly.
	(propagate_constants_accross_call): Do not propagate
	through instrumentation thunks.
	* ipa-pure-const.c (propagate_pure_const): Support
	IPA_REF_CHKP.
	* ipa-inline.c (early_inliner): Check edge has summary allocated.
	* ipa-split.c: Include tree-chkp.h.
	(find_retbnd): New.
	(split_part_set_ssa_name_p): New.
	(consider_split): Do not split retbnd and retval
	producers.
	(insert_bndret_call_after): new.
	(split_function): Propagate Pointer Bounds Checker
	instrumentation marks and handle returned bounds.
	* tree-ssa-sccvn.h (vn_reference_op_struct): Transform opcode
	into bit field and add with_bounds field.
	* tree-ssa-sccvn.c (copy_reference_ops_from_call): Set
	with_bounds field for instrumented calls.
	* tree-ssa-pre.c (create_component_ref_by_pieces_1): Restore
	CALL_WITH_BOUNDS_P flag for calls.
	* tree-ssa-ccp.c: Include tree-chkp.h.
	(insert_clobber_before_stack_restore): Handle
	BUILT_IN_CHKP_BNDRET calls.
	* tree-ssa-dce.c: Include tree-chkp.h.
	(propagate_necessity): For free call fed by alloc check
	bounds are also provided by the same alloc.
	(eliminate_unnecessary_stmts): Handle BUILT_IN_CHKP_BNDRET
	used by free calls.
	* tree-inline.c: Include tree-chkp.h.
	(declare_return_variable): Add arg holding
	returned bounds slot.  Create and initialize returned bounds var.
	(remap_gimple_stmt): Handle returned bounds.
	Return sequence of statements instead of a single statement.
	(insert_init_stmt): Add declaration.
	(remap_gimple_seq): Adjust to new remap_gimple_stmt signature.
	(copy_bb): Adjust to changed return type of remap_gimple_stmt.
	Properly handle bounds in va_arg_pack and va_arg_pack_len.
	(expand_call_inline): Handle returned bounds.  Add bounds copy
	for generated mem to mem assignments.
	* tree-inline.h (copy_body_data): Add fields retbnd and
	assign_stmts.
	* value-prof.c: Include tree-chkp.h.
	(gimple_ic): Support returned bounds.
	* ipa.c (cgraph_build_static_cdtor_1): Support contructors
	with "chkp ctor" and "bnd_legacy" attributes.
	(symtab_remove_unreachable_nodes): Keep initial values for
	pointer bounds to be used for checks eliminations.
	(process_references): Handle IPA_REF_CHKP.
	(walk_polymorphic_call_targets): Likewise.
	* ipa-visibility.c (cgraph_externally_visible_p): Mark
	instrumented 'main' as externally visible.
	(function_and_variable_visibility): Filter instrumentation
	thunks.
	* cgraph.h (cgraph_thunk_info): Add add_pointer_bounds_args
	field.
	(cgraph_node): Add instrumented_version, orig_decl and
	instrumentation_clone fields.
	(symtab_node::get_alias_target): Allow IPA_REF_CHKP reference.
	(varpool_node): Add need_bounds_init field.
	(cgraph_local_p): New.
	* cgraph.c: Include tree-chkp.h.
	(cgraph_node::remove): Fix instrumented_version
	of the referenced node if any.
	(cgraph_node::dump): Dump instrumentation_clone and
	instrumented_version fields.
	(cgraph_node::verify_node): Check correctness of IPA_REF_CHKP
	references and instrumentation thunks.
	(cgraph_can_remove_if_no_direct_calls_and_refs_p): Keep
	all not instrumented instrumentation clones alive.
	(cgraph_redirect_edge_call_stmt_to_callee): Support
	returned bounds.
	* cgraphbuild.c (rebuild_cgraph_edges): Rebuild IPA_REF_CHKP
	reference.
	(cgraph_rebuild_references): Likewise.
	* cgraphunit.c: Include tree-chkp.h.
	(assemble_thunks_and_aliases): Skip thunks calling instrumneted
	function version.
	(varpool_finalize_decl): Register statically initialized decls
	in Pointer Bounds Checker.
	(walk_polymorphic_call_targets): Do not mark generated call to
	__builtin_unreachable as with_bounds.
	(output_weakrefs): If there are both instrumented and original
	versions, output only one of them.
	(cgraph_node::expand_thunk): Set with_bounds flag
	for created call statement.
	* ipa-ref.h (ipa_ref_use): Add IPA_REF_CHKP.
	(ipa_ref): increase size of use field.
	* symtab.c (ipa_ref_use_name): Add element for IPA_REF_CHKP.
	* varpool.c (dump_varpool_node): Dump need_bounds_init field.
	(ctor_for_folding): Do not fold constant bounds vars.
	* lto-streamer.h (LTO_minor_version): Change minor version from
	0 to 1.
	* lto-cgraph.c (compute_ltrans_boundary): Keep initial values for
	pointer bounds.
	(lto_output_node): Output instrumentation_clone,
	thunk.add_pointer_bounds_args and orig_decl field.
	(lto_output_ref): Adjust to new ipa_ref::use field size.
	(input_overwrite_node): Read instrumentation_clone field.
	(input_node): Read thunk.add_pointer_bounds_args and orig_decl
	fields.
	(input_ref): Adjust to new ipa_ref::use field size.
	(input_cgraph_1): Compute instrumented_version fields and restore
	IDENTIFIER_TRANSPARENT_ALIAS chains.
	(lto_output_varpool_node): Output
	need_bounds_init value.
	(input_varpool_node): Read need_bounds_init value.
	* lto-partition.c (add_symbol_to_partition_1): Keep original
	and instrumented versions together.
	(privatize_symbol_name): Restore transparent alias chain if required.
	(add_references_to_partition): Add references to pointer bounds vars.
	* dbxout.c (dbxout_type): Ignore POINTER_BOUNDS_TYPE.
	* dwarf2out.c (gen_subprogram_die): Ignore bound args.
	(gen_type_die_with_usage): Skip pointer bounds.
	(dwarf2out_global_decl): Likewise.
	(is_base_type): Support POINTER_BOUNDS_TYPE.
	(gen_formal_types_die): Skip pointer bounds.
	(gen_decl_die): Likewise.
	* var-tracking.c (vt_add_function_parameters): Skip
	bounds parameters.
	* ipa-icf.c (sem_function::merge): Do not merge when instrumentation
	thunk still exists.
	(sem_variable::merge): Reset need_bounds_init flag.
	* doc/extend.texi: Document Pointer Bounds Checker built-in functions
	and attributes.
	* doc/tm.texi.in (TARGET_LOAD_BOUNDS_FOR_ARG): New.
	(TARGET_STORE_BOUNDS_FOR_ARG): New.
	(TARGET_LOAD_RETURNED_BOUNDS): New.
	(TARGET_STORE_RETURNED_BOUNDS): New.
	(TARGET_CHKP_FUNCTION_VALUE_BOUNDS): New.
	(TARGET_SETUP_INCOMING_VARARG_BOUNDS): New.
	(TARGET_BUILTIN_CHKP_FUNCTION): New.
	(TARGET_CHKP_BOUND_TYPE): New.
	(TARGET_CHKP_BOUND_MODE): New.
	(TARGET_CHKP_MAKE_BOUNDS_CONSTANT): New.
	(TARGET_CHKP_INITIALIZE_BOUNDS): New.
	* doc/tm.texi: Regenerated.
	* doc/rtl.texi (MODE_POINTER_BOUNDS): New.
	(BND32mode): New.
	(BND64mode): New.
	* doc/invoke.texi (-mmpx): New.
	(-mno-mpx): New.
	(chkp-max-ctor-size): New.
	* config/i386/constraints.md (w): New.
	(Ti): New.
	(Tb): New.
	* config/i386/i386-c.c (ix86_target_macros_internal): Add __MPX__.
	* config/i386/i386-modes.def (BND32): New.
	(BND64): New.
	* config/i386/i386-protos.h (ix86_bnd_prefixed_insn_p): New.
	* config/i386/i386.c: Include tree-chkp.h, rtl-chkp.h, tree-iterator.h.
	(regclass_map): Add bound registers.
	(dbx_register_map): Likewise.
	(dbx64_register_map): Likewise.
	(svr4_dbx_register_map): Likewise.
	(isa_opts): Add -mmpx.
	(PTA_MPX): New.
	(ix86_option_override_internal): Support MPX ISA.
	(ix86_conditional_register_usage): Support bound registers.
	(ix86_code_end): Add MPX bnd prefix.
	(output_set_got): Likewise.
	(print_reg): Avoid prefixes for bound registers.
	(ix86_print_operand): Add '!' (MPX bnd) print prefix support.
	(ix86_print_operand_punct_valid_p): Likewise.
	(ix86_print_operand_address): Support UNSPEC_BNDMK_ADDR and
	UNSPEC_BNDLDX_ADDR.
	(ix86_output_call_insn): Add MPX bnd prefix to branch instructions.
	(ix86_class_likely_spilled_p): Add bound regs support.
	(ix86_hard_regno_mode_ok): Likewise.
	(x86_order_regs_for_local_alloc): Likewise.
	(ix86_bnd_prefixed_insn_p): New.
	(ix86_builtins): Add
	IX86_BUILTIN_BNDMK, IX86_BUILTIN_BNDSTX,
	IX86_BUILTIN_BNDLDX, IX86_BUILTIN_BNDCL,
	IX86_BUILTIN_BNDCU, IX86_BUILTIN_BNDRET,
	IX86_BUILTIN_BNDNARROW, IX86_BUILTIN_BNDINT,
	IX86_BUILTIN_SIZEOF, IX86_BUILTIN_BNDLOWER,
	IX86_BUILTIN_BNDUPPER.
	(builtin_isa): Add leaf_p and nothrow_p fields.
	(def_builtin): Initialize leaf_p and nothrow_p.
	(ix86_add_new_builtins): Handle leaf_p and nothrow_p
	flags.
	(bdesc_mpx): New.
	(bdesc_mpx_const): New.
	(ix86_init_mpx_builtins): New.
	(ix86_init_builtins): Call ix86_init_mpx_builtins.
	(ix86_emit_cmove): New.
	(ix86_emit_move_max): New.
	(ix86_expand_builtin): Expand IX86_BUILTIN_BNDMK,
	IX86_BUILTIN_BNDSTX, IX86_BUILTIN_BNDLDX,
	IX86_BUILTIN_BNDCL, IX86_BUILTIN_BNDCU,
	IX86_BUILTIN_BNDRET, IX86_BUILTIN_BNDNARROW,
	IX86_BUILTIN_BNDINT, IX86_BUILTIN_SIZEOF,
	IX86_BUILTIN_BNDLOWER, IX86_BUILTIN_BNDUPPER.
	(ix86_function_value_bounds): New.
	(ix86_builtin_mpx_function): New.
	(ix86_get_arg_address_for_bt): New.
	(ix86_load_bounds): New.
	(ix86_store_bounds): New.
	(ix86_load_returned_bounds): New.
	(ix86_store_returned_bounds): New.
	(ix86_mpx_bound_mode): New.
	(ix86_make_bounds_constant): New.
	(ix86_initialize_bounds):
	(TARGET_LOAD_BOUNDS_FOR_ARG): New.
	(TARGET_STORE_BOUNDS_FOR_ARG): New.
	(TARGET_LOAD_RETURNED_BOUNDS): New.
	(TARGET_STORE_RETURNED_BOUNDS): New.
	(TARGET_CHKP_BOUND_MODE): New.
	(TARGET_BUILTIN_CHKP_FUNCTION): New.
	(TARGET_CHKP_FUNCTION_VALUE_BOUNDS): New.
	(TARGET_CHKP_MAKE_BOUNDS_CONSTANT): New.
	(TARGET_CHKP_INITIALIZE_BOUNDS): New.
	(ix86_option_override_internal): Do not
	support x32 with MPX.
	(init_cumulative_args): Init stdarg, bnd_regno, bnds_in_bt
	and force_bnd_pass.
	(function_arg_advance_32): Return number of used integer
	registers.
	(function_arg_advance_64): Likewise.
	(function_arg_advance_ms_64): Likewise.
	(ix86_function_arg_advance): Handle pointer bounds.
	(ix86_function_arg): Likewise.
	(ix86_function_value_regno_p): Mark fisrt bounds registers as
	possible function value.
	(ix86_function_value_1): Handle pointer bounds type/mode
	(ix86_return_in_memory): Likewise.
	(ix86_print_operand): Analyse insn to decide abounf "bnd" prefix.
	(ix86_expand_call): Generate returned bounds.
	(ix86_setup_incoming_vararg_bounds): New.
	(ix86_va_start): Initialize bounds for pointers in va_list.
	(TARGET_SETUP_INCOMING_VARARG_BOUNDS): New.
	* config/i386/i386.h (TARGET_MPX): New.
	(TARGET_MPX_P): New.
	(FIRST_PSEUDO_REGISTER): Fix to new value.
	(FIXED_REGISTERS): Add bound registers.
	(CALL_USED_REGISTERS): Likewise.
	(REG_ALLOC_ORDER): Likewise.
	(HARD_REGNO_NREGS): Likewise.
	(VALID_BND_REG_MODE): New.
	(FIRST_BND_REG): New.
	(LAST_BND_REG): New.
	(reg_class): Add BND_REGS.
	(REG_CLASS_NAMES): Likewise.
	(REG_CLASS_CONTENTS): Likewise.
	(BND_REGNO_P): New.
	(ANY_BND_REG_P): New.
	(BNDmode): New.
	(HI_REGISTER_NAMES): Add bound registers.
	(ix86_args): Add bnd_regno, bnds_in_bt,	force_bnd_pass and
	stdarg fields.
	* config/i386/i386.md (UNSPEC_BNDMK): New.
	(UNSPEC_BNDMK_ADDR): New.
	(UNSPEC_BNDSTX): New.
	(UNSPEC_BNDLDX): New.
	(UNSPEC_BNDLDX_ADDR): New.
	(UNSPEC_BNDCL): New.
	(UNSPEC_BNDCU): New.
	(UNSPEC_BNDCN): New.
	(UNSPEC_MPX_FENCE): New.
	(UNSPEC_SIZEOF): New.
	(BND0_REG): New.
	(BND1_REG): New.
	(type): Add mpxmov, mpxmk, mpxchk, mpxld, mpxst.
	(length_immediate): Support mpxmov, mpxmk, mpxchk, mpxld, mpxst.
	(prefix_rep): Check for bnd prefix.
	(prefix_0f): Support mpxmov, mpxmk, mpxchk, mpxld, mpxst.
	(length_nobnd): New.
	(length): Use length_nobnd when specified.
	(memory): Support mpxmov, mpxmk, mpxchk, mpxld, mpxst.
	(BND): New.
	(bnd_ptr): New.
	(BNDCHECK): New.
	(bndcheck): New.
	(*jcc_1): Add MPX bnd prefix.
	(*jcc_2): Likewise.
	(jump): Likewise.
	(*indirect_jump): Likewise.
	(*tablejump_1): Likewise.
	(simple_return_internal): Likewise.
	(simple_return_internal_long): Likewise.
	(simple_return_pop_internal): Likewise.
	(simple_return_indirect_internal): Likewise.
	(<mode>_mk): New.
	(*<mode>_mk): New.
	(mov<mode>): New.
	(*mov<mode>_internal_mpx): New.
	(<mode>_<bndcheck>): New.
	(*<mode>_<bndcheck>): New.
	(<mode>_ldx): New.
	(*<mode>_ldx): New.
	(<mode>_stx): New.
	(*<mode>_stx): New.
	move_size_reloc_<mode>): New.
	* config/i386/predicates.md (address_mpx_no_base_operand): New.
	(address_mpx_no_index_operand): New.
	(bnd_mem_operator): New.
	(symbol_operand): New.
	(x86_64_immediate_size_operand): New.
	* config/i386/i386.opt (mmpx): New.
	* config/i386/i386-builtin-types.def (BND): New.
	(ULONG): New.
	(BND_FTYPE_PCVOID_ULONG): New.
	(VOID_FTYPE_BND_PCVOID): New.
	(VOID_FTYPE_PCVOID_PCVOID_BND): New.
	(BND_FTYPE_PCVOID_PCVOID): New.
	(BND_FTYPE_PCVOID): New.
	(BND_FTYPE_BND_BND): New.
	(PVOID_FTYPE_PVOID_PVOID_ULONG): New.
	(PVOID_FTYPE_PCVOID_BND_ULONG): New.
	(ULONG_FTYPE_VOID): New.
	(PVOID_FTYPE_BND): New.

gcc/testsuite/

2014-11-05  Ilya Enkovich  <ilya.enkovich@intel.com>

	* gcc.target/i386/chkp-builtins-1.c: New.
	* gcc.target/i386/chkp-builtins-2.c: New.
	* gcc.target/i386/chkp-builtins-3.c: New.
	* gcc.target/i386/chkp-builtins-4.c: New.
	* gcc.target/i386/chkp-remove-bndint-1.c: New.
	* gcc.target/i386/chkp-remove-bndint-2.c: New.
	* gcc.target/i386/chkp-const-check-1.c: New.
	* gcc.target/i386/chkp-const-check-2.c: New.
	* gcc.target/i386/chkp-lifetime-1.c: New.
	* gcc.dg/pr37858.c: Replace early_local_cleanups pass name
	with build_ssa_passes.

From-SVN: r217125
2014-11-05 12:42:03 +00:00
Dehao Chen be3c16c474 Add AutoFDO.
gcc/ChangeLog:

2014-10-21  Dehao Chen  <dehao@google.com>

	* auto-profile.c: New file.
	* auto-profile.h: New file.
	* basic-block.h (maybe_hot_count_p): New export func.
	(add_working_set): New export func.
	* gcov-io.h (GCOV_TAG_AFDO_FILE_NAMES): New tag.
	(GCOV_TAG_AFDO_FUNCTION): Likewise.
	(GCOV_TAG_AFDO_WORKING_SET): Likewise.
	* opts.c (enable_fdo_optimizations): New func.
	(common_handle_option): Handle -fauto-profile flag.
	* ipa-inline.c (want_early_inline_function_p): Iterative-einline.
	(class pass_early_inline): Export early_inliner.
	(early_inliner): Likewise.
	(pass_early_inline::execute): Likewise.
	* ipa-inline.h (early_inliner): Likewise.
	* predict.c (maybe_hot_count_p): New export func.
	(counts_to_freqs): AutoFDO logic.
	(rebuild_frequencies): Likewise.
	* tree-profile.c (pass_ipa_tree_profile::gate): Likewise.
	* profile.c (add_working_set): New func.
	* Makefile.in (auto-profile.o): New object file.
	* passes.def (pass_ipa_auto_profile): New pass.
	* tree-ssa-live.c (remove_unused_scope_block_p): AutoFDO logic.
	* tree-pass.h (make_pass_ipa_auto_profile): New pass.
	* toplev.c (compile_file): AutoFDO logic.
	* doc/invoke.texi (-fauto-profile): New doc.
	* coverage.c (coverage_init): AutoFDO logic.
	* common.opt (-fauto-profile): New flag.
	* timevar.def (TV_IPA_AUTOFDO): New tag.
	* value-prof.c (gimple_alloc_histogram_value): New export func.
	(check_ic_target): Likewise.
	* value-prof.h (gimple_alloc_histogram_value): Likewise.
	(check_ic_target): Likewise.

From-SVN: r216523
2014-10-21 17:59:30 +00:00
Martin Liska b84d4347ac IPA ICF pass, part 3/5
* Makefile.in: New object files included.
	* cgraph.c (cgraph_node::dump): New cgraph_node flag icf_merged
	is printed.
	(verify_edge_corresponds_to_fndecl): More sensitive verification
	of nodes that are merged by IPA ICF.
	* cgraph.h (cgraph_node::num_references): New function.
	* cgraphunit.c (cgraph_node::expand_thunk): White space fixed.
	* common.opt: New options ipa-icf, ipa-icf-functions and
	ipa-icf-variables introduced.
	* doc/invoke.texi: Documentation of new options introduced.
	* ipa-icf-gimple.c: New file.
	* ipa-icf-gimple.h: New file.
	* ipa-icf.c: New file.
	* ipa-icf.h: New file.
	* lto-cgraph.c (lto_output_node): Streaming of icf_merged flag added.
	(input_overwrite_node): Likewise.
	* lto-section-in.c: New icf section added.
	* lto-streamer.h (enum lto_section_type): Likewise.
	* opts.c (common_handle_option): New option added.
	* passes.def: New pass included.
	* timevar.def: Time variable for IPA ICF added.
	* tree-pass.h: New IPA ICF pass entry point added.


Co-Authored-By: Jan Hubicka <hubicka@ucw.cz>

From-SVN: r216305
2014-10-16 10:47:55 +00:00
Jan Hubicka f8934be787 loop-unroll.c: (decide_unrolling_and_peeling): Rename to
* loop-unroll.c: (decide_unrolling_and_peeling): Rename to
	(decide_unrolling): ... this one.
	(peel_loops_completely): Remove.
	(decide_peel_simple): Remove.
	(decide_peel_once_rolling): Remove.
	(decide_peel_completely): Remove.
	(peel_loop_simple): Remove.
	(peel_loop_completely): Remove.
	(unroll_and_peel_loops): Rename to ...
	(unroll_loops): ... this one; handle only unrolling.
	* cfgloop.h (lpt_dec): Remove LPT_PEEL_COMPLETELY and
	LPT_PEEL_SIMPLE.
	(UAP_PEEL): Remove.
	(unroll_and_peel_loops): Remove.
	(unroll_loops): New.
	* passes.def: Replace
	pass_rtl_unroll_and_peel_loops by pass_rtl_unroll_loops.
	* loop-init.c (gate_rtl_unroll_and_peel_loops,
	rtl_unroll_and_peel_loops): Rename to ...
	(gate_rtl_unroll_loops, rtl_unroll_loops): ... these; update.
	(pass_rtl_unroll_and_peel_loops): Rename to ...
	(pass_rtl_unroll_loops): ... this one.
	* tree-pass.h (make_pass_rtl_unroll_and_peel_loops): Remove.
	(make_pass_rtl_unroll_loops): New.
	* tree-ssa-loop-ivcanon.c: (estimated_peeled_sequence_size, try_peel_loop): New.
	(canonicalize_loop_induction_variables): Update.

	* gcc.dg/tree-prof/peel-1.c: Update.
	* gcc.dg/tree-prof/unroll-1.c: Update.
	* gcc.dg/gcc.dg/unroll_1.c: Update.
	* gcc.dg/gcc.dg/unroll_2.c: Update.
	* gcc.dg/gcc.dg/unroll_3.c: Update.
	* gcc.dg/gcc.dg/unroll_4.c: Update.

From-SVN: r216238
2014-10-15 08:02:06 +00:00
Richard Biener 7d39012c24 re PR tree-optimization/62081 (ICE: in fix_loop_structure, at loop-init.c:208 with -fno-tree-ch -fno-tree-cselim -fno-tree-dominator-opts -fno-tree-reassoc -fno-tree-sink)
2014-08-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/62081
	* tree-ssa-loop.c (pass_fix_loops): New pass.
	(pass_tree_loop::gate):  Do not fixup loops here.
	* tree-pass.h (make_pass_fix_loops): Declare.
	* passes.def: Schedule pass_fix_loops before GIMPLE loop passes.

From-SVN: r213961
2014-08-14 13:14:24 +00:00
Trevor Saunders 558d255943 remove has_execute
gcc/

	* tree-pass.h (pass_data): Remove has_execute member.
	* passes.c (execute_one_pass): Don't check pass->has_execute.
	* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
	cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
	compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
	config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
	config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
	config/sh/sh_optimize_sett_clrt.cc, config/sh/sh_treg_combine.cc,
	config/sparc/sparc.c, cprop.c, cse.c, dce.c, df-core.c, dse.c,
	dwarf2cfi.c, except.c, final.c, function.c, fwprop.c, gcse.c,
	gimple-low.c, gimple-ssa-isolate-paths.c,
	gimple-ssa-strength-reduction.c, graphite.c, ifcvt.c, init-regs.c,
	ipa-comdats.c, ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c,
	ipa-inline.c, ipa-profile.c, ipa-pure-const.c, ipa-reference.c,
	ipa-split.c, ipa-visibility.c, ipa.c, ira.c, jump.c, loop-init.c,
	lower-subreg.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
	postreload-gcse.c, postreload.c, predict.c, recog.c, ree.c,
	reg-stack.c, regcprop.c, reginfo.c, regrename.c, reorg.c, sched-rgn.c,
	stack-ptr-mod.c, store-motion.c, tracer.c, trans-mem.c,
	tree-call-cdce.c, tree-cfg.c, tree-cfgcleanup.c, tree-complex.c,
	tree-eh.c, tree-emutls.c, tree-if-conv.c, tree-into-ssa.c,
	tree-loop-distribution.c, tree-nrv.c, tree-object-size.c,
	tree-parloops.c, tree-pass.h, tree-predcom.c, tree-profile.c,
	tree-sra.c, tree-ssa-ccp.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
	tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
	tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
	tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
	tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
	tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
	tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
	tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
	tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
	tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
	tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c,
	web.c: Remove initializer for pass_data::has_execute.

From-SVN: r212383
2014-07-09 03:06:49 +00:00
Jan Hubicka eb6a09a725 varpool.c (dump_varpool_node): Dump used_by_single_function.
* varpool.c (dump_varpool_node): Dump used_by_single_function.
	* tree-pass.h (make_pass_ipa_single_use): New pass.
	* cgraph.h (used_by_single_function): New flag.
	* lto-cgraph.c (lto_output_varpool_node, input_varpool_node): Stream
	it.
	* passes.def (pass_ipa_single_use): Scedule.
	* ipa.c (BOTTOM): New macro.
	(meet): New function
	(propagate_single_user): New function.
	(ipa_single_use): New function.
	(pass_data_ipa_single_use): New pass.
	(pass_ipa_single_use): New pass.
	(pass_ipa_single_use::gate): New gate.
	(make_pass_ipa_single_use): New function.

From-SVN: r211925
2014-06-24 03:07:13 +00:00
Richard Biener e5d8bd8c77 tree-ssa-loop.c (gate_loop): New function.
2014-06-23  Richard Biener  <rguenther@suse.de>

	* tree-ssa-loop.c (gate_loop): New function.
	(pass_tree_loop::gate): Call it.
	(pass_data_tree_no_loop, pass_tree_no_loop,
	make_pass_tree_no_loop): New.
	* tree-vectorizer.c: Include tree-scalar-evolution.c
	(pass_slp_vectorize::execute): Initialize loops and SCEV if
	required.
	(pass_slp_vectorize::clone): New method.
	* timevar.def (TV_TREE_NOLOOP): New.
	* tree-pass.h (make_pass_tree_no_loop): Declare.
	* passes.def (pass_tree_no_loop): New pass group with
	SLP vectorizer.

	* g++.dg/vect/slp-pr50413.cc: Scan and cleanup appropriate SLP dumps.
	* g++.dg/vect/slp-pr50819.cc: Likewise.
	* g++.dg/vect/slp-pr56812.cc: Likewise.
	* gcc.dg/vect/bb-slp-1.c: Likewise.
	* gcc.dg/vect/bb-slp-10.c: Likewise.
	* gcc.dg/vect/bb-slp-11.c: Likewise.
	* gcc.dg/vect/bb-slp-13.c: Likewise.
	* gcc.dg/vect/bb-slp-14.c: Likewise.
	* gcc.dg/vect/bb-slp-15.c: Likewise.
	* gcc.dg/vect/bb-slp-16.c: Likewise.
	* gcc.dg/vect/bb-slp-17.c: Likewise.
	* gcc.dg/vect/bb-slp-18.c: Likewise.
	* gcc.dg/vect/bb-slp-19.c: Likewise.
	* gcc.dg/vect/bb-slp-2.c: Likewise.
	* gcc.dg/vect/bb-slp-20.c: Likewise.
	* gcc.dg/vect/bb-slp-21.c: Likewise.
	* gcc.dg/vect/bb-slp-22.c: Likewise.
	* gcc.dg/vect/bb-slp-23.c: Likewise.
	* gcc.dg/vect/bb-slp-24.c: Likewise.
	* gcc.dg/vect/bb-slp-25.c: Likewise.
	* gcc.dg/vect/bb-slp-26.c: Likewise.
	* gcc.dg/vect/bb-slp-27.c: Likewise.
	* gcc.dg/vect/bb-slp-28.c: Likewise.
	* gcc.dg/vect/bb-slp-29.c: Likewise.
	* gcc.dg/vect/bb-slp-3.c: Likewise.
	* gcc.dg/vect/bb-slp-30.c: Likewise.
	* gcc.dg/vect/bb-slp-31.c: Likewise.
	* gcc.dg/vect/bb-slp-32.c: Likewise.
	* gcc.dg/vect/bb-slp-4.c: Likewise.
	* gcc.dg/vect/bb-slp-5.c: Likewise.
	* gcc.dg/vect/bb-slp-6.c: Likewise.
	* gcc.dg/vect/bb-slp-7.c: Likewise.
	* gcc.dg/vect/bb-slp-8.c: Likewise.
	* gcc.dg/vect/bb-slp-8a.c: Likewise.
	* gcc.dg/vect/bb-slp-8b.c: Likewise.
	* gcc.dg/vect/bb-slp-9.c: Likewise.
	* gcc.dg/vect/bb-slp-cond-1.c: Likewise.
	* gcc.dg/vect/bb-slp-pattern-1.c: Likewise.
	* gcc.dg/vect/bb-slp-pattern-2.c: Likewise.
	* gcc.dg/vect/fast-math-bb-slp-call-1.c: Likewise.
	* gcc.dg/vect/fast-math-bb-slp-call-2.c: Likewise.
	* gcc.dg/vect/fast-math-bb-slp-call-3.c: Likewise.
	* gcc.dg/vect/no-tree-reassoc-bb-slp-12.c: Likewise.
	* gcc.dg/vect/no-tree-sra-bb-slp-pr50730.c: Likewise.
	* gcc.dg/vect/pr26359.c: Likewise.
	* gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a.c: Likewise.

From-SVN: r211904
2014-06-23 16:51:10 +00:00