On 06/18/13 22:27:51, Steven Bosscher wrote:
> The advice would have to be that the front end should not write out
> anything to the assembler file.
> 
> Why not just emit the function as GIMPLE (even if your stmt_list is
> empty) and let your main() call it?

The initialization function is currently generated in tree form in the
usual way (it will be gimplified when the gimple pass is run).

The code that is being generated is roughly equivalent to:

    static void
    __upc_init_decls (void)
    {
      /* Compiler generated:
         Initialize data related to UPC shared variables.  */
    }

    static void (*const __upc_init_addr) (void)
      __attribute__ ((section ("upc_init_array"))) = __upc_init_decls;

The __upc_init_decls() function is generated on a per file (compilation unit)
basis, if there is UPC related data that needs to be initialized.
Thus, calling it from main() will not be sufficient.  The address
of this function is added to the section named upc_init_array.
Sentinel symbols are added to the section by the inclusion of
a upcrtbegin.o and upcrtend.o file.  This is done by the gupc
command line driver.  The UPC runtime traverses this table
and calls each per file initialization function.

Would you happen to know of any code in GCC that creates a
file scoped variable and initializes, perhaps along the lines
of that shown above?  I should be able to eventually figure
something out, but any pointers/suggestions would be appreciated.

Note that in the longer term it be better not to create a
uniquely named section for this purpose, but that will
require some re-work of the UPC runtime.  For now, I'd like
to find a method that of generating code along the lines
of that shown above.

Thanks,
- Gary

Reply via email to