On 06/05/13 16:18:52, Jan Hubicka wrote:
> Hi,
> this patch deals with C++ keyed methods and explicit instantiations.
> Currently> C++ calls mark_used that ultimately sets force_output
> on the functions.  This is equivalent to attribute ((used))
> on the function/variable and it is bit too strong.
> [...]

This patch leads to in ICE on the GUPC branch after attempting
a merge from the trunk.  This may be because GUPC is attempting
to write to the (assembler) output too early, or because
some additional tree meta data needs to be set before the
cgraph-related pass is run.

I'd appreciate your suggestions on how to best make this work
within the new scheme of things.

As background, in certain situations GUPC generates initialization
code that is run before main() is called.  This initialization code
is run after the UPC runtime has set up things like shared memory.
The actual program initial entry point (main) is in the runtime.
GCC's constructors won't do the job here because constructors are
run _before_ the runtime's main() entry point is called.

The ICE (in debug builds with checks enabled) is shown below.

test25.upc:91:1: internal compiler error: in decide_is_symbol_needed, at
cgraphunit.c:230


This failure occurs in tests that require active initialization of shared
variables or static variables that are initialized with expressions involving
the addresses of UPC shared variables.

This assertion is failing:

227 /* Double check that no one output the function into assembly file
228 early. */
229 gcc_checking_assert (!DECL_ASSEMBLER_NAME_SET_P (decl)
230 || !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME

The failure is a result of this patch:
http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00240.html [^]

It was committed as:
r199695 | hubicka | 2013-06-05 07:15:31 -0700 (Wed, 05 Jun 2013)

The reason that this fails is that GNU UPC has the following code in
gcc/upc/upc-act.c:

/* Build a function that will be called by the UPC runtime
   to initialize UPC shared variables.  STMT_LIST is a
   list of initialization statements.  */

static void
upc_build_init_func (const tree stmt_list)
{
[...]
  finish_function ();
  gcc_assert (DECL_RTL (init_func));
  mark_decl_referenced (init_func);
  DECL_PRESERVE_P (init_func) = 1;
  upc_init_array_section =
    get_section (UPC_INIT_ARRAY_SECTION_NAME, 0, NULL);
  init_func_symbol = XEXP (DECL_RTL (init_func), 0);
  assemble_addr_to_section (init_func_symbol, upc_init_array_section);
}

See:
http://gcc.gnu.org/viewcvs/gcc/branches/gupc/gcc/upc/upc-act.c?revision=197503&view=markup
 (near line 1448).

The function upc_build_init_func() is called after the entire compilation unit
has been compiled. It is called from upc_write_global_declarations() which is
called from c_common_parse_file(), just after parsing the main source file.

1054 void
1055 c_common_parse_file (void)
1056 {
1057   unsigned int i;
1058 
1059   i = 0;
1060   for (;;)
1061     {
1062       c_finish_options ();
1063       pch_init ();
1064       push_file_scope ();
1065       c_parse_file ();
1066       /* Generate UPC global initialization code, if required.  */
1067       if (c_dialect_upc ())
1068         upc_write_global_declarations ();
1069       pop_file_scope ();

See:
http://gcc.gnu.org/viewcvs/gcc/branches/gupc/gcc/c-family/c-opts.c?revision=198453&view=markup
 (near line 1068).

It seems that GUPC may be calling assemble_addr_to_section() too early and that
some other method of locating the UPC shared data related initialization into
the UPC "upc_init_array" section needs to be implemented.  Either that,
or something needs to be set in the function's tree node to indicate
that no further special handling is needed.  Please advise.

Thanks,
- Gary

Reply via email to