On 3/25/25 11:18, Thomas Schwinge wrote:
Hi Tom!
On 2022-03-22T14:41:46+0100, Tom de Vries via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
Starting with ptx isa version 6.3, a ptx directive .alias is available.
Regarding the following item specifically:
Unreferenced aliases are not emitted (these can occur f.i. when inlining a
call to an alias). This avoids driver link error "Internal error: reference
to deleted section".
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
+void
+nvptx_asm_output_def_from_decls (FILE *stream, tree name, tree value)
+{
+ [...]
+ if (!cgraph_node::get (name)->referred_to_p ())
+ /* Prevent "Internal error: reference to deleted section". */
+ return;
+ [...]
+}
I understand the high-level rationale (PR105019) behind this early
return, but I'm curious why you chose cgraph 'referred_to_p ()' here,
instead of 'TREE_USED', or 'TREE_SYMBOL_REFERENCED' (on identifier), or
some such? (All untested.) Is there any specific reason that you
remember, or did it just happen to do the right thing?
Hi Thomas,
sorry, I don't remember, my best guess is that it happened to DTRT.
In an offloading test case (PR106445), I'm running into the case that a
C++ constructor alias gets called (via 'nvptx_output_call_insn', and per
that one's 'assemble_name' call, 'TREE_SYMBOL_REFERENCED' gets set, for
example) -- but that alias isn't '[cgraph]->referred_to_p ()', so no
PTX '.alias' gets emitted, resulting in link failure. To make that work,
I might just add '|| TREE_SYMBOL_REFERENCED ([identifier])' next to the
existing cgraph 'referred_to_p ()', but I'd like to understand this
better. For example, is it actually the very problem that this alias
isn't cgraph 'referred_to_p ()', but it should it be? (I have not much
clue about the cgraph machinery generally, and even less about the
applicability of it/of its state in offloading compilation,
specifically.)
Grepping though the source code for referred_to_p, I see that it is
sometimes used in conjunction with needed_p. So I wonder if that one
returns true for the case you're describing.
Thanks,
- Tom