diff mbox

c++/70594 debug info differences

Message ID 570D16D8.9000002@acm.org
State New
Headers show

Commit Message

Nathan Sidwell April 12, 2016, 3:40 p.m. UTC
On 04/12/16 11:19, Jakub Jelinek wrote:
> On Tue, Apr 12, 2016 at 10:53:22AM -0400, Jason Merrill wrote:
>> It doesn't seem that dangerous to me.  The decls are only used within
>> constexpr evaluation, they never escape.
>
> The uids can be used in hashing, folding, for the various on the side
> tables (value-expr, debug-expr, ...).

FWIW this proof-of-concept patch showed no testsuite regressions.

nathan
diff mbox

Patch

Index: tree.c
===================================================================
--- tree.c	(revision 234902)
+++ tree.c	(working copy)
@@ -1128,6 +1128,8 @@  free_node (tree node)
 /* Return a new node with the same contents as NODE except that its
    TREE_CHAIN, if it has one, is zero and it has a fresh uid.  */
 
+bool clone_uid;
+
 tree
 copy_node_stat (tree node MEM_STAT_DECL)
 {
@@ -1149,7 +1151,9 @@  copy_node_stat (tree node MEM_STAT_DECL)
 
   if (TREE_CODE_CLASS (code) == tcc_declaration)
     {
-      if (code == DEBUG_EXPR_DECL)
+      if (clone_uid)
+	DECL_UID (t) = DECL_UID (node);
+      else if (code == DEBUG_EXPR_DECL)
 	DECL_UID (t) = --next_debug_decl_uid;
       else
 	{
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 234902)
+++ tree-inline.c	(working copy)
@@ -6100,6 +6100,18 @@  build_duplicate_type (tree type)
   return type;
 }
 
+static tree
+copy_decl_no_change_uid (tree decl, copy_body_data *id)
+{
+  extern bool clone_uid;
+  
+  clone_uid = true;
+  tree r = copy_decl_no_change (decl, id);
+  clone_uid = false;
+
+  return r;
+}
+
 /* Unshare the entire DECL_SAVED_TREE of FN and return the remapped
    parameters and RESULT_DECL in PARMS and RESULT.  Used by C++ constexpr
    evaluation.  */
@@ -6120,7 +6132,7 @@  copy_fn (tree fn, tree& parms, tree& res
   id.src_cfun = DECL_STRUCT_FUNCTION (fn);
   id.decl_map = &decl_map;
 
-  id.copy_decl = copy_decl_no_change;
+  id.copy_decl = copy_decl_no_change_uid;
   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   id.transform_new_cfg = false;
   id.transform_return_to_modify = false;