#include "symtab-thunks.h"
#include "symtab-clones.h"
-/* True when asm nodes has been output. */
-bool asm_nodes_output = false;
-
static void output_cgraph_opt_summary (void);
static void input_cgraph_opt_summary (vec<symtab_node *> nodes);
lto_destroy_simple_output_block (ob);
- /* Emit toplevel asms.
- When doing WPA we must output every asm just once. Since we do not partition asm
- nodes at all, output them to first output. This is kind of hack, but should work
- well. */
- if (!asm_nodes_output && !lto_stream_offload_p)
- {
- asm_nodes_output = true;
- lto_output_toplevel_asms ();
- }
+ /* Emit toplevel asms. */
+ if (!lto_stream_offload_p)
+ lto_output_toplevel_asms (encoder);
output_refs (encoder);
}
/* Emit toplevel asms. */
void
-lto_output_toplevel_asms (void)
+lto_output_toplevel_asms (lto_symtab_encoder_t encoder)
{
struct output_block *ob;
- struct asm_node *can;
char *section_name;
struct lto_simple_header_with_strings header;
- if (!symtab->first_asm_symbol ())
+ bool any_asm = false;
+ for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
+ if (is_a <asm_node*> (lto_symtab_encoder_deref (encoder, i)))
+ any_asm = true;
+
+ if (!any_asm)
return;
ob = create_output_block (LTO_section_asm);
/* Make string 0 be a NULL string. */
streamer_write_char_stream (ob->string_stream, 0);
- for (can = symtab->first_asm_symbol (); can; can = can->next)
+ for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
{
- if (TREE_CODE (can->asm_str) != STRING_CST)
+ toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i);
+ asm_node *anode = dyn_cast <asm_node*> (tnode);
+ if (!anode)
+ continue;
+
+ if (TREE_CODE (anode->asm_str) != STRING_CST)
{
- sorry_at (EXPR_LOCATION (can->asm_str),
+ sorry_at (EXPR_LOCATION (anode->asm_str),
"LTO streaming of toplevel extended %<asm%> "
"unimplemented");
continue;
}
- streamer_write_string_cst (ob, ob->main_stream, can->asm_str);
- streamer_write_hwi (ob, can->order);
+ streamer_write_string_cst (ob, ob->main_stream, anode->asm_str);
+ streamer_write_hwi (ob, anode->order);
}
streamer_write_string_cst (ob, ob->main_stream, NULL_TREE);
{
auto_vec<int> orders;
unsigned i;
- struct asm_node* anode;
encoder->order_remap = new hash_map<int_hash<int, -1, -2>, int>;
unsigned n_nodes = lto_symtab_encoder_size (encoder);
for (i = 0; i < n_nodes; i++)
orders.safe_push (lto_symtab_encoder_deref (encoder, i)->order);
- if (!asm_nodes_output)
- {
- for (anode = symtab->first_asm_symbol (); anode; anode = anode->next)
- orders.safe_push (anode->order);
- }
-
orders.qsort (cmp_int);
int ord = 0;
int last_order = -1;
ord++;
}
}
-
- /* Asm nodes are currently always output only into first partition.
- We can remap already here. */
- if (!asm_nodes_output)
- {
- for (anode = symtab->first_asm_symbol (); anode; anode = anode->next)
- anode->order = *encoder->order_remap->get (anode->order);
- }
}
/* Main entry point from the pass manager. */
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 = anode->next)
+ lto_set_symtab_encoder_in_partition (encoder, anode);
+ }
+
create_order_remap (encoder);
prune_offload_funcs ();
struct lto_output_stream *, tree);
extern tree lto_input_var_decl_ref (lto_input_block *, lto_file_decl_data *);
extern tree lto_input_fn_decl_ref (lto_input_block *, lto_file_decl_data *);
-extern void lto_output_toplevel_asms (void);
+extern void lto_output_toplevel_asms (lto_symtab_encoder_t);
extern void produce_asm (struct output_block *ob);
extern void lto_output ();
extern void produce_asm_for_decls ();
/* In lto-cgraph.cc */
-extern bool asm_nodes_output;
lto_symtab_encoder_t lto_symtab_encoder_new (bool);
int lto_symtab_encoder_encode (lto_symtab_encoder_t, toplevel_node *);
void lto_symtab_encoder_delete (lto_symtab_encoder_t);