Here's the current status of my work (see appended patch.)

gnat1 can now handle multiple input files as previously
described (produce one assembly and ALI file per input file.)

First tests look very promising. I'm getting noticeable speedups
of when supplying N interrelated bodies in a single call as opposed
to N individual calls to gnat1. Precise measurements will follow.

gcc has a new command line switch, "-multi".
This tells gcc to forward all given input files to a single execution
of the compiler proper, in a similar way as done for "-combine".
For now, the switch is not forwarded to the compilers, i.e. it is
purely a gcc driver switch.
It's not totally functioning yet:
1) invocation of "as" (assembler) is only done for the first file
2) gcc is passing too many switches to the compiler, for example
"-o" (output file) should be suppressed when in multi-source mode.

The Ada backend still has a problem with calls to instantiated
generic subprograms, there is a crash in gigi(), deep in gimplify(),
which only happens in multi-source mode. I can provide the details.

Here are more details:

* gcc.c and lang-specs.h of all languages:
Added a new flag to struct compiler, "multisource".
If nonzero, compiler can deal with multiple source files at once.
For each input file, a corresponding output file is generated.
This is different from "combine", where a single output file is
generated for all input files.
This flag is set to true only for Ada.

* gcc.c:
Added a new command line switch, "-multi".
This tells gcc to forward all given input files to a single execution
of the compiler proper, in a similar way as done for "-combine".
For now, this switch is not forwarded to the backends, i.e. it is
purely a gcc driver switch.

* toplev.c:
1) Had to make realloc_for_line_map() global because when repeatedly
calling linemap_init(), the member "reallocator" is NULL and I
couldn't find a way of setting it to the proper value again.
2) lang_dependent_init(name): When in multi_source mode, changed the
main_input_filename to the given "name" argument.  This change is
responsible for getting a separate assembly file per each input file.
3) do_compile(): When in multi_source mode, loop over in_fnames[],
calling lang_dependent_init(), compile_file(), and finalize() for
each name.

* cgraph.{h,c}, cgraphunit.c:
Added many missing reinitializations that are necessary when calling
compile_file() repeatedly.

* ada/frontend.ad{s,b}:
Changed this procedure into a package with two procedures, Initialize
and Call_Frontend. This was necessary because Initialize is only
once, but Call_Frontend is called per each input file.
ATTENTION: In order for the whole multi-source mechanism to work, atm
it is necessary to comment out line 389 as follows,
 if VM_Target = No_VM then
    null;  --  ATTENTION - THIS IS A TEMPORARY HACK - DO NOT COMMIT !
    --  Exp_Dbug.Qualify_All_Entity_Names;
 end if;
In other words, the qualification of all entity names currently
disturbs the name lookup for repeated runs of semantic analysis.

* ada/lib-load.ad{s,b}:
Added new flag Main_Unit_Previously_Loaded. This is needed because
Units.Increment_Last shall only be called for the first main unit
(further main units are stored in Units.Table(0) therefore no
incrementing is required.)

* ada/{inline,sem,fname-uf}.ad[sb]:
Add procedure Unlock, required for processing of subsequent main
units.

* ada/sem.adb, procedure Initialize: Fix glibc report of double
free() on reinvocation.

* ada/gcc-interface/misc.c:
gnat_parse_file(): Move one-time-only initializations to gnat_init().
gnat_init(): Added call to linemap_init().  Added a new flag,
first_call_to_gnat_init, in order to ensure that one-time-only
initializations are really done only once, even when gnat_init()
it called multiple times.

* ada/gnat1drv.adb:
Ensure that frontend initializations are done only once.
Reformat comments to obey GNAT style checks.
Unlock tables after processing the main unit.

Oliver


On 2009-04-20 at 14:55, Geert Bosch wrote:
> On Apr 20, 2009, at 14:45, Oliver Kellogg wrote:
> >> It would be best to first contemplate what output a single
> >> invocation of the compiler, with multiple compilation units
> >> as arguments, should produce.
> >
> > For an invocation
> > gnat1 a.adb b.adb c.adb
> > , the files a.{s,ali} b.{s,ali} c.{s,ali} are produced.
> 
> The back end is not prepared to produce multiple assembly files.
> The "gcc" driver program also assumes each invocation produces a
> single .s file.
> 
> So, if this is what you want to do, you'd have to address all these
> underlying limitations first.
> 
>    -Geert

Attachment: gnat1_multi_source_compile-1.diff.gz
Description: GNU Zip compressed data

Reply via email to