This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] Fix sharing-1.c and sharing-1.C
On Tue, Oct 18, 2005 at 01:02:29PM -0400, Jakub Jelinek wrote:
> Well, I haven't changed the code in that regard. is_global_var
> TREE_READONLY vars will not be in the shared clause, local ones will be
> as before. Now I think we have 3 options what to do about TREE_READONLY
> locals: 1) special case them already on the omp_notice_* level and put them
> immediately as firstprivate 2) in gimplify_reconstruct_omp_clauses_1
> put TREE_READONLY shared vars into firstprivate rather than shared clause
> 3) handle OMP_CLAUSE_SHARED with TREE_READONLY var as
> OMP_CLAUSE_FIRSTPRIVATE
>
> I think 2) is easiest.
const int *p;
int main()
{
const int x = 1;
p = &x;
#pragma omp parallel
{
if (p != &x)
abort ();
}
return 0;
}
> Yes, we can add this as optimization for the firstprivate case.
> But only if the initializer is sufficiently small (and what is small enough
> here is not clear to me).
The DECL_INITIAL won't exist anymore. It'll have been cleared when
the DECL_EXPR defining it was processed. You'd have to locate the
modify_expr that initializes it.
Now, we *are* already scanning the entire function in omp-low, and
it certainly would be easy to notice sets of non-addressable const-
qualified scalars, and if the value is constant remember that and
substitute that instead of a local variable in firstprivates.
r~