> Streaming of toplevel extended assembly was missing implementation.
> 
> gcc/ChangeLog:
> 
>       * lto-streamer-in.cc (lto_input_asm_ref): New.
>       (lto_input_toplevel_asms): Input extended asm_node.
>       * lto-streamer-out.cc (lto_output_asm_ref): New.
>       (lto_is_streamable): Add ASM_EXPR.
>       (lto_output_toplevel_asms): Output extended asm_node.

> +/* Output toplevel assembly to OBS.  */
> +
> +void
> +lto_output_asm_ref (struct lto_out_decl_state *decl_state,
> +                 struct lto_output_stream * obs, tree decl)
> +{
> +  gcc_assert (TREE_CODE (decl) == STRING_CST || TREE_CODE (decl) == 
> ASM_EXPR);
decl seeems misnamed here
> +  streamer_write_uhwi_stream
> +     (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM], decl));
> +}
> +
>  /* Return true if EXPR is a tree node that can be written to disk.  */
>  
>  static inline bool
> @@ -384,6 +395,7 @@ lto_is_streamable (tree expr)
>        && code != STATEMENT_LIST
>        && (code == CASE_LABEL_EXPR
>            || code == DECL_EXPR
> +          || code == ASM_EXPR

I see that you add toplevel asm statements to global stream. While this
work, why you don't write trees into section_asm itself?  It seems it is
already constructed uwing create_output_block instead of
create_simple_output_block so this should be possible?

Honza
>            || TREE_CODE_CLASS (code) != tcc_statement);
>  }
>  
> @@ -2560,19 +2572,18 @@ lto_output_toplevel_asms (lto_symtab_encoder_t 
> encoder)
>    char *section_name;
>    struct lto_simple_header_with_strings header;
>  
> -  bool any_asm = false;
> +  unsigned asm_count = 0;
>    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;
> +      asm_count++;
>  
> -  if (!any_asm)
> +  if (!asm_count)
>      return;
>  
>    ob = create_output_block (LTO_section_asm);
>  
> -  /* Make string 0 be a NULL string.  */
> -  streamer_write_char_stream (ob->string_stream, 0);
> -
> +  /* Stream the length.  */
> +  streamer_write_uhwi (ob, asm_count);
>    for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
>      {
>        toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i);
> @@ -2580,19 +2591,11 @@ lto_output_toplevel_asms (lto_symtab_encoder_t 
> encoder)
>        if (!anode)
>       continue;
>  
> -      if (TREE_CODE (anode->asm_str) != STRING_CST)
> -     {
> -       sorry_at (EXPR_LOCATION (anode->asm_str),
> -                 "LTO streaming of toplevel extended %<asm%> "
> -                 "unimplemented");
> -       continue;
> -     }
> -      streamer_write_string_cst (ob, ob->main_stream, anode->asm_str);
> -      streamer_write_hwi (ob, anode->order);
> +      int output_order = *encoder->order_remap->get (anode->order);
> +      lto_output_asm_ref (ob->decl_state, ob->main_stream, anode->asm_str);
> +      streamer_write_hwi (ob, output_order);
>      }
>  
> -  streamer_write_string_cst (ob, ob->main_stream, NULL_TREE);
> -
>    section_name = lto_get_section_name (LTO_section_asm, NULL, 0, NULL);
>    lto_begin_section (section_name, !flag_wpa);
>    free (section_name);
> -- 
> 2.51.1
> 

Reply via email to