public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100991] New: [OpenMP] firstprivate for optional arguments is mishandled
@ 2021-06-09 11:48 burnus at gcc dot gnu.org
2021-10-31 17:37 ` [Bug fortran/100991] " aldot at gcc dot gnu.org
2023-05-12 14:25 ` burnus at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-06-09 11:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100991
Bug ID: 100991
Summary: [OpenMP] firstprivate for optional arguments is
mishandled
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: openmp
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
Split off from my defaultmap patch.
FAILING is either:
(A) FIRST TEST:
libgomp/testsuite/libgomp.fortran/optional-map.f90
for the implicitly mapped
subroutine sub2(ii, ...
integer, optional :: ii, ...
but that requires the trans-openmp.c patch shown below (otherwise, ii is mapped
fromto)
(B) SECOND TEST
program main
implicit none
integer :: ii
ii = 7
call foo(ii)
call foo()
contains
subroutine foo (ii1)
integer, optional :: ii1
!$omp target firstprivate(ii1)
if (present (ii1)) then
if (ii1 /= 7) stop 1
ii1 = 5
end if
!$omp end target
if (present (ii1)) then
if (ii1 /= 7) stop 1
end if
end
end
Patch mentioned for (A):
gfc_omp_scalar_p (tree decl, bool ptr_alloc_ok)
{
tree type = TREE_TYPE (decl);
+ if (gfc_omp_is_optional_argument (decl))
+ type = TREE_TYPE (type);
if (TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type);
if (TREE_CODE (type) == POINTER_TYPE)
* * * *
The code needed is similar to:
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12804,7 +12804,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p,
omp_context *ctx)
if (omp_is_reference (ovar))
type = TREE_TYPE (type);
if ((INTEGRAL_TYPE_P (type)
- && TYPE_PRECISION (type) <= POINTER_SIZE)
+ && TYPE_PRECISION (type) <= POINTER_SIZE
+ && !omp_check_optional_argument (ovar, false))
|| TREE_CODE (type) == POINTER_TYPE)
{
tkind = GOMP_MAP_FIRSTPRIVATE_INT;
@@ -13026,13 +13027,15 @@ lower_omp_target (gimple_stmt_iterator *gsi_p,
omp_context *ctx)
|| is_gimple_reg_type (TREE_TYPE (var)))
{
tree new_var = lookup_decl (var, ctx);
+ bool is_optional = omp_check_optional_argument (var, false);
tree type;
type = TREE_TYPE (var);
if (omp_is_reference (var))
type = TREE_TYPE (type);
if ((INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) <= POINTER_SIZE)
- || TREE_CODE (type) == POINTER_TYPE)
+ || TREE_CODE (type) == POINTER_TYPE
+ || is_optional)
{
x = build_receiver_ref (var, false, ctx);
if (TREE_CODE (type) != POINTER_TYPE)
@@ -13040,11 +13043,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p,
omp_context *ctx)
x = fold_convert (type, x);
gimplify_expr (&x, &new_body, NULL, is_gimple_val,
fb_rvalue);
- if (omp_is_reference (var))
+ if (omp_is_reference (var) || is_optional)
{
+ tree present = (is_optional
+ ? omp_check_optional_argument (ovar,
true)
+ : NULL_TREE);
...
(Cf. other code in this file.)
Except, of course, that this does not handle all the fun stuff which is not
trivially assignable. (allocatable arrays, polymorphic ...)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/100991] [OpenMP] firstprivate for optional arguments is mishandled
2021-06-09 11:48 [Bug fortran/100991] New: [OpenMP] firstprivate for optional arguments is mishandled burnus at gcc dot gnu.org
@ 2021-10-31 17:37 ` aldot at gcc dot gnu.org
2023-05-12 14:25 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: aldot at gcc dot gnu.org @ 2021-10-31 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100991
Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |aldot at gcc dot gnu.org
Last reconfirmed| |2021-10-31
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/100991] [OpenMP] firstprivate for optional arguments is mishandled
2021-06-09 11:48 [Bug fortran/100991] New: [OpenMP] firstprivate for optional arguments is mishandled burnus at gcc dot gnu.org
2021-10-31 17:37 ` [Bug fortran/100991] " aldot at gcc dot gnu.org
@ 2023-05-12 14:25 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2023-05-12 14:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100991
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Close as INVALID as firstprivate is no longer regarded as valid for absent
optional arguments in OpenMP
See PR 109831 for the remaining issues and what is valid.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-12 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 11:48 [Bug fortran/100991] New: [OpenMP] firstprivate for optional arguments is mishandled burnus at gcc dot gnu.org
2021-10-31 17:37 ` [Bug fortran/100991] " aldot at gcc dot gnu.org
2023-05-12 14:25 ` burnus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).