Fix ICE for map iterator with non-constant bound
An ICE (Internal Compiler Error) in OpenMP's iterator handling is fixed by unsetting OMP_CLAUSE_ITERATORS after a sorry diagnostic.
This commit addresses an Internal Compiler Error (ICE) that occurred in GCC’s OpenMP implementation when handling map iterators with non-constant bounds. Previously, even after a ‘sorry’ diagnostic was issued for such cases, internal compiler state (elems remaining NULL_TREE) would lead to a crash. The fix involves unsetting the OMP_CLAUSE_ITERATORS flag after the diagnostic is issued, preventing the subsequent segfault.
In Details
An ICE in build_omp_iterators_loops within gimplify.cc is resolved by this commit. The issue arose when an OpenMP loop iterator had a non-constant bound, which correctly triggered a 'sorry' diagnostic. However, the compiler's internal state, specifically the elems variable remaining NULL_TREE, caused a segmentation fault shortly after. The fix unsets the OMP_CLAUSE_ITERATORS flag after the 'sorry' diagnostic, preventing the erroneous state from persisting and causing the crash. A test case is added to cover this specific scenario.
- OpenMP
- An API that supports multi-platform shared-memory parallel programming in C, C++, and Fortran, primarily used for loop-level parallelism.
- ICE
- Internal Compiler Error. A critical error that occurs within the compiler itself, usually indicating a bug in the compiler's logic.
- map iterator
- In the context of OpenMP, this likely refers to an iterator used for traversing elements within a data structure that is being mapped for offloading or parallel processing.
- non-constant bound
- A loop bound (start, end, or step value) whose value is not known at compile time and may vary during program execution.
- sorry diagnostic
- A message produced by the compiler indicating that a feature or construct is not supported, often before terminating compilation with an error.
- OMP_CLAUSE_ITERATORS
- An internal compiler flag or state variable likely used to track the presence or handling of iterators within OpenMP clauses during compilation.
- gimplify.cc
- A source file within GCC that handles the 'gimplification' process, where high-level language constructs are converted into GCC's internal generic representation (GIMPLE).