]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-inline.c (remap_gimple_stmt): Force input_location on the new statement if id...
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 28 Jun 2018 06:21:13 +0000 (06:21 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 28 Jun 2018 06:21:13 +0000 (06:21 +0000)
* tree-inline.c (remap_gimple_stmt): Force input_location on the new
statement if id->reset_location is true.
(copy_edges_for_bb): Do not set goto_locus on the new edges if
id->reset_location is true.
(copy_phis_for_bb): Force input_location on the arguments if
id->reset_location is true.
(expand_call_inline): Set id->reset_location if DECL_IGNORED_P
is set on the function to be inlined.
* tree-inline.h (struct copy_body_data): Move remapping_type_depth and
prevent_decl_creation_for_types fields up and add reset_location field.

From-SVN: r262207

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/debug15.adb [new file with mode: 0644]
gcc/tree-inline.c
gcc/tree-inline.h

index 1059443ce7f73534cd912501e2ef15e9141fdb01..91ccb225b315d6f937573e50a0eb7dbe9a4866e6 100644 (file)
@@ -1,3 +1,16 @@
+2018-06-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-inline.c (remap_gimple_stmt): Force input_location on the new
+       statement if id->reset_location is true.
+       (copy_edges_for_bb): Do not set goto_locus on the new edges if
+       id->reset_location is true.
+       (copy_phis_for_bb): Force input_location on the arguments if
+       id->reset_location is true.
+       (expand_call_inline): Set id->reset_location if DECL_IGNORED_P
+       is set on the function to be inlined.
+       * tree-inline.h (struct copy_body_data): Move remapping_type_depth and
+       prevent_decl_creation_for_types fields up and add reset_location field.
+
 2018-06-27  Stephan Bergmann  <sbergman@redhat.com>
 
        * doc/invoke.texi (Debugging Options): Add -gsplit-dwarf.
index 3b33d2051f004075258a9a557ba3d51a179de231..1350260009487131b967489ab1ce03edfd2dcce7 100644 (file)
@@ -1,3 +1,7 @@
+2018-06-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/debug15.adb: New test.
+
 2018-06-27  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/86329
@@ -5,8 +9,6 @@
 
 2018-06-27  Carl Love  <cel@us.ibm.com>
 
-Add test case that was supposed to be added in commit 255556 on 2017-12-11.
-
        * gcc.target/vsx-vector-abss.c: New file to test vec_abss.
 
 2018-06-27 Tamar Christina  <tamar.christina@arm.com>
diff --git a/gcc/testsuite/gnat.dg/debug15.adb b/gcc/testsuite/gnat.dg/debug15.adb
new file mode 100644 (file)
index 0000000..75470e3
--- /dev/null
@@ -0,0 +1,23 @@
+-- { dg-do compile }
+-- { dg-options "-g1" }
+
+procedure Debug15 is
+
+   type Shape is abstract tagged record
+      S : Integer;
+   end record;
+
+   type Rectangle is new Shape with record
+      R : Integer;
+   end record;
+
+   X : Integer;
+
+   R: Rectangle := (1, 2);
+   S: Shape'Class := R;
+
+begin
+   X := 12;
+end;
+
+-- { dg-final { scan-assembler-not "loc 2" } }
index c39a8457e001c13ba0d681ccc76171d1cfcd82d5..427ef959740b10d8aebfc33976a7266008fbb0da 100644 (file)
@@ -1630,6 +1630,8 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
            = gimple_build_debug_bind (gimple_debug_bind_get_var (stmt),
                                       gimple_debug_bind_get_value (stmt),
                                       stmt);
+         if (id->reset_location)
+           gimple_set_location (copy, input_location);
          id->debug_stmts.safe_push (copy);
          gimple_seq_add_stmt (&stmts, copy);
          return stmts;
@@ -1640,6 +1642,8 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
                           (gimple_debug_source_bind_get_var (stmt),
                            gimple_debug_source_bind_get_value (stmt),
                            stmt);
+         if (id->reset_location)
+           gimple_set_location (copy, input_location);
          id->debug_stmts.safe_push (copy);
          gimple_seq_add_stmt (&stmts, copy);
          return stmts;
@@ -1653,6 +1657,8 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
            return stmts;
 
          gdebug *copy = as_a <gdebug *> (gimple_copy (stmt));
+         if (id->reset_location)
+           gimple_set_location (copy, input_location);
          id->debug_stmts.safe_push (copy);
          gimple_seq_add_stmt (&stmts, copy);
          return stmts;
@@ -1751,6 +1757,9 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
       gimple_set_block (copy, *n);
     }
 
+  if (id->reset_location)
+    gimple_set_location (copy, input_location);
+
   /* Debug statements ought to be rebuilt and not copied.  */
   gcc_checking_assert (!is_gimple_debug (copy));
 
@@ -2178,7 +2187,8 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
        new_edge
          = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags);
        new_edge->probability = old_edge->probability;
-       new_edge->goto_locus = remap_location (locus, id);
+       if (!id->reset_location)
+         new_edge->goto_locus = remap_location (locus, id);
       }
 
   if (bb->index == ENTRY_BLOCK || bb->index == EXIT_BLOCK)
@@ -2375,7 +2385,10 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
                      inserted = true;
                    }
                  locus = gimple_phi_arg_location_from_edge (phi, old_edge);
-                 locus = remap_location (locus, id);
+                 if (id->reset_location)
+                   locus = input_location;
+                 else
+                   locus = remap_location (locus, id);
                  add_phi_arg (new_phi, new_arg, new_edge, locus);
                }
            }
@@ -4499,8 +4512,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
       prepend_lexical_block (gimple_block (stmt), id->block);
     }
 
-  /* Local declarations will be replaced by their equivalents in this
-     map.  */
+  /* Local declarations will be replaced by their equivalents in this map.  */
   st = id->decl_map;
   id->decl_map = new hash_map<tree, tree>;
   dst = id->debug_map;
@@ -4509,6 +4521,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
   /* Record the function we are about to inline.  */
   id->src_fn = fn;
   id->src_cfun = DECL_STRUCT_FUNCTION (fn);
+  id->reset_location = DECL_IGNORED_P (fn);
   id->call_stmt = call_stmt;
 
   /* When inlining into an OpenMP SIMD-on-SIMT loop, arrange for new automatic
index faeca2fec3eddcb00479094340c06299bcfbe97f..29caab7115476f6edb509a54743cf4cfa4f0c8a6 100644 (file)
@@ -80,6 +80,9 @@ struct copy_body_data
      is not.  */
   gcall *call_stmt;
 
+  /* > 0 if we are remapping a type currently.  */
+  int remapping_type_depth;
+
   /* Exception landing pad the inlined call lies in.  */
   int eh_lp_nr;
 
@@ -110,11 +113,14 @@ struct copy_body_data
   /* True if this statement will need to be regimplified.  */
   bool regimplify;
 
-  /* True if trees should not be unshared.  */
+  /* True if trees may not be unshared.  */
   bool do_not_unshare;
 
-  /* > 0 if we are remapping a type currently.  */
-  int remapping_type_depth;
+  /* True if new declarations may not be created during type remapping.  */
+  bool prevent_decl_creation_for_types;
+
+  /* True if the location information will need to be reset.  */
+  bool reset_location;
 
   /* A function to be called when duplicating BLOCK nodes.  */
   void (*transform_lang_insert_block) (tree);
@@ -145,9 +151,6 @@ struct copy_body_data
   /* A list of addressable local variables remapped into the caller
      when inlining a call within an OpenMP SIMD-on-SIMT loop.  */
   vec<tree> *dst_simt_vars;
-
-  /* Do not create new declarations when within type remapping.  */
-  bool prevent_decl_creation_for_types;
 };
 
 /* Weights of constructions for estimate_num_insns.  */