[Patch][omp-low.c,fortran] Simple fix for optional argument handling with OpenMP's use_device_ptr

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Patch][omp-low.c,fortran] Simple fix for optional argument handling with OpenMP's use_device_ptr

Tobias Burnus-3
Hi all,
[For those who got it twice, I actually forget to include the mailing
lists in the first round. Ups.]

this patch fixes the bug that with "optional" the wrong pointer is used
with "use_device_ptr"; the bug is already observable without doing
actual offloading.

Namely, "present(ptr)" checks whether the passed argument is != NULL.
While using "ptr" – e.g. as "associated(ptr)" – workes the (once)
dereferenced dummy argument, which matches the actual argument.

The test case is written such that the pointer passed to
"use_device_ptr" is present.*

Built and regtested on x86_64-gnu-linux without device; I am currently
doing a full bootstrap + regtesting and want to test it also with nvptx
offloading. Assuming no issue pops up:

OK for the trunk?

Regarding the patches:

* The first tiny patch is mine

* The second patch which added the lang_hook omp_is_optional_argument is
the one posted at https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01743.html
This one was approved by Jakub and I only did two things:
(a) re-diff-ed it (trivial as fuzzy worked)
(b) I followed both suggestions of Jakub (PARAM_DECL + adding "( )")

[Motivation of this patch is – besides fixing an issue – to get the
second patch it, which makes it easier to consolidate some other bits
and pieces.]



* OpenACC (Sec. 2.17) demands that a variable 'arg' in "clauses has no
effect at runtime if PRESENT(arg) is .false." – Hence, one needs to go
beyond this patch. That's done in the patch series at
https://gcc.gnu.org/ml/gcc-patches/2019-07/threads.html#00960 – the
patch lang_hook patch of this email is 2/5 of that series.

optional-fix.diff (2K) Download Attachment
optional-2-v3.diff (8K) Download Attachment