Hi! On 2019-08-05T22:51:22+0100, Kwok Cheung Yeung <k...@codesourcery.com> wrote: > On 18/07/2019 10:30 am, Jakub Jelinek wrote: >> On Wed, Jul 17, 2019 at 10:06:07PM +0100, Kwok Cheung Yeung wrote: >>> --- a/gcc/omp-oacc-kernels.c >>> +++ b/gcc/omp-oacc-kernels.c >>> @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see >>> #include "backend.h" >>> #include "target.h" >>> #include "tree.h" >>> +#include "cp/cp-tree.h" >> >> No, you certainly don't want to do this. Use langhooks if needed
ACK. >> though >> that can be only for stuff done before IPA. After IPA, because of LTO FE, >> you >> must not rely on anything that is not in the IL generically. ACK, and this is very early: NEXT_PASS (pass_diagnose_omp_blocks); NEXT_PASS (pass_diagnose_tm_blocks); + NEXT_PASS (pass_omp_oacc_kernels_decompose); NEXT_PASS (pass_lower_omp); > I have modified the patch to use the get_generic_function_decl langhook > to determine whether current_function_decl is an instantiation of a > template (in this case, we don't care what the generic decl is - just > whether the function decl has one). To me, it's not obvious that the original: (DECL_LANG_SPECIFIC (current_function_decl) && DECL_TEMPLATE_INSTANTIATION (current_function_decl))) ... may be replaced with: (lang_hooks.decls.get_generic_function_decl (current_function_decl) != NULL) ..., so thanks, Kwok, that you've figured that out. :-) I've just pushed to master branch commit ccd56db89806a5f6eb3be99fc3b4fe364cf35e98 "In 'gcc/omp-oacc-kernels-decompose.cc', use langhook instead of accessing language-specific decl information", see attached. Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
>From ccd56db89806a5f6eb3be99fc3b4fe364cf35e98 Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung <k...@codesourcery.com> Date: Mon, 5 Aug 2019 22:51:22 +0100 Subject: [PATCH] In 'gcc/omp-oacc-kernels-decompose.cc', use langhook instead of accessing language-specific decl information gcc/ * omp-oacc-kernels-decompose.cc (maybe_build_inner_data_region): Use langhook instead of accessing language-specific decl information. --- gcc/omp-oacc-kernels-decompose.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/omp-oacc-kernels-decompose.cc b/gcc/omp-oacc-kernels-decompose.cc index c585e5d092b..baad1b9a348 100644 --- a/gcc/omp-oacc-kernels-decompose.cc +++ b/gcc/omp-oacc-kernels-decompose.cc @@ -25,7 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "backend.h" #include "target.h" #include "tree.h" -#include "cp/cp-tree.h" +#include "langhooks.h" #include "gimple.h" #include "tree-pass.h" #include "cgraph.h" @@ -792,6 +792,12 @@ static gimple * maybe_build_inner_data_region (location_t loc, gimple *body, tree inner_bind_vars, gimple *inner_cleanup) { + /* Is this an instantiation of a template? (In this case, we don't care what + the generic decl is - just whether the function decl has one.) */ + bool generic_inst_p + = (lang_hooks.decls.get_generic_function_decl (current_function_decl) + != NULL); + /* Build data 'create (var)' clauses for these local variables. Below we will add these to a data region enclosing the entire body of the decomposed kernels region. */ @@ -802,8 +808,7 @@ maybe_build_inner_data_region (location_t loc, gimple *body, next = TREE_CHAIN (v); if (DECL_ARTIFICIAL (v) || TREE_CODE (v) == CONST_DECL - || (DECL_LANG_SPECIFIC (current_function_decl) - && DECL_TEMPLATE_INSTANTIATION (current_function_decl))) + || generic_inst_p) { /* If this is an artificial temporary, it need not be mapped. We move its declaration into the bind inside the data region. -- 2.17.1