Message ID | ZaEOgF4jwjfK6QwE@tucnak |
---|---|
State | New |
Headers | show |
Series | varasm: Fix up process_pending_assemble_externals [PR113182] | expand |
On Fri, 12 Jan 2024, Jakub Jelinek wrote: > Hi! > > John reported that on HP-UX we no longer emit needed external libcalls. > > The problem is that we didn't strip name encoding when looking up > the identifiers in assemble_external_libcall and > process_pending_assemble_externals, while > assemble_name_resolve does that: > const char *real_name = targetm.strip_name_encoding (name); > tree id = maybe_get_identifier (real_name); > > if (id) > { > ... > mark_referenced (id); > The intention is that assemble_external_libcall ensures the IDENTIFIER > exists for the external libcall, then for actually emitted calls > assemble_name_resolve sees those IDENTIFIERS and sets TREE_SYMBOL_REFERENCED > on them and finally process_pending_assemble_externals looks the > IDENTIFIER up again and checks its TREE_SYMBOL_REFERENCED. > > But without the strip_name_encoding call, they can look up different > identifiers and those are likely never used. > > In the PR, John was discussing whether get_identifier or > maybe_get_identifier should be used, I believe in assemble_external_libcall > we definitely want to use get_identifier, we need an IDENTIFIER allocated > so that it can be actually tracked, in process_pending_assemble_externals > it doesn't matter, the IDENTIFIER should be already created. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk? OK. > 2024-01-12 John David Anglin <danglin@gcc.gnu.org> > Jakub Jelinek <jakub@redhat.com> > > PR middle-end/113182 > * varasm.cc (process_pending_assemble_externals, > assemble_external_libcall): Use targetm.strip_name_encoding > before calling get_identifier. > > --- gcc/varasm.cc.jj 2024-01-08 21:56:04.968516120 +0100 > +++ gcc/varasm.cc 2024-01-11 18:44:19.171399167 +0100 > @@ -2543,7 +2543,8 @@ process_pending_assemble_externals (void > for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1)) > { > rtx symbol = XEXP (list, 0); > - tree id = get_identifier (XSTR (symbol, 0)); > + const char *name = targetm.strip_name_encoding (XSTR (symbol, 0)); > + tree id = get_identifier (name); > if (TREE_SYMBOL_REFERENCED (id)) > targetm.asm_out.external_libcall (symbol); > } > @@ -2631,7 +2632,8 @@ assemble_external_libcall (rtx fun) > reference to it will mark its tree node as referenced, via > assemble_name_resolve. These are eventually emitted, if > used, in process_pending_assemble_externals. */ > - get_identifier (XSTR (fun, 0)); > + const char *name = targetm.strip_name_encoding (XSTR (fun, 0)); > + get_identifier (name); > pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun, > pending_libcall_symbols); > } > > Jakub > >
--- gcc/varasm.cc.jj 2024-01-08 21:56:04.968516120 +0100 +++ gcc/varasm.cc 2024-01-11 18:44:19.171399167 +0100 @@ -2543,7 +2543,8 @@ process_pending_assemble_externals (void for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1)) { rtx symbol = XEXP (list, 0); - tree id = get_identifier (XSTR (symbol, 0)); + const char *name = targetm.strip_name_encoding (XSTR (symbol, 0)); + tree id = get_identifier (name); if (TREE_SYMBOL_REFERENCED (id)) targetm.asm_out.external_libcall (symbol); } @@ -2631,7 +2632,8 @@ assemble_external_libcall (rtx fun) reference to it will mark its tree node as referenced, via assemble_name_resolve. These are eventually emitted, if used, in process_pending_assemble_externals. */ - get_identifier (XSTR (fun, 0)); + const char *name = targetm.strip_name_encoding (XSTR (fun, 0)); + get_identifier (name); pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun, pending_libcall_symbols); }