]> git.ipfire.org Git - thirdparty/gcc.git/commit
cgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk ...
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Feb 2023 10:05:27 +0000 (11:05 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 3 May 2023 12:52:43 +0000 (14:52 +0200)
commitf1789989ca265abaa246592cd4223cc3ca89b361
treefb8704d2674f7cb2d90241a9743bfa7942a4b975
parent8f8472f3119751df3b4906bbd08fdad74ef63f33
cgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk [PR108854]

The following testcase ICEs on x86_64-linux with -m32.  The problem is
we create an artificial thunk and because of -fPIC, ia32 and thunk
destination which doesn't bind locally can't use a mi thunk.
The ICE is because during expansion to RTL we see SSA_NAME for a PARM_DECL,
but the PARM_DECL doesn't have DECL_CONTEXT of the current function.
This is because duplicate_thunk_for_node creates a new DECL_ARGUMENTS chain
only if some arguments need modification.

The following patch fixes it by copying the DECL_ARGUMENTS list even if
the arguments can stay as is, to update DECL_CONTEXT on them.  While for
mi thunks it doesn't really matter because we don't use those arguments
in any way, for other thunks it is important.

2023-02-23  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/108854
* cgraphclones.c (duplicate_thunk_for_node): If no parameter
changes are needed, copy at least DECL_ARGUMENTS PARM_DECL
nodes and adjust their DECL_CONTEXT.

* g++.dg/opt/pr108854.C: New test.

(cherry picked from commit 2f1691be517fcdcabae9cd671ab511eb0e08b1d5)
gcc/cgraphclones.c
gcc/testsuite/g++.dg/opt/pr108854.C [new file with mode: 0644]