Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    8b604594
    openmp: Don't optimize shared to firstprivate on task with depend clause · 8b604594
    Jakub Jelinek authored
    The attached testcase is miscompiled, because we optimize shared clauses
    to firstprivate when task body can't modify the variable even when the
    task has depend clause.  That is wrong, because firstprivate means the
    variable will be copied immediately when the task is created, while with
    depend clause some other task might change it later before the dependencies
    are satisfied and the task should observe the value only after the change.
    
    2020-12-18  Jakub Jelinek  <jakub@redhat.com>
    
    	* gimplify.c (struct gimplify_omp_ctx): Add has_depend member.
    	(gimplify_scan_omp_clauses): Set it to true if OMP_CLAUSE_DEPEND
    	appears on OMP_TASK.
    	(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Force
    	GOVD_WRITTEN on shared variables if task construct has depend clause.
    
    	* testsuite/libgomp.c/task-6.c: New test.
    8b604594
    History
    openmp: Don't optimize shared to firstprivate on task with depend clause
    Jakub Jelinek authored
    The attached testcase is miscompiled, because we optimize shared clauses
    to firstprivate when task body can't modify the variable even when the
    task has depend clause.  That is wrong, because firstprivate means the
    variable will be copied immediately when the task is created, while with
    depend clause some other task might change it later before the dependencies
    are satisfied and the task should observe the value only after the change.
    
    2020-12-18  Jakub Jelinek  <jakub@redhat.com>
    
    	* gimplify.c (struct gimplify_omp_ctx): Add has_depend member.
    	(gimplify_scan_omp_clauses): Set it to true if OMP_CLAUSE_DEPEND
    	appears on OMP_TASK.
    	(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Force
    	GOVD_WRITTEN on shared variables if task construct has depend clause.
    
    	* testsuite/libgomp.c/task-6.c: New test.