On Fri, Jul 31, 2015 at 11:31 AM, Jakub Jelinek <ja...@redhat.com> wrote: > On Fri, Jul 31, 2015 at 11:22:30AM +0200, Richard Biener wrote: >> On Fri, Jul 31, 2015 at 10:43 AM, Jakub Jelinek <ja...@redhat.com> wrote: >> > Hi! >> > >> > I wonder if we shouldn't change: >> > >> > TREE_TYPE (ctx->receiver_decl) >> > = build_qualified_type (build_reference_type (type), >> > TYPE_QUAL_RESTRICT); >> > >> > in fixup_child_record_type to add: >> > >> > if (is_gimple_omp_offloaded (ctx->stmt)) >> > type = build_qualified_type (type, TYPE_QUAL_CONST); >> > >> > before it (and perhaps also add | TYPE_QUAL_CONST to TYPE_QUAL_RESTRICT >> > for all >> > constructs). I mean, aren't all the pointers in *.omp_data_i for the >> > target >> > constructs constant in the offloaded region? Perhaps that could result in >> > better generated code (though perhaps just the restrict helps enough). >> > Can you think of any case where it is not constant? >> >> Const qualification of a pointer or reference doesn't result in any >> optimization. The >> decl you refer to has to be constant. > > Even if the pointer would be addressable?
Yes, it's the decls readonly setting that matters, not type qualification. > But it isn't in this case. > Still the > if (is_gimple_omp_offloaded (ctx->stmt)) > type = build_qualified_type (type, TYPE_QUAL_CONST); > would constify what the reference refers to. Maybe it doesn't make > any difference either due to TYPE_QUAL_RESTRICT on the reference though. Maybe. Richard. > Jakub