Introduce instance discriminators
authorAlexandre Oliva <oliva@adacore.com>
Tue, 31 Jul 2018 21:19:13 +0000 (21:19 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 31 Jul 2018 21:19:13 +0000 (21:19 +0000)
commitfa6fd7b7afece6e0cfe197c9419ea3346d3c60b2
treef227c6802b9656b6bc7d3b3f090e9b9d78f1bb4b
parente540ccc0e281a6e30c14e55b39334db27e55b3bf
Introduce instance discriminators

With -gnateS, the Ada compiler sets itself up to output discriminators
for different instantiations of generics, but the middle and back ends
have lacked support for that.  This patch introduces the missing bits,
translating the GNAT-internal representation of the per-file instance
map to an instance_table that maps decls to instance discriminators.

From: Alexandre Oliva  <oliva@adacore.com>, Olivier Hainque  <hainque@adacore.com>
for  gcc/ChangeLog

* debug.h (decl_to_instance_map_t): New type.
(decl_to_instance_map): Declare.
(maybe_create_decl_to_instance_map): New inline function.
     * final.c (bb_discriminator, last_bb_discriminator): New statics,
     to track basic block discriminators.
     (final_start_function_1): Initialize them.
     (final_scan_insn_1): On NOTE_INSN_BASIC_BLOCK, track
bb_discriminator.
(decl_to_instance_map): New variable.
(map_decl_to_instance, maybe_set_discriminator): New functions.
     (notice_source_line): Set discriminator.

for  gcc/ada/ChangeLog

* trans.c: Include debug.h.
(file_map): New static variable.
(gigi): Set it.  Create decl_to_instance_map when needed.
(Subprogram_Body_to_gnu): Pass gnu_subprog_decl to...
(Sloc_to_locus): ... this.  Add decl parm, map it to instance.
* gigi.h (Sloc_to_locus): Adjust declaration.

for  gcc/testsuite/ChangeLog

* gnat.dg/dinst.adb: New.
* gnat.dg/dinst_pkg.ads, gnat.dg/dinst_pkg.adb: New.

Co-Authored-By: Olivier Hainque <hainque@adacore.com>
From-SVN: r263182
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/trans.c
gcc/debug.h
gcc/final.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/dinst.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/dinst_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/dinst_pkg.ads [new file with mode: 0644]