This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Handle undefined extern vars in output_in_order
- From: Jeff Law <law at redhat dot com>
- To: Alexander Monakov <amonakov at ispras dot ru>, Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jul 2016 12:08:20 -0600
- Subject: Re: [PATCH] Handle undefined extern vars in output_in_order
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LNX.firstname.lastname@example.org> <alpine.LNX.email@example.com> <20160616142524.GA93274@kam.mff.cuni.cz> <alpine.LNX.firstname.lastname@example.org> <20160616152403.GA38925@kam.mff.cuni.cz> <alpine.LNX.email@example.com> <20160616154239.GA416@kam.mff.cuni.cz> <alpine.LNX.firstname.lastname@example.org>
On 06/23/2016 08:45 AM, Alexander Monakov wrote:
I haven't followed this issue at all. So bear with me if I ask a
question you've already answered.
I've discovered that this assert in my patch was too restrictive:
+ if (DECL_HAS_VALUE_EXPR_P (pv->decl))
+ gcc_checking_assert (lookup_attribute ("omp declare target link",
+ DECL_ATTRIBUTES (pv->decl)));
Testing for the nvptx target uncovered that there's another case where a
global variable would have a value expr: emutls. Sorry for not spotting it
earlier (but at least the new assert did its job). I think we should always
skip here over decls that have value-exprs, just like hard-reg vars are
skipped. The following patch does that. Is this still OK?
(bootstrapped/regtested on x86-64)
* cgraphunit.c (cgraph_order_sort_kind): New entry ORDER_VAR_UNDEF.
(output_in_order): Loop over undefined variables too. Output them
via assemble_undefined_decl. Skip variables that correspond to hard
registers or have value-exprs.
* varpool.c (symbol_table::output_variables): Handle undefined
variables together with defined ones.
Is the point here to be able to deduce what symbols are external &
undefined and emit some kind of directive to the assembler in that case?
Avoiding duplicates as well as symbols which may have had originally
looked like external & undefined, but later we find a definition?
The reason I ask someone might be able to simplify a bit of the PA
backend if that's the goal here. The PA (when using the SOM object
format) has similar needs. We solved it by queuing up everything that
might need "importing". Then at the end of the compilation unit, we'd
walk that queue of symbols emitting the proper magic.