mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
lto: Compute partition boundary with asm_nodes
Previous patch added asm_node streaming, so we need to add referenced symbols to partition. asm_nodes must be added to partition before computing the boundary. gcc/ChangeLog: * lto-cgraph.cc (compute_ltrans_boundary): Add symbols referenced from asm_nodes. * lto-streamer-out.cc (lto_output): Move adding asm_nodes to... * passes.cc (ipa_write_summaries): ...here. gcc/testsuite/ChangeLog: * gcc.dg/lto/toplevel-extended-asm-1_0.c: New test. * gcc.dg/lto/toplevel-extended-asm-1_1.c: New test.
This commit is contained in:
@@ -899,6 +899,24 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
|
||||
lto_set_symtab_encoder_encode_initializer (encoder, vnode);
|
||||
create_references (encoder, vnode);
|
||||
}
|
||||
for (lsei = lsei_start (in_encoder); !lsei_end_p (lsei); lsei_next (&lsei))
|
||||
{
|
||||
toplevel_node *tnode = lsei_node (lsei);
|
||||
if (asm_node* node = dyn_cast <asm_node*> (tnode))
|
||||
{
|
||||
symtab_node* ref;
|
||||
for (unsigned i = 0; node->symbols_referenced.iterate (i, &ref); i++)
|
||||
{
|
||||
if (!lto_symtab_encoder_in_partition_p (encoder, ref))
|
||||
{
|
||||
if (cgraph_node* cref = dyn_cast <cgraph_node*> (ref))
|
||||
add_node_to (encoder, cref, false);
|
||||
else if (varpool_node *vref = dyn_cast <varpool_node *> (ref))
|
||||
lto_symtab_encoder_encode (encoder, vref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Pickle in also the initializer of all referenced readonly variables
|
||||
to help folding. Constant pool variables are not shared, so we must
|
||||
pickle those too. */
|
||||
|
||||
@@ -2817,15 +2817,6 @@ lto_output (void)
|
||||
lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder;
|
||||
auto_vec<symtab_node *> symbols_to_copy;
|
||||
|
||||
if (!flag_wpa)
|
||||
{
|
||||
asm_node *anode;
|
||||
for (anode = symtab->first_asm_symbol ();
|
||||
anode;
|
||||
anode = safe_as_a<asm_node*>(anode->next))
|
||||
lto_set_symtab_encoder_in_partition (encoder, anode);
|
||||
}
|
||||
|
||||
create_order_remap (encoder);
|
||||
|
||||
prune_offload_funcs ();
|
||||
|
||||
@@ -2911,6 +2911,11 @@ ipa_write_summaries (void)
|
||||
if (vnode->need_lto_streaming)
|
||||
lto_set_symtab_encoder_in_partition (encoder, vnode);
|
||||
|
||||
asm_node *anode;
|
||||
for (anode = symtab->first_asm_symbol (); anode;
|
||||
anode = safe_as_a<asm_node*> (anode->next))
|
||||
lto_set_symtab_encoder_in_partition (encoder, anode);
|
||||
|
||||
ipa_write_summaries_1 (compute_ltrans_boundary (encoder),
|
||||
flag_generate_offload);
|
||||
|
||||
|
||||
19
gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-1_0.c
Normal file
19
gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-1_0.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* { dg-lto-do link } */
|
||||
/* { dg-lto-options {{-O2 -flto -flto-partition=1to1} } } */
|
||||
|
||||
void asm_fn();
|
||||
void asm_fn_used();
|
||||
|
||||
asm(".global %cc0\n%cc0:" :: ":" (asm_fn));
|
||||
asm(".global %cc0\n%cc0:" :: ":" (asm_fn_used));
|
||||
|
||||
|
||||
__attribute__((noinline))
|
||||
int privatized_fn(int v) { return v + v;}
|
||||
|
||||
extern void call_privatized_fn();
|
||||
|
||||
int main() {
|
||||
privatized_fn (0);
|
||||
call_privatized_fn ();
|
||||
}
|
||||
12
gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-1_1.c
Normal file
12
gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-1_1.c
Normal file
@@ -0,0 +1,12 @@
|
||||
extern void asm_fn_used();
|
||||
|
||||
__attribute__((used))
|
||||
void local_caller() {
|
||||
asm_fn_used();
|
||||
}
|
||||
|
||||
__attribute__((noipa))
|
||||
static void privatized_fn() { asm volatile ("");}
|
||||
asm(".long %cc0" :: "s"(privatized_fn));
|
||||
|
||||
void call_privatized_fn() { privatized_fn();}
|
||||
Reference in New Issue
Block a user