gcc/
2012-10-08  Tobias Burnus  <burnus@net-b.de>

	* lto-cgraph.c (input_node_opt_summary): Remove unused code.
	* lto-opts.c (append_to_collect_gcc_options): Ditto.
	* lto-symtab.c (lto_cgraph_replace_node): Don't xstrdup string
	which is passed to fprintf.

gcc/lto/
2012-10-08  Tobias Burnus  <burnus@net-b.de>

	* lto-lang.c (lto_register_builtin_type): Avoid useless
	decl creation.
	* lto-object.c (lto_obj_file_open, lto_obj_file_open): Free memory.

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 4f952f5..b23f192 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1510,28 +1510,23 @@ input_node_opt_summary (struct cgraph_node *node,
   if (count)
     node->clone.combined_args_to_skip = BITMAP_GGC_ALLOC ();
   for (i = 0; i < count; i++)
     {
       bit = streamer_read_uhwi (ib_main);
       bitmap_set_bit (node->clone.combined_args_to_skip, bit);
     }
   count = streamer_read_uhwi (ib_main);
   for (i = 0; i < count; i++)
     {
-      int parm_num;
-      tree parm;
       struct ipa_replace_map *map = ggc_alloc_ipa_replace_map ();
 
       VEC_safe_push (ipa_replace_map_p, gc, node->clone.tree_map, map);
-      for (parm_num = 0, parm = DECL_ARGUMENTS (node->symbol.decl); parm_num;
-	   parm = DECL_CHAIN (parm))
-	parm_num --;
       map->parm_num = streamer_read_uhwi (ib_main);
       map->old_tree = NULL;
       map->new_tree = stream_read_tree (ib_main, data_in);
       bp = streamer_read_bitpack (ib_main);
       map->replace_p = bp_unpack_value (&bp, 1);
       map->ref_p = bp_unpack_value (&bp, 1);
     }
   for (e = node->callees; e; e = e->next_callee)
     input_edge_opt_summary (e, ib_main);
   for (e = node->indirect_calls; e; e = e->next_callee)
diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index 668a5ce..8484423 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -37,22 +37,20 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string
    set up by OB, appropriately quoted and separated by spaces
    (if !*FIRST_P).  */
 
 static void
 append_to_collect_gcc_options (struct obstack *ob,
 			       bool *first_p, const char *opt)
 {
   const char *p, *q = opt;
-  if (!first_p)
-    obstack_grow (ob, " ", 1);
   obstack_grow (ob, "'", 1);
   while ((p = strchr (q, '\'')))
     {
       obstack_grow (ob, q, p - q);
       obstack_grow (ob, "'\\''", 4);
       q = ++p;
     }
   obstack_grow (ob, q, strlen (q));
   obstack_grow (ob, "'", 1);
   *first_p = false;
diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c
index 25c0b22..659a68b 100644
--- a/gcc/lto-symtab.c
+++ b/gcc/lto-symtab.c
@@ -39,22 +39,22 @@ static void
 lto_cgraph_replace_node (struct cgraph_node *node,
 			 struct cgraph_node *prevailing_node)
 {
   struct cgraph_edge *e, *next;
   bool compatible_p;
 
   if (cgraph_dump_file)
     {
       fprintf (cgraph_dump_file, "Replacing cgraph node %s/%i by %s/%i"
  	       " for symbol %s\n",
-	       xstrdup (cgraph_node_name (node)), node->uid,
-	       xstrdup (cgraph_node_name (prevailing_node)),
+	       cgraph_node_name (node), node->uid,
+	       cgraph_node_name (prevailing_node),
 	       prevailing_node->uid,
 	       IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name)
 		 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->symbol.decl)))));
     }
 
   /* Merge node flags.  */
   if (node->symbol.force_output)
     cgraph_mark_force_output_node (prevailing_node);
   if (node->symbol.address_taken)
     {
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index 280d883..edfab74 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -1072,24 +1072,27 @@ static tree
 lto_builtin_function (tree decl)
 {
   return decl;
 }
 
 static void
 lto_register_builtin_type (tree type, const char *name)
 {
   tree decl;
 
-  decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier (name), type);
-  DECL_ARTIFICIAL (decl) = 1;
   if (!TYPE_NAME (type))
-    TYPE_NAME (type) = decl;
+    {
+      decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
+			 get_identifier (name), type);
+      DECL_ARTIFICIAL (decl) = 1;
+      TYPE_NAME (type) = decl;
+    }
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
 
 /* Build nodes that would have be created by the C front-end; necessary
    for including builtin-types.def and ultimately builtins.def.  */
 
 static void
 lto_build_c_type_nodes (void)
 {
diff --git a/gcc/lto/lto-object.c b/gcc/lto/lto-object.c
index daf3bd0..ce24400 100644
--- a/gcc/lto/lto-object.c
+++ b/gcc/lto/lto-object.c
@@ -126,21 +126,24 @@ lto_obj_file_open (const char *filename, bool writable)
       if (attrs == NULL)
 	goto fail_errmsg;
 
       if (saved_attributes == NULL)
 	saved_attributes = attrs;
       else
 	{
 	  errmsg = simple_object_attributes_merge (saved_attributes, attrs,
 						   &err);
 	  if (errmsg != NULL)
-	    goto fail_errmsg;
+	    {
+	      free (attrs);
+	      goto fail_errmsg;
+	    }
 	}
     }
   else
     {
       gcc_assert (saved_attributes != NULL);
       lo->sobj_w = simple_object_start_write (saved_attributes,
 					      LTO_SEGMENT_NAME,
 					      &errmsg, &err);
       if (lo->sobj_w == NULL)
 	goto fail_errmsg;
@@ -148,25 +151,27 @@ lto_obj_file_open (const char *filename, bool writable)
 
   return &lo->base;
 
  fail_errmsg:
   if (err == 0)
     error ("%s: %s", fname, errmsg);
   else
     error ("%s: %s: %s", fname, errmsg, xstrerror (err));
 					 
  fail:
-  if (lo != NULL)
+  if (lo->fd != -1)
     lto_obj_file_close ((lto_file *) lo);
+  free (lo);
   return NULL;
 }
 
+
 /* Close FILE.  If FILE was opened for writing, it is written out
    now.  */
 
 void
 lto_obj_file_close (lto_file *file)
 {
   struct lto_simple_object *lo = (struct lto_simple_object *) file;
 
   if (lo->sobj_r != NULL)
     simple_object_release_read (lo->sobj_r);
