[Patch] OpenMP/Fortran: Handle polymorphic scalars in data-sharing FIRSTPRIVATE (PR86470)
Tobias Burnus
burnus@net-b.de
Mon Aug 31 13:58:59 GMT 2020
Hi Andre,
On 8/31/20 12:55 PM, Andre Vehreschild wrote:
> +gfc_is_unlimited_polymorphic_nonptr (tree type)
> + tree field = TYPE_FIELDS (type); /* _data */
> + if (!field)
>
> ^^^ here you don't . So theoretically this routine could match a type which
> has a _len as its third field, but that is not a unlim-poly class. Maybe factor
> out the test from the above routine and unify with this one to reuse the test
> for a BT_CLASS?!
Granted. The reason was the code use:
if (polymophic)
{
...
if (unlimited_polymorphic)
Hence, I assumed that that check was already done, reducing
code size (but having less universality) and increasing
(cold-code) performance.
My new idea is to unify the two functions and add an
"bool only_unlimited" flag.
> Btw, I believe the first routine can be better replaced by:
>
> static bool
> gfc_is_polymorphic_nonptr (tree type)
> {
> if (POINTER_TYPE_P (type))
> type = TREE_TYPE (type);
> return GFC_CLASS_TYPE_P (type);
> }
Maybe. However, when looking into the check for polymorphic
arrays, the DECL_LANG_SPECIFIC (and I think TYPE_LANG_SPECIFIC)
were present but contained only garbage. Thus, it might not work.
(I have to check.) – If it works, I will use your nicer suggestion.
If it doesn't work, I would go for my proposal above.
(Eventually, in a follow-up patch for polymorphic arrays, it has
to be fixed properly to avoid the following hack.)
> + /* TODO: implement support for polymorphic arrays; reject for now. */
> + /* Void arrays appear as var.0 = var._data.data. A bit hackish to
> + distinguish from 'type(c_ptr) :: var(5)' by scanning for '.';
> + this assumes that ASM_FORMAT_PRIVATE_NAME uses a '.', which most
> + systems do. */
> ...
> I totally agree that this is hackish and I don't like for that. But I can't
> come up with a better solution at the moment.
I think some changes at multiple places are needed to implement this
properly – but for the 'sorry' I did not want to do non-local changes;
for the real version, it should use some nicer code!
Thanks for the suggestions and review.
Tobias
PS: I want to first finish working on some other tasks before coming back
to this patch.
More information about the Gcc-patches
mailing list