https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99322

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:a3ad6489d38982434faef3bc5f33e3c28c5f7c74

commit r11-7533-ga3ad6489d38982434faef3bc5f33e3c28c5f7c74
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Mar 5 21:52:35 2021 +0100

    openmp: Avoid ICEs due to orphaned labels in OpenMP regions [PR99322]

    When performing cfg cleanup at the end of cfg pass, if there are any OpenMP
    regions and some basic blocks are unreachable and contain forced labels,
    remove_bb moves the labels to previous bb, but if the two bb belong to
different
    OpenMP regions, that means it will end up in a different function from
where
    it was assumed to be and checked e.g. during gimplification or OpenMP
region
    SESE checking.

    The following patch will place the labels to some bb from the right OpenMP
    region if the previous bb is not that.  I think it should happen very
rarely,
    normally the bbs from each OpenMP region should be from the before-cfg pass
    adjacent and the problems will usually be only if the OpenMP regions are
    no-return, so I hope it isn't fatal that it searches through all bbs on the
miss.
    If it turns out to be a problem, it can always lazily create some better
data
    structure and maintain it through bb removals when it reaches that case the
    first time.

    2021-03-05  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/99322
            * tree-cfg.c (bb_to_omp_idx): New variable.
            (execute_build_cfg): Release the bb_to_omp_idx vector after
            cleanup_tree_cfg returns.
            (handle_abnormal_edges): Remove bb_to_omp_idx argument, adjust
            for bb_to_omp_idx being a vec<int> instead of pointer to array
            of ints.
            (make_edges): Remove bb_to_omp_idx local variable, don't pass
            it to handle_abnormal_edges, adjust for bb_to_omp_idx being a
            vec<int> instead of pointer to array of ints and don't free/release
            it at the end.
            (remove_bb): When removing a bb and placing forced label somewhere
            else, ensure it is put into the same OpenMP region during cfg
            pass if possible or to entry successor as fallback.  Unregister
            bb from bb_to_omp_idx.

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

Reply via email to