]> git.ipfire.org Git - thirdparty/gcc.git/commit
debug/104337 - avoid messing with the abstract origin chain in NRV
authorRichard Biener <rguenther@suse.de>
Thu, 3 Feb 2022 10:20:59 +0000 (11:20 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 21 Apr 2022 12:51:14 +0000 (14:51 +0200)
commitf058e124350d3b19a79b3b7754b2ccab59bec7b1
treeb93068eba598fa54e20d15ebee1fa84cf6b21d64
parente513d5641077d41ff85e6f877f8997e173886cd6
debug/104337 - avoid messing with the abstract origin chain in NRV

The following avoids NRV from massaging DECL_ABSTRACT_ORIGIN after
variable creation since NRV runs _after_ the function was inlined and thus
affects the inlined variables copy indirectly.  We may adjust the abstract
origin of a variable only at the point we create it, not further along the
path since otherwise the (new) invariant that the abstract origin is always
the ultimate origin cannot be maintained.

The intent of what NRV does is OK I guess and it may improve the debug
experience.  But I also notice we do

  SET_DECL_VALUE_EXPR (found, result);
  DECL_HAS_VALUE_EXPR_P (found) = 1;

the code is there since the merge from tree-ssa which added tree-nrv.c.

Jakub added the DECL_VALUE_EXPR in g:938650d8fddb878f623e315f0b7fd94b217efa96
and Jason added the abstract origin setting conditional in g:7716876bbd3a

The follwoing takes the radical approach and remove the attempt
to "optimize" the debug info.

The gdb testsuites show no regressions.

2022-02-03  Richard Biener  <rguenther@suse.de>

PR debug/104337
* tree-nrv.c (pass_nrv::execute): Remove tieing result and found
together via DECL_ABSTRACT_ORIGIN.

* gcc.dg/debug/pr104337.c: New testcase.

(cherry picked from commit 1d5c7584fd6e72bfdbede86cef5ff04ae35f9744)
gcc/testsuite/gcc.dg/debug/pr104337.c [new file with mode: 0644]
gcc/tree-nrv.c