Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    98acbb31
    openmp: Fix up taskloop reduction ICE if taskloop has no iterations [PR100471] · 98acbb31
    Jakub Jelinek authored
    When a taskloop doesn't have any iterations, GOMP_taskloop* takes an early
    return, doesn't create any tasks and more importantly, doesn't create
    a taskgroup and doesn't register task reductions.  But, the code emitted
    in the callers assumes task reductions have been registered and performs
    the reduction handling and task reduction unregistration.  The pointer
    to the task reduction private variables is reused, on input it is the alignment
    and only on output it is the pointer, so in the case taskloop with no iterations
    the caller attempts to dereference the alignment value as if it was a pointer
    and crashes.  We could in the early returns register the task reductions
    only to have them looped over and unregistered in the caller, but I think
    it is better to tell the caller there is nothing to task reduce and bypass
    all that.
    
    2021-05-11  Jakub Jelinek  <jakub@redhat.com>
    
    	PR middle-end/100471
    	* omp-low.c (lower_omp_task_reductions): For OMP_TASKLOOP, if data
    	is 0, bypass the reduction loop including
    	GOMP_taskgroup_reduction_unregister call.
    
    	* taskloop.c (GOMP_taskloop): If GOMP_TASK_FLAG_REDUCTION and not
    	GOMP_TASK_FLAG_NOGROUP, when doing early return clear the task
    	reduction pointer.
    	* testsuite/libgomp.c/task-reduction-4.c: New test.
    98acbb31
    History
    openmp: Fix up taskloop reduction ICE if taskloop has no iterations [PR100471]
    Jakub Jelinek authored
    When a taskloop doesn't have any iterations, GOMP_taskloop* takes an early
    return, doesn't create any tasks and more importantly, doesn't create
    a taskgroup and doesn't register task reductions.  But, the code emitted
    in the callers assumes task reductions have been registered and performs
    the reduction handling and task reduction unregistration.  The pointer
    to the task reduction private variables is reused, on input it is the alignment
    and only on output it is the pointer, so in the case taskloop with no iterations
    the caller attempts to dereference the alignment value as if it was a pointer
    and crashes.  We could in the early returns register the task reductions
    only to have them looped over and unregistered in the caller, but I think
    it is better to tell the caller there is nothing to task reduce and bypass
    all that.
    
    2021-05-11  Jakub Jelinek  <jakub@redhat.com>
    
    	PR middle-end/100471
    	* omp-low.c (lower_omp_task_reductions): For OMP_TASKLOOP, if data
    	is 0, bypass the reduction loop including
    	GOMP_taskgroup_reduction_unregister call.
    
    	* taskloop.c (GOMP_taskloop): If GOMP_TASK_FLAG_REDUCTION and not
    	GOMP_TASK_FLAG_NOGROUP, when doing early return clear the task
    	reduction pointer.
    	* testsuite/libgomp.c/task-reduction-4.c: New test.