From b8daf3d80b6daa9fab3e523586d1f570de43a9cb Mon Sep 17 00:00:00 2001 From: bergner Date: Thu, 29 Jun 2017 12:58:32 +0000 Subject: gcc/ PR middle-end/81194 * cfgexpand.c (expand_gimple_stmt_1): Handle switch statements with only one label. * stmt.c (expand_case): Assert NCASES is greater than one. gcc/testsuite/ PR middle-end/81194 * g++.dg/pr81194.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249783 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index c1f80727d30..d61c261a172 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3566,7 +3566,13 @@ expand_gimple_stmt_1 (gimple *stmt) case GIMPLE_PREDICT: break; case GIMPLE_SWITCH: - expand_case (as_a (stmt)); + { + gswitch *swtch = as_a (stmt); + if (gimple_switch_num_labels (swtch) == 1) + expand_goto (CASE_LABEL (gimple_switch_default_label (swtch))); + else + expand_case (swtch); + } break; case GIMPLE_ASM: expand_asm_stmt (as_a (stmt)); -- cgit v1.2.1 From 720cfc437994ab33ce3047b15eddcb727a26f2c1 Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 29 Jun 2017 16:40:53 +0000 Subject: * asan.c (asan_emit_stack_protection): Update. (create_cond_insert_point): Update. * auto-profile.c (afdo_propagate_circuit): Update. * basic-block.h (struct edge_def): Turn probability to profile_probability. (EDGE_FREQUENCY): Update. * bb-reorder.c (find_traces_1_round): Update. (better_edge_p): Update. (sanitize_hot_paths): Update. * cfg.c (unchecked_make_edge): Initialize probability to uninitialized. (make_single_succ_edge): Update. (check_bb_profile): Update. (dump_edge_info): Update. (update_bb_profile_for_threading): Update. * cfganal.c (connect_infinite_loops_to_exit): Initialize new edge probabilitycount to 0. * cfgbuild.c (compute_outgoing_frequencies): Update. * cfgcleanup.c (try_forward_edges): Update. (outgoing_edges_match): Update. (try_crossjump_to_edge): Update. * cfgexpand.c (expand_gimple_cond): Update make_single_succ_edge. (expand_gimple_tailcall): Update. (construct_init_block): Use make_single_succ_edge. (construct_exit_block): Use make_single_succ_edge. * cfghooks.c (verify_flow_info): Update. (redirect_edge_succ_nodup): Update. (split_edge): Update. (account_profile_record): Update. * cfgloopanal.c (single_likely_exit): Update. * cfgloopmanip.c (scale_loop_profile): Update. (set_zero_probability): Remove. (duplicate_loop_to_header_edge): Update. * cfgloopmanip.h (loop_version): Update prototype. * cfgrtl.c (try_redirect_by_replacing_jump): Update. (force_nonfallthru_and_redirect): Update. (update_br_prob_note): Update. (rtl_verify_edges): Update. (purge_dead_edges): Update. (rtl_lv_add_condition_to_bb): Update. * cgraph.c: (cgraph_edge::redirect_call_stmt_to_calle): Update. * cgraphunit.c (init_lowered_empty_function): Update. (cgraph_node::expand_thunk): Update. * cilk-common.c: Include profile-count.h * dojump.c (inv): Remove. (jumpifnot): Update. (jumpifnot_1): Update. (do_jump_1): Update. (do_jump): Update. (do_jump_by_parts_greater_rtx): Update. (do_compare_rtx_and_jump): Update. * dojump.h (jumpifnot, jumpifnot_1, jumpif_1, jumpif, do_jump, do_jump_1. do_compare_rtx_and_jump): Update prototype. * dwarf2cfi.c: Include profile-count.h * except.c (dw2_build_landing_pads): Use make_single_succ_edge. (sjlj_emit_dispatch_table): Likewise. * explow.c: Include profile-count.h * expmed.c (emit_store_flag_force): Update. (do_cmp_and_jump): Update. * expr.c (compare_by_pieces_d::generate): Update. (compare_by_pieces_d::finish_mode): Update. (emit_block_move_via_loop): Update. (store_expr_with_bounds): Update. (store_constructor): Update. (expand_expr_real_2): Update. (expand_expr_real_1): Update. * expr.h (try_casesi, try_tablejump): Update prototypes. * gimple-pretty-print.c (dump_probability): Update. (dump_profile): New. (dump_gimple_label): Update. (dump_gimple_bb_header): Update. * graph.c (draw_cfg_node_succ_edges): Update. * hsa-gen.c (convert_switch_statements): Update. * ifcvt.c (cheap_bb_rtx_cost_p): Update. (find_if_case_1): Update. (find_if_case_2): Update. * internal-fn.c (expand_arith_overflow_result_store): Update. (expand_addsub_overflow): Update. (expand_neg_overflow): Update. (expand_mul_overflow): Update. (expand_vector_ubsan_overflow): Update. * ipa-cp.c (good_cloning_opportunity_p): Update. * ipa-split.c (split_function): Use make_single_succ_edge. * ipa-utils.c (ipa_merge_profiles): Update. * loop-doloop.c (add_test): Update. (doloop_modify): Update. * loop-unroll.c (compare_and_jump_seq): Update. (unroll_loop_runtime_iterations): Update. * lra-constraints.c (lra_inheritance): Update. * lto-streamer-in.c (input_cfg): Update. * lto-streamer-out.c (output_cfg): Update. * mcf.c (adjust_cfg_counts): Update. * modulo-sched.c (sms_schedule): Update. * omp-expand.c (expand_omp_for_init_counts): Update. (extract_omp_for_update_vars): Update. (expand_omp_ordered_sink): Update. (expand_omp_for_ordered_loops): Update. (expand_omp_for_generic): Update. (expand_omp_for_static_nochunk): Update. (expand_omp_for_static_chunk): Update. (expand_cilk_for): Update. (expand_omp_simd): Update. (expand_omp_taskloop_for_outer): Update. (expand_omp_taskloop_for_inner): Update. * omp-simd-clone.c (simd_clone_adjust): Update. * optabs.c (expand_doubleword_shift): Update. (expand_abs): Update. (emit_cmp_and_jump_insn_1): Update. (expand_compare_and_swap_loop): Update. * optabs.h (emit_cmp_and_jump_insns): Update prototype. * predict.c (predictable_edge_p): Update. (edge_probability_reliable_p): Update. (set_even_probabilities): Update. (combine_predictions_for_insn): Update. (combine_predictions_for_bb): Update. (propagate_freq): Update. (estimate_bb_frequencies): Update. (force_edge_cold): Update. * profile-count.c (profile_count::dump): Add missing space into dump. (profile_count::debug): Add newline. (profile_count::differs_from_p): Explicitly convert to unsigned. (profile_count::stream_in): Update. (profile_probability::dump): New member function. (profile_probability::debug): New member function. (profile_probability::differs_from_p): New member function. (profile_probability::differs_lot_from_p): New member function. (profile_probability::stream_in): New member function. (profile_probability::stream_out): New member function. * profile-count.h (profile_count_quality): Rename to ... (profile_quality): ... this one. (profile_probability): New. (profile_count): Update. * profile.c (compute_branch_probabilities): Update. * recog.c (peep2_attempt): Update. * sched-ebb.c (schedule_ebbs): Update. * sched-rgn.c (find_single_block_region): Update. (compute_dom_prob_ps): Update. (schedule_region): Update. * sel-sched-ir.c (compute_succs_info): Update. * stmt.c (struct case_node): Update. (do_jump_if_equal): Update. (get_outgoing_edge_probs): Update. (conditional_probability): Update. (emit_case_dispatch_table): Update. (expand_case): Update. (expand_sjlj_dispatch_table): Update. (emit_case_nodes): Update. * targhooks.c: Update. * tracer.c (better_p): Update. (find_best_successor): Update. * trans-mem.c (expand_transaction): Update. * tree-call-cdce.c: Update. * tree-cfg.c (gimple_split_edge): Upate. (move_sese_region_to_fn): Upate. * tree-cfgcleanup.c (cleanup_control_expr_graph): Upate. * tree-eh.c (lower_resx): Upate. (cleanup_empty_eh_move_lp): Upate. * tree-if-conv.c (version_loop_for_if_conversion): Update. * tree-inline.c (copy_edges_for_bb): Update. (copy_cfg_body): Update. * tree-parloops.c (gen_parallel_loop): Update. * tree-profile.c (gimple_gen_ic_func_profiler): Update. (gimple_gen_time_profiler): Update. * tree-ssa-dce.c (remove_dead_stmt): Update. * tree-ssa-ifcombine.c (update_profile_after_ifcombine): Update. * tree-ssa-loop-im.c (execute_sm_if_changed): Update. * tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Update. (unloop_loops): Update. (try_peel_loop): Update. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Update. * tree-ssa-loop-split.c (connect_loops): Update. (split_loop): Update. * tree-ssa-loop-unswitch.c (tree_unswitch_loop): Update. (hoist_guard): Update. * tree-ssa-phionlycprop.c (propagate_rhs_into_lhs): Update. * tree-ssa-phiopt.c (replace_phi_edge_with_variable): Update. (value_replacement): Update. * tree-ssa-reassoc.c (branch_fixup): Update. * tree-ssa-tail-merge.c (replace_block_by): Update. * tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Update. (create_edge_and_update_destination_phis): Update. (compute_path_counts): Update. (recompute_probabilities): Update. (update_joiner_offpath_counts): Update. (freqs_to_counts_path): Update. (duplicate_thread_path): Update. * tree-switch-conversion.c (hoist_edge_and_branch_if_true): Update. (struct switch_conv_info): Update. (gen_inbound_check): Update. * tree-vect-loop-manip.c (slpeel_add_loop_guard): Update. (vect_do_peeling): Update. (vect_loop_versioning): Update. * tree-vect-loop.c (scale_profile_for_vect_loop): Update. (optimize_mask_stores): Update. * ubsan.c (ubsan_expand_null_ifn): Update. * value-prof.c (gimple_divmod_fixed_value): Update. (gimple_divmod_fixed_value_transform): Update. (gimple_mod_pow2): Update. (gimple_mod_pow2_value_transform): Update. (gimple_mod_subtract): Update. (gimple_mod_subtract_transform): Update. (gimple_ic): Update. (gimple_stringop_fixed_value): Update. (gimple_stringops_transform): Update. * value-prof.h: Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249800 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index d61c261a172..71662f21350 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2389,7 +2389,6 @@ static basic_block expand_gimple_cond (basic_block bb, gcond *stmt) { basic_block new_bb, dest; - edge new_edge; edge true_edge; edge false_edge; rtx_insn *last2, *last; @@ -2508,9 +2507,7 @@ expand_gimple_cond (basic_block bb, gcond *stmt) if (loop->latch == bb && loop->header == dest) loop->latch = new_bb; - new_edge = make_edge (new_bb, dest, 0); - new_edge->probability = REG_BR_PROB_BASE; - new_edge->count = new_bb->count; + make_single_succ_edge (new_bb, dest, 0); if (BARRIER_P (BB_END (new_bb))) BB_END (new_bb) = PREV_INSN (BB_END (new_bb)); update_bb_for_insn (new_bb); @@ -3788,7 +3785,7 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru) rtx_insn *last2, *last; edge e; edge_iterator ei; - int probability; + profile_probability probability; last2 = last = expand_gimple_stmt (stmt); @@ -3813,7 +3810,7 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru) all edges here, or redirecting the existing fallthru edge to the exit block. */ - probability = 0; + probability = profile_probability::never (); profile_count count = profile_count::zero (); for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) @@ -5839,12 +5836,11 @@ construct_init_block (void) { first_block = e->dest; redirect_edge_succ (e, init_block); - e = make_edge (init_block, first_block, flags); + e = make_single_succ_edge (init_block, first_block, flags); } else - e = make_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FALLTHRU); - e->probability = REG_BR_PROB_BASE; - e->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count; + e = make_single_succ_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun), + EDGE_FALLTHRU); update_bb_for_insn (init_block); return init_block; @@ -5924,9 +5920,8 @@ construct_exit_block (void) ix++; } - e = make_edge (exit_block, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FALLTHRU); - e->probability = REG_BR_PROB_BASE; - e->count = EXIT_BLOCK_PTR_FOR_FN (cfun)->count; + e = make_single_succ_edge (exit_block, EXIT_BLOCK_PTR_FOR_FN (cfun), + EDGE_FALLTHRU); FOR_EACH_EDGE (e2, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) if (e2 != e) { -- cgit v1.2.1 From 7e93252e57fb52f011775e9f8db6ffda523fbd19 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 30 Jun 2017 17:00:46 +0000 Subject: * ggc.h (empty_string): Delete. * cfgexpand.c (expand_asm_stmt): Use plain "". * optabs.c (expand_asm_memory_barrier): Likewise. * stringpool.c (empty_string): Delete. (digit_vector, digit_string): Delete. (ggc_alloc_string): Use plain "", don't optimize single digit strings. Use ggc_alloc_atomic. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249851 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 71662f21350..3b5f2fe270f 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3165,7 +3165,7 @@ expand_asm_stmt (gasm *stmt) rtx body = gen_rtx_ASM_OPERANDS ((noutputs == 0 ? VOIDmode : GET_MODE (output_rvec[0])), ggc_strdup (gimple_asm_string (stmt)), - empty_string, 0, argvec, constraintvec, + "", 0, argvec, constraintvec, labelvec, locus); MEM_VOLATILE_P (body) = gimple_asm_volatile_p (stmt); -- cgit v1.2.1 From d08919a73c3e8740f5c663763d476f7f908c7c0f Mon Sep 17 00:00:00 2001 From: chefmax Date: Thu, 6 Jul 2017 16:02:06 +0000 Subject: ASAN: Implement dynamic allocas/VLAs sanitization. gcc/ * asan.c: Include gimple-fold.h. (get_last_alloca_addr): New function. (handle_builtin_stackrestore): Likewise. (handle_builtin_alloca): Likewise. (asan_emit_allocas_unpoison): Likewise. (get_mem_refs_of_builtin_call): Add new parameter, remove const quallifier from first paramerer. Handle BUILT_IN_ALLOCA, BUILT_IN_ALLOCA_WITH_ALIGN and BUILT_IN_STACK_RESTORE builtins. (instrument_builtin_call): Pass gimple iterator to get_mem_refs_of_builtin_call. (last_alloca_addr): New global. * asan.h (asan_emit_allocas_unpoison): Declare. * builtins.c (expand_asan_emit_allocas_unpoison): New function. (expand_builtin): Handle BUILT_IN_ASAN_ALLOCAS_UNPOISON. * cfgexpand.c (expand_used_vars): Call asan_emit_allocas_unpoison if function calls alloca. * gimple-fold.c (replace_call_with_value): Remove static keyword. * gimple-fold.h (replace_call_with_value): Declare. * internal-fn.c: Include asan.h. * sanitizer.def (BUILT_IN_ASAN_ALLOCA_POISON, BUILT_IN_ASAN_ALLOCAS_UNPOISON): New builtins. gcc/testsuite/ * c-c++-common/asan/alloca_big_alignment.c: New test. * c-c++-common/asan/alloca_detect_custom_size.c: Likewise. * c-c++-common/asan/alloca_instruments_all_paddings.c: Likewise. * c-c++-common/asan/alloca_loop_unpoisoning.c: Likewise. * c-c++-common/asan/alloca_overflow_partial.c: Likewise. * c-c++-common/asan/alloca_overflow_right.c: Likewise. * c-c++-common/asan/alloca_safe_access.c: Likewise. * c-c++-common/asan/alloca_underflow_left.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250031 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3b5f2fe270f..dd7277f4a73 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2241,6 +2241,11 @@ expand_used_vars (void) expand_stack_vars (NULL, &data); } + if ((flag_sanitize & SANITIZE_ADDRESS) && cfun->calls_alloca) + var_end_seq = asan_emit_allocas_unpoison (virtual_stack_dynamic_rtx, + virtual_stack_vars_rtx, + var_end_seq); + fini_vars_expansion (); /* If there were any artificial non-ignored vars without rtl -- cgit v1.2.1 From 77c44489f2db5e259e6b113cc0c2f45c1829c9d9 Mon Sep 17 00:00:00 2001 From: chefmax Date: Thu, 6 Jul 2017 16:05:00 +0000 Subject: gcc/ * asan.h (asan_sanitize_allocas_p): Declare. * asan.c (asan_sanitize_allocas_p): New function. (handle_builtin_stack_restore): Bail out if !asan_sanitize_allocas_p. (handle_builtin_alloca): Likewise. * cfgexpand.c (expand_used_vars): Do not add allocas unpoisoning stuff if !asan_sanitize_allocas_p. * params.def (asan-instrument-allocas): Add new option. * params.h (ASAN_PROTECT_ALLOCAS): Define. * opts.c (common_handle_option): Disable allocas sanitization for KASan by default. gcc/testsuite/ * c-c++-common/asan/kasan-alloca-1.c: New test. * c-c++-common/asan/kasan-alloca-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250032 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index dd7277f4a73..c427a89bab0 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2241,7 +2241,7 @@ expand_used_vars (void) expand_stack_vars (NULL, &data); } - if ((flag_sanitize & SANITIZE_ADDRESS) && cfun->calls_alloca) + if (asan_sanitize_allocas_p () && cfun->calls_alloca) var_end_seq = asan_emit_allocas_unpoison (virtual_stack_dynamic_rtx, virtual_stack_vars_rtx, var_end_seq); -- cgit v1.2.1 From 61b3ef70d2921130ef52337e3a8358e28f9b5f21 Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 14 Jul 2017 07:44:33 +0000 Subject: Remove Java references in source code. 2017-07-14 Martin Liska * cfgexpand.c (expand_gimple_basic_block): Remove dead comment. * dwarf2out.c (is_java): Remove the function. (output_pubname): Remove usage of the function. (lower_bound_default): Remove usage of DW_LANG_Java. (gen_compile_unit_die): Likewise. * gcc.c: Remove compiler defaults for .java and .zip files. * gimple-expr.c (remove_suffix): Change as there's no longer extension than 4-letter one. * gimplify.c (mostly_copy_tree_r): Remove Java-special part. (gimplify_save_expr): Likewise. * ipa-utils.h (polymorphic_type_binfo_p): Remove the comment as it's possible even for other languages than Java. * langhooks.h (struct lang_hooks): Remove Java from a comment. * lto-opts.c (lto_write_options): Remove reference to Java. * opts.c (strip_off_ending): Update file extension handling. * tree-cfg.c (verify_gimple_call): Remove comment with Java. * tree-eh.c (lower_resx): Likewise. * tree.c (free_lang_data_in_type): Remove dead code. (find_decls_types_r): Likewise. (build_common_builtin_nodes): Remove Java from a comment. (verify_type): Remove dead code. * varasm.c (assemble_external): Remove Java from a comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250199 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index c427a89bab0..3e1d24db876 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -5497,8 +5497,6 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) if (elt) emit_label (*elt); - /* Java emits line number notes in the top of labels. - ??? Make this go away once line number notes are obsoleted. */ BB_HEAD (bb) = NEXT_INSN (last); if (NOTE_P (BB_HEAD (bb))) BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb)); -- cgit v1.2.1 From c86933f928ee5cd7cb79beff3553787a8e11b7bb Mon Sep 17 00:00:00 2001 From: hubicka Date: Wed, 19 Jul 2017 18:09:39 +0000 Subject: * predict.c (propagate_unlikely_bbs_forward): Break out from ... (determine_unlikely_bbs): ... here. * predict.h (propagate_unlikely_bbs_forward): Declare. * cfgexpand.c (pass_expand::execute): Use it. * bb-reorder.c (sanitize_hot_paths): Do not consider known to be unlikely edges. (find_rarely_executed_basic_blocks_and_crossing_edges): Use propagate_unlikely_bbs_forward. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250360 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgexpand.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/cfgexpand.c') diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3e1d24db876..c9d8118ed45 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -6480,6 +6480,11 @@ pass_expand::execute (function *fun) if (fun->eh->region_tree != NULL) finish_eh_generation (); + /* BB subdivision may have created basic blocks that are are only reachable + from unlikely bbs but not marked as such in the profile. */ + if (optimize) + propagate_unlikely_bbs_forward (); + /* Remove unreachable blocks, otherwise we cannot compute dominators which are needed for loop state verification. As a side-effect this also compacts blocks. -- cgit v1.2.1