[lto] fix two spec issues

Nathan Froyd froydnj@codesourcery.com
Fri Dec 21 15:23:00 GMT 2007

This patch fixes two issues with SPECint.  The input_real fix is because
we'd occasionally the string table entry for the real we were supposed
to read would contain something like:


The indicated 3 did not belong to the hexadecimal float, but
real_from_string didn't know that and would happily read until it found
a non-decimal character.  So we would occasionally read in numbers with
much larger exponents, with predictably bad results.

The input_expr_operand fix handles a case in 176.gcc:dwarfout.c where we
were faced with a construct like:

  output_die (CONDITION ? output_one_way : output_differently, ...)

And OUTPUT_ONE_WAY and OUTPUT_DIFFERENTLY were never explicitly called
from anywhere else.  cgraph would notice this and decide that the
functions weren't actually needed, leading to assembler errors.

Committed to the LTO branch.


2007-12-21  Nathan Froyd  <froydnj@codesourcery.com>

	* lto-read.c (input_real): Use a separate null-terminated buffer
	for calling real_from_string.
	(input_expr_operand): If we take the address of a FUNCTION_DECL,
	tell cgraph that it's needed.

Index: lto/lto-read.c
--- lto/lto-read.c	(revision 131119)
+++ lto/lto-read.c	(working copy)
@@ -266,11 +266,16 @@ input_real (struct input_block *ib, stru
   unsigned int len;
   const char * str;
+  static char buffer[1000];
   LTO_DEBUG_TOKEN ("real");
   loc = input_uleb128 (ib);
   str = input_string_internal (data_in, loc, &len);
-  real_from_string (&value, str);
+  /* Copy over to make sure real_from_string doesn't see peculiar
+     trailing characters in the exponent.  */
+  memcpy (buffer, str, len);
+  buffer[len] = '\0';
+  real_from_string (&value, buffer);
   return build_real (type, value);
@@ -1164,6 +1169,8 @@ input_expr_operand (struct input_block *
       if (TREE_CODE (x) == VAR_DECL || TREE_CODE (x) == PARM_DECL)
+      else if (TREE_CODE (x) == FUNCTION_DECL)
+	cgraph_mark_needed_node (cgraph_node (x));
       recompute_tree_invariant_for_addr_expr (result);

More information about the Gcc-patches mailing list