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

Tobias Burnus tobias@codesourcery.com
Tue Oct 1 14:19:00 GMT 2019


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.]


Thanks,

Tobias

* 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.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: optional-fix.diff
Type: text/x-patch
Size: 2010 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191001/5d0a3c2c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: optional-2-v3.diff
Type: text/x-patch
Size: 8582 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191001/5d0a3c2c/attachment-0001.bin>


More information about the Gcc-patches mailing list