This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][LTO] Fix PR41281, toplevel asms


This streams toplevel asms (which are just STRING_CSTs) as part of
the cgraph.  It works nicely but -fwhopr still ICEs for the testcase.
I must be missing sth obvious here ;)

Queued for testing.

Richard.

2009-09-14  Richard Guenther  <rguenther@suse.de>

	PR lto/41281
	* lto-cgraph.c (output_cgraph): Output toplevel asms.
	(input_cgraph_1): Input toplevel asms.

	* gcc.dg/lto/20090914-2_0.c: New testcase.

Index: lto/gcc/lto-cgraph.c
===================================================================
*** lto.orig/gcc/lto-cgraph.c	2009-09-14 12:15:51.000000000 +0200
--- lto/gcc/lto-cgraph.c	2009-09-14 15:32:39.000000000 +0200
*************** output_cgraph (cgraph_node_set set)
*** 316,321 ****
--- 316,322 ----
    int i, n_nodes;
    bitmap written_decls;
    lto_cgraph_encoder_t encoder;
+   struct cgraph_asm_node *can;
  
    ob = lto_create_simple_output_block (LTO_section_cgraph);
  
*************** output_cgraph (cgraph_node_set set)
*** 373,378 ****
--- 374,391 ----
  
    lto_output_uleb128_stream (ob->main_stream, 0);
  
+   /* Emit toplevel asms.  */
+   for (can = cgraph_asm_nodes; can; can = can->next)
+     {
+       int len = TREE_STRING_LENGTH (can->asm_str);
+       lto_output_uleb128_stream (ob->main_stream, len);
+       for (i = 0; i < len; ++i)
+ 	lto_output_1_stream (ob->main_stream,
+ 			     TREE_STRING_POINTER (can->asm_str)[i]);
+     }
+ 
+   lto_output_uleb128_stream (ob->main_stream, 0);
+ 
    lto_destroy_simple_output_block (ob);
  }
  
*************** input_cgraph_1 (struct lto_file_decl_dat
*** 609,614 ****
--- 622,628 ----
    VEC(cgraph_node_ptr, heap) *nodes = NULL;
    struct cgraph_node *node;
    unsigned i;
+   unsigned HOST_WIDE_INT len;
  
    tag = (enum LTO_cgraph_tags) lto_input_uleb128 (ib);
    while (tag)
*************** input_cgraph_1 (struct lto_file_decl_dat
*** 627,632 ****
--- 641,659 ----
        tag = (enum LTO_cgraph_tags) lto_input_uleb128 (ib);
      }
  
+   /* Input toplevel asms.  */
+   len = lto_input_uleb128 (ib);
+   while (len)
+     {
+       char *str = xmalloc (len + 1);
+       for (i = 0; i < len; ++i)
+ 	str[i] = lto_input_1_unsigned (ib);
+       cgraph_add_asm_node (build_string (len, str));
+       free (str);
+ 
+       len = lto_input_uleb128 (ib);
+     }
+ 
    for (i = 0; VEC_iterate (cgraph_node_ptr, nodes, i, node); i++)
      {
        const int ref = (int) (intptr_t) node->global.inlined_to;
Index: lto/gcc/testsuite/gcc.dg/lto/20090914-2_0.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- lto/gcc/testsuite/gcc.dg/lto/20090914-2_0.c	2009-09-14 15:37:18.000000000 +0200
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-lto-do run { target x86_64-*-* i?86-*-* } } */
+ /* { dg-suppress-ld-options "-fwhopr" } */
+ 
+ /* Doesn't work with -fwhopr yet.  */
+ 
+ asm(".text\n"
+     ".globl main\n"
+     "\t.type main,@function\n"
+     "main:\n"
+     "\txorl %eax, %eax\n"
+     "\tret\n");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]