This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Constification of _omp_fn.* argument for target regions
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Nathan Sidwell <nathan at acm dot org>, Ilya Verbin <iverbin at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 31 Jul 2015 12:06:36 +0200
- Subject: Re: Constification of _omp_fn.* argument for target regions
- Authentication-results: sourceware.org; auth=none
- References: <20150731084311 dot GY1780 at tucnak dot redhat dot com> <CAFiYyc2S2bqSLZzMRBK6ETaV+1OZqkgcKT8zUhkegw-GoEga8g at mail dot gmail dot com> <20150731093103 dot GZ1780 at tucnak dot redhat dot com> <CAFiYyc1Z6NpuBtmMOt3Lrp790U2Z12mfuHjH6CmuGTUfOAT=PQ at mail dot gmail dot com> <20150731095100 dot GA1780 at tucnak dot redhat dot com>
On Fri, Jul 31, 2015 at 11:51 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jul 31, 2015 at 11:41:47AM +0200, Richard Biener wrote:
>> >> 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.
>
> Ok, so I'll test:
>
> 2015-07-31 Jakub Jelinek <jakub@redhat.com>
>
> * omp-low.c (fixup_child_record_type): Const qualify *.omp_data_i.
> (create_omp_child_function): Set TREE_READONLY on .omp_data_i.
>
> --- gcc/omp-low.c.jj 2015-07-31 11:08:38.581201231 +0200
> +++ gcc/omp-low.c 2015-07-31 11:49:14.764734054 +0200
> @@ -1824,6 +1824,11 @@ fixup_child_record_type (omp_context *ct
> layout_type (type);
> }
>
> + /* In a target region we never modify any of the pointers in *.omp_data_i,
> + so attempt to help the optimizers. */
> + if (is_gimple_omp_offloaded (ctx->stmt))
> + type = build_qualified_type (type, TYPE_QUAL_CONST);
> +
> TREE_TYPE (ctx->receiver_decl)
> = build_qualified_type (build_reference_type (type), TYPE_QUAL_RESTRICT);
> }
> @@ -2521,6 +2526,7 @@ create_omp_child_function (omp_context *
> DECL_ARG_TYPE (t) = ptr_type_node;
> DECL_CONTEXT (t) = current_function_decl;
> TREE_USED (t) = 1;
> + TREE_READONLY (t) = 1;
Ah, it's a parameter. I think we don't use TREE_READONLY on that, we use
it only on globals.
Richard.
> if (cilk_for_count)
> DECL_CHAIN (t) = DECL_ARGUMENTS (decl);
> DECL_ARGUMENTS (decl) = t;
>
>
> Jakub