+2022-02-11 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * omp-general.c (DELAY_METADIRECTIVES_AFTER_LTO): Check that cfun is
+ non-null before derefencing.
+
2022-01-28 Kwok Cheung Yeung <kcy@codesourcery.com>
* gimplify.c (gimplify_omp_metadirective): Mark offloadable functions
+2022-02-11 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * decl.c (gfc_match_end): Search for first previous state that is not
+ COMP_OMP_METADIRECTIVE.
+ * gfortran.h (gfc_skip_omp_metadirective_clause): Add prototype.
+ * openmp.c (match_omp_metadirective): Skip clause if
+ result of gfc_skip_omp_metadirective_clause is true.
+ * trans-openmp.c (gfc_trans_omp_set_selector): Add argument and
+ disable expression conversion if false.
+ (gfc_skip_omp_metadirective_clause): New.
+
2022-01-31 Kwok Cheung Yeung <kcy@codesourcery.com>
* openmp.c (gfc_match_omp_context_selector_specification): Remove
case COMP_CONTAINS:
case COMP_DERIVED_CONTAINS:
- case COMP_OMP_METADIRECTIVE:
case COMP_OMP_BEGIN_METADIRECTIVE:
state = gfc_state_stack->previous->state;
block_name = gfc_state_stack->previous->sym == NULL
- ? NULL : gfc_state_stack->previous->sym->name;
+ ? NULL : gfc_state_stack->previous->sym->name;
abreviated_modproc_decl = gfc_state_stack->previous->sym
&& gfc_state_stack->previous->sym->abr_modproc_decl;
break;
+ case COMP_OMP_METADIRECTIVE:
+ {
+ /* Metadirectives can be nested, so we need to drill down to the
+ first state that is not COMP_OMP_METADIRECTIVE. */
+ gfc_state_data *state_data = gfc_state_stack;
+
+ do
+ {
+ state_data = state_data->previous;
+ state = state_data->state;
+ block_name = state_data->sym == NULL
+ ? NULL : state_data->sym->name;
+ abreviated_modproc_decl = state_data->sym
+ && state_data->sym->abr_modproc_decl;
+ }
+ while (state == COMP_OMP_METADIRECTIVE);
+ }
+ break;
default:
break;
}
void finish_oacc_declare (gfc_namespace *, gfc_symbol *, bool);
void gfc_adjust_builtins (void);
+/* trans-openmp.c */
+
+bool gfc_skip_omp_metadirective_clause (gfc_omp_metadirective_clause *);
+
#endif /* GCC_GFORTRAN_H */
new_st.ext.omp_clauses = NULL;
}
- *next_clause = omc;
- next_clause = &omc->next;
+ if (!gfc_skip_omp_metadirective_clause (omc))
+ {
+ *next_clause = omc;
+ next_clause = &omc->next;
+ }
}
if (gfc_match_omp_eos () != MATCH_YES)
}
static tree
-gfc_trans_omp_set_selector (gfc_omp_set_selector *gfc_selectors, locus where)
+gfc_trans_omp_set_selector (gfc_omp_set_selector *gfc_selectors, locus where,
+ bool conv_expr_p = true)
{
tree set_selectors = NULL_TREE;
gfc_omp_set_selector *oss;
case CTX_PROPERTY_USER:
case CTX_PROPERTY_EXPR:
{
- gfc_se se;
- gfc_init_se (&se, NULL);
- gfc_conv_expr (&se, otp->expr);
- properties = tree_cons (NULL_TREE, se.expr,
- properties);
+ tree expr = NULL_TREE;
+ if (conv_expr_p)
+ {
+ gfc_se se;
+ gfc_init_se (&se, NULL);
+ gfc_conv_expr (&se, otp->expr);
+ expr = se.expr;
+ }
+ properties = tree_cons (NULL_TREE, expr, properties);
}
break;
case CTX_PROPERTY_ID:
if (os->score)
{
- gfc_se se;
- gfc_init_se (&se, NULL);
- gfc_conv_expr (&se, os->score);
+ tree expr = NULL_TREE;
+ if (conv_expr_p)
+ {
+ gfc_se se;
+ gfc_init_se (&se, NULL);
+ gfc_conv_expr (&se, os->score);
+ expr = se.expr;
+ }
properties = tree_cons (get_identifier (" score"),
- se.expr, properties);
+ expr, properties);
}
selectors = tree_cons (get_identifier (os->trait_selector_name),
return metadirective_tree;
}
+
+bool gfc_skip_omp_metadirective_clause (gfc_omp_metadirective_clause *clause)
+{
+ tree selector = gfc_trans_omp_set_selector (clause->selectors,
+ clause->where, false);
+
+ return omp_context_selector_matches (selector, true) == 0;
+}
}
#define DELAY_METADIRECTIVES_AFTER_LTO { \
- if (metadirective_p && !(cfun->curr_properties & PROP_gimple_lomp_dev)) \
- return -1; \
+ if (metadirective_p \
+ && !(cfun && cfun->curr_properties & PROP_gimple_lomp_dev)) \
+ return -1; \
}
/* Return 1 if context selector matches the current OpenMP context, 0
+2022-02-11 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * gfortran.dg/gomp/metadirective-8.f90: New.
+
2022-01-28 Kwok Cheung Yeung <kcy@codesourcery.com>
* c-c++-common/gomp/metadirective-4.c (main): Add expected warning.
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-original" }
+
+program test
+ integer :: i
+ integer, parameter :: N = 100
+ integer :: sum = 0
+
+ ! The compiler should never consider a situation where both metadirectives
+ ! match. If it does, then the nested metadirective would be an error
+ ! as it is not a loop-nest as per the OpenMP specification.
+
+ !$omp metadirective when (implementation={vendor("ibm")}: &
+ !$omp& target teams distribute)
+ !$omp metadirective when (implementation={vendor("gnu")}: parallel do)
+ do i = 1, N
+ sum = sum + i
+ end do
+end program
+
+! { dg-final { scan-tree-dump-not "when \\(implementation vendor \"ibm\"\\):" "original" } }
+! { dg-final { scan-tree-dump-times "when \\(implementation vendor \"gnu\"\\):" 1 "original" } }