On Tue, Jan 28, 2014 at 2:44 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> Hi!
>
> As discussed in the PR and similarly to what has been done previously
> for __builtin_setjmp only, this patch attempts to decrease number of
> EDGE_ABNORMAL edges in functions with non-local gotos and/or setjmp or
> other functions that return twice.
> Because, if we have many non-local labels or calls returning twice and
> many calls that could potentially longjmp or goto a non-local label,
> and especially if we have many SSA_NAMEs live across those abnormal edges,
> the number of needed PHI arguments is number of non-local
> labels/returns_twice calls times number of (most of) calls times number of
> such SSA_NAMEs, which even on real-world testcases means gigabytes of memory
> and hours of compilation time.
> The patch changes it, so that abnormal edges from calls that might longjmp
> or do non-local goto point to a special basic block containing
> an artificial ABNORMAL_DISPATCHER internal call and from that basic block
> there are abnormal edges to each non-local
> label/__builtin_setjmp_receiver/returns_twice call.
>
> The patch also fixes the OpenMP PR, the abnormal edges since their
> introduction for setjmp for 4.9 (and for non-local gotos and computed gotos
> since forever) prevent discovery of OpenMP regions, because dominance can't
> be used for that.  As OpenMP SESE regions must not be entered abnormally or
> left abnormally (exit allowed as an exception and we allow abort too) in a
> valid program, we don't need to deal with longjmp jumping out of or into
> an OpenMP region (explicitly disallowed in the standard) and similarly for
> non-local gotos or computed gotos, the patch constructs the abnormal
> dispatchers or computed goto factored blocks one per OpenMP SESE region
> that needs it, which means fewer abnormal edges and more importantly that
> the regions can be easily discovered and outlined into separate functions.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2014-01-27  Jakub Jelinek  <ja...@redhat.com>
>
>         PR middle-end/59917
>         PR tree-optimization/59920
>         * tree.c (build_common_builtin_nodes): Remove
>         __builtin_setjmp_dispatcher initialization.
>         * omp-low.h (make_gimple_omp_edges): Add a new int * argument.
>         * profile.c (branch_prob): Use gsi_start_nondebug_after_labels_bb
>         instead of gsi_after_labels + manually skipping debug stmts.
>         Don't ignore bbs with BUILT_IN_SETJMP_DISPATCHER, instead
>         ignore bbs with IFN_ABNORMAL_DISPATCHER.
>         * tree-inline.c (copy_edges_for_bb): Remove
>         can_make_abnormal_goto argument, instead add abnormal_goto_dest
>         argument.  Ignore computed_goto_p stmts.  Don't call
>         make_abnormal_goto_edges.  If a call might need abnormal edges
>         for non-local gotos, see if it already has an edge to
>         IFN_ABNORMAL_DISPATCHER or if it is IFN_ABNORMAL_DISPATCHER
>         with true argument, don't do anything then, otherwise add
>         EDGE_ABNORMAL from the call's bb to abnormal_goto_dest.
>         (copy_cfg_body): Compute abnormal_goto_dest, adjust copy_edges_for_bb
>         caller.
>         * gimple-low.c (struct lower_data): Remove calls_builtin_setjmp.
>         (lower_function_body): Don't emit __builtin_setjmp_dispatcher.
>         (lower_stmt): Don't set data->calls_builtin_setjmp.
>         (lower_builtin_setjmp): Adjust comment.
>         * builtins.def (BUILT_IN_SETJMP_DISPATCHER): Remove.
>         * tree-cfg.c (found_computed_goto): Remove.
>         (factor_computed_gotos): Remove.
>         (make_goto_expr_edges): Return bool, true for computed gotos.
>         Don't call make_abnormal_goto_edges.
>         (build_gimple_cfg): Don't set found_computed_goto, don't call
>         factor_computed_gotos.
>         (computed_goto_p): No longer static.
>         (make_blocks): Don't set found_computed_goto.
>         (handle_abnormal_edges): New function.
>         (make_edges): If make_goto_expr_edges returns true, push bb
>         into ab_edge_goto vector, for stmt_can_make_abnormal_goto calls
>         instead of calling make_abnormal_goto_edges push bb into ab_edge_call
>         vector.  Record mapping between bbs and OpenMP regions if there
>         are any, adjust make_gimple_omp_edges caller.  Call
>         handle_abnormal_edges.
>         (make_abnormal_goto_edges): Remove.
>         * tree-cfg.h (make_abnormal_goto_edges): Remove.
>         (computed_goto_p): New prototype.
>         * internal-fn.c (expand_ABNORMAL_DISPATCHER): New function.
>         * builtins.c (expand_builtin): Don't handle
>         BUILT_IN_SETJMP_DISPATCHER.
>         * internal-fn.def (ABNORMAL_DISPATCHER): New.
>         * omp-low.c (make_gimple_omp_edges): Add region_idx argument, when
>         filling *region also set *region_idx to (*region)->entry->index.
>

It caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60013

H.J.

Reply via email to