[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-09-17 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #9 from CVS Commits  ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:777fa0a232a6bfc7ed3827f35322ec740fe714e9

commit r8-10457-g777fa0a232a6bfc7ed3827f35322ec740fe714e9
Author: Jakub Jelinek 
Date:   Wed Mar 4 12:59:04 2020 +0100

inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888]

In the following testcase we emit wrong debug info for the karg
parameter in the DW_TAG_inlined_subroutine into main.
The problem is that the karg PARM_DECL is DECL_BY_REFERENCE and thus
in the IL has const K & type, but in the source just const K.
When the function is inlined, we create a VAR_DECL for it, but don't
set DECL_BY_REFERENCE, so when emitting DW_AT_location, we treat it like
a const K & typed variable, but it has DW_AT_abstract_origin which has
just the const K type and thus the debugger thinks the variable has
const K type.

Fixed by copying the DECL_BY_REFERENCE flag.  Not doing it in
copy_decl_for_dup_finish, because copy_decl_no_change already copies
that flag through copy_node and in copy_result_decl_to_var it is
undesirable, as we handle DECL_BY_REFERENCE in that case instead
by changing the type.

2020-03-04  Jakub Jelinek  

PR debug/93888
* tree-inline.c (copy_decl_to_var): Copy DECL_BY_REFERENCE flag.

* g++.dg/guality/pr93888.C: New test.

(cherry picked from commit d2a810ee83e2952bf351498cecf8f5db28860a24)

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-17 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #8 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:d2a810ee83e2952bf351498cecf8f5db28860a24

commit r9-8386-gd2a810ee83e2952bf351498cecf8f5db28860a24
Author: Jakub Jelinek 
Date:   Wed Mar 4 12:59:04 2020 +0100

inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888]

In the following testcase we emit wrong debug info for the karg
parameter in the DW_TAG_inlined_subroutine into main.
The problem is that the karg PARM_DECL is DECL_BY_REFERENCE and thus
in the IL has const K & type, but in the source just const K.
When the function is inlined, we create a VAR_DECL for it, but don't
set DECL_BY_REFERENCE, so when emitting DW_AT_location, we treat it like
a const K & typed variable, but it has DW_AT_abstract_origin which has
just the const K type and thus the debugger thinks the variable has
const K type.

Fixed by copying the DECL_BY_REFERENCE flag.  Not doing it in
copy_decl_for_dup_finish, because copy_decl_no_change already copies
that flag through copy_node and in copy_result_decl_to_var it is
undesirable, as we handle DECL_BY_REFERENCE in that case instead
by changing the type.

2020-03-04  Jakub Jelinek  

PR debug/93888
* tree-inline.c (copy_decl_to_var): Copy DECL_BY_REFERENCE flag.

* g++.dg/guality/pr93888.C: New test.

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #7 from Jakub Jelinek  ---
Yeah, I'm considering a backport, but didn't want to rush it into 9.3, want to
wait a few weeks.

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Richard Biener  ---
Fixed.  Technically not a regression but it looks safe to backport if there's
desire (I've pushed it to our LTS gcc 7 flavor).

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-04 Thread mgulick at mathworks dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #5 from Mike Gulick  ---
Thanks Jakub!  I can confirm that this fixes the issue for me.

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-04 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:64ba6d17022eeb65f56f0b141c2640f9ab938f97

commit r10-7014-g64ba6d17022eeb65f56f0b141c2640f9ab938f97
Author: Jakub Jelinek 
Date:   Wed Mar 4 12:59:04 2020 +0100

inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888]

In the following testcase we emit wrong debug info for the karg
parameter in the DW_TAG_inlined_subroutine into main.
The problem is that the karg PARM_DECL is DECL_BY_REFERENCE and thus
in the IL has const K & type, but in the source just const K.
When the function is inlined, we create a VAR_DECL for it, but don't
set DECL_BY_REFERENCE, so when emitting DW_AT_location, we treat it like
a const K & typed variable, but it has DW_AT_abstract_origin which has
just the const K type and thus the debugger thinks the variable has
const K type.

Fixed by copying the DECL_BY_REFERENCE flag.  Not doing it in
copy_decl_for_dup_finish, because copy_decl_no_change already copies
that flag through copy_node and in copy_result_decl_to_var it is
undesirable, as we handle DECL_BY_REFERENCE in that case instead
by changing the type.

2020-03-04  Jakub Jelinek  

PR debug/93888
* tree-inline.c (copy_decl_to_var): Copy DECL_BY_REFERENCE flag.

* g++.dg/guality/pr93888.C: New test.

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #3 from Jakub Jelinek  ---
--- gcc/tree-inline.c.jj2020-02-07 19:11:57.444981885 +0100
+++ gcc/tree-inline.c   2020-03-03 13:27:57.811046011 +0100
@@ -5929,6 +5929,7 @@ copy_decl_to_var (tree decl, copy_body_d
   TREE_READONLY (copy) = TREE_READONLY (decl);
   TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl);
   DECL_GIMPLE_REG_P (copy) = DECL_GIMPLE_REG_P (decl);
+  DECL_BY_REFERENCE (copy) = DECL_BY_REFERENCE (decl);

   return copy_decl_for_dup_finish (id, decl, copy);
 }

fixes that, but will need to see what it will that do e.g. to OpenMP/OpenACC...

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-03-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

--- Comment #2 from Jakub Jelinek  ---
The location looks fine.
The issue is that the func1_k argument is turned into a reference
(DECL_BY_REFERENCE).
In the *.optimized dump we have:
  const struct K & restrict func1_k;
...
  K::K (, _k);
  # DEBUG func1_k => 
  _8 = D.2368.m_storage[0];
  _9 = _8 == 67;

   :
:
  _10 = _9;

   :
  # DEBUG func1_k => NULL
and in *.final:
(note 43 12 50 2 (var_location func1_k (plus:DI (reg/f:DI 6 bp)
(const_int -8 [0xfff8]))) NOTE_INSN_VAR_LOCATION)
which matches that, bp - 8 is what is passed to the copy constructor.
But for the func1_k VAR_DECL, we don't emit type of reference to const K, but
just use
.uleb128 0x10   # (DIE (0xfb) DW_TAG_formal_parameter)
.long   0x14c   # DW_AT_abstract_origin
.long   .LLST0  # DW_AT_location
and the abstract origin has type const K.
I guess we should mark such vars DECL_BY_REFERENCE if their abstract origin is
DECL_BY_REFERENCE.

[Bug debug/93888] Incorrect DW_AT_location generated for copy-constructed function argument

2020-02-24 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93888

Richard Biener  changed:

   What|Removed |Added

   Keywords||wrong-debug
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-02-24
 CC||jakub at gcc dot gnu.org,
   ||rguenth at gcc dot gnu.org
 Ever confirmed|0   |1
  Known to fail||7.5.0

--- Comment #1 from Richard Biener  ---
Confirmed.