aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2007-11-15 21:07:52 +0000
committerNathan Froyd <froydnj@codesourcery.com>2007-11-15 21:07:52 +0000
commit338c5141331428d18618d4b39eb4878cd170efaf (patch)
tree43e29241c860fccbc0ad696001a5318880c0d394
parent908862539dc6ea977205ac343f0895cd7c5fd70b (diff)
gcc/
* tree.h (DECL_CONTEXT): Note that this applies to RESULT_DECLs too. gcc/lto/ * lto.c: Include langhooks.h. (lto_find_integral_type): Rework logic to handle the case where got_byte_size is true, but the bitsize requested and that of the base_type doesn't match. (lto_read_variable_formal_parameter_constant_DIE): Only check for asm_name if we are creating a VAR_DECL. (lto_materialize_function): Set DECL_EXTERNAL if we can't find a definition. (lto_read_subroutine_type_subprogram_DIE): Check for a builtin function reference and use the builtin's decl if so. Set the DECL_CONTEXT of the RESULT_DECL for the function. * lto-lang.c (registered_builtin_fndecls): New variable. (lto_getdecls): Return it. (lto_builtin_function): Chain the new decl onto registered_builtin_fndecls. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/lto@130209 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.lto4
-rw-r--r--gcc/lto/ChangeLog18
-rw-r--r--gcc/lto/lto-lang.c12
-rw-r--r--gcc/lto/lto.c41
-rw-r--r--gcc/tree.h6
5 files changed, 70 insertions, 11 deletions
diff --git a/gcc/ChangeLog.lto b/gcc/ChangeLog.lto
index ba11ce90199..4baa5e1b92d 100644
--- a/gcc/ChangeLog.lto
+++ b/gcc/ChangeLog.lto
@@ -1,3 +1,7 @@
+2007-11-15 Nathan Froyd <froydnj@codesourcery.com>
+
+ * tree.h (DECL_CONTEXT): Note that this applies to RESULT_DECLs too.
+
2007-11-15 Kenneth Zadeck <zadeck@naturalbridge.com>
* tree-dump.c (dump_options): Removed verbose from -all option.
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 1e478e20f6f..584d3e27ca9 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,21 @@
+2007-11-15 Nathan Froyd <froydnj@codesourcery.com>
+
+ * lto.c: Include langhooks.h.
+ (lto_find_integral_type): Rework logic to handle the case where
+ got_byte_size is true, but the bitsize requested and that of the
+ base_type doesn't match.
+ (lto_read_variable_formal_parameter_constant_DIE): Only check for
+ asm_name if we are creating a VAR_DECL.
+ (lto_materialize_function): Set DECL_EXTERNAL if we can't find a
+ definition.
+ (lto_read_subroutine_type_subprogram_DIE): Check for a builtin
+ function reference and use the builtin's decl if so. Set the
+ DECL_CONTEXT of the RESULT_DECL for the function.
+ * lto-lang.c (registered_builtin_fndecls): New variable.
+ (lto_getdecls): Return it.
+ (lto_builtin_function): Chain the new decl onto
+ registered_builtin_fndecls.
+
2007-11-15 Kenneth Zadeck <zadeck@naturalbridge.com>
* lto-read.c (process_tree_flags, lto_static_init_local):
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index 86e6ee3de94..db6f63c97b9 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -59,6 +59,11 @@ static GTY(()) tree signed_and_unsigned_types[MAX_BITS_PER_WORD + 1][2];
static GTY(()) tree registered_builtin_types;
+/* A chain of builtin functions that we need to recognize. We will
+ assume that all other function names we see will be defined by the
+ user's program. */
+static GTY(()) tree registered_builtin_fndecls;
+
/* Language hooks. */
static bool
@@ -193,7 +198,7 @@ lto_pushdecl (tree t ATTRIBUTE_UNUSED)
static tree
lto_getdecls (void)
{
- gcc_unreachable ();
+ return registered_builtin_fndecls;
}
static void
@@ -208,7 +213,10 @@ lto_write_globals (void)
static tree
lto_builtin_function (tree decl)
{
- /* No special processing required. */
+ /* Record it. */
+ TREE_CHAIN (decl) = registered_builtin_fndecls;
+ registered_builtin_fndecls = decl;
+
return decl;
}
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 1cbbfb1f083..df5be3e0dba 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -33,6 +33,7 @@ Boston, MA 02110-1301, USA. */
#include "lto.h"
#include "lto-tree.h"
#include "tree-ssa-operands.h" /* For init_ssa_operands. */
+#include "langhooks.h"
/* References
@@ -1230,9 +1231,12 @@ lto_find_integral_type (tree base_type, int byte_size, bool got_byte_size)
|| !TYPE_SIZE (base_type)
|| !host_integerp (TYPE_SIZE (base_type), 1))
lto_abi_mismatch_error ();
- else if (got_byte_size
- && nbits != tree_low_cst (TYPE_SIZE (base_type), 1))
- sorry ("size of base type (%d bits) doesn't match specified size (%d bits)",
+ else if (!got_byte_size)
+ return base_type;
+ else if (nbits <= tree_low_cst (TYPE_SIZE (base_type), 1))
+ base_type = lang_hooks.types.type_for_size (nbits, /*unsigned=*/true);
+ else
+ sorry ("size of base type (%d bits) smaller than specified size (%d bits)",
(int) tree_low_cst (TYPE_SIZE (base_type), 1),
nbits);
return base_type;
@@ -2043,8 +2047,6 @@ lto_read_variable_formal_parameter_constant_DIE (lto_info_fd *fd,
name = DECL_NAME (referenced);
if (referenced && !type)
type = TREE_TYPE (referenced);
- if (referenced && !asm_name)
- asm_name = DECL_ASSEMBLER_NAME (referenced);
/* Build the tree node for this entity. */
decl = build_decl (code, name, type);
@@ -2055,6 +2057,8 @@ lto_read_variable_formal_parameter_constant_DIE (lto_info_fd *fd,
etc. */
if (code == VAR_DECL)
{
+ if (referenced && !asm_name)
+ asm_name = DECL_ASSEMBLER_NAME (referenced);
SET_DECL_ASSEMBLER_NAME (decl, asm_name);
TREE_PUBLIC (decl) = external;
DECL_EXTERNAL (decl) = declaration;
@@ -2366,7 +2370,7 @@ lto_materialize_function (lto_info_fd *fd,
file->vtable->unmap_fn_body (file, name, body);
}
else
- DECL_EXTERNAL (decl) = 0;
+ DECL_EXTERNAL (decl) = 1;
/* Let the middle end know about the function. */
rest_of_decl_compilation (decl,
@@ -2556,6 +2560,30 @@ lto_read_subroutine_type_subprogram_DIE (lto_info_fd *fd,
if (!name)
lto_file_corrupt_error ((lto_fd *)fd);
+ if (external && declaration)
+ {
+ /* Check to see if this function is a builtin. */
+ tree builtins = lang_hooks.decls.getdecls ();
+
+ while (builtins)
+ {
+ tree candidate = builtins;
+
+ /* Check to see if this builtin matches this function's
+ DIE. Use the builtin decl if so. */
+ if (name == DECL_NAME (candidate)
+ || (DECL_ASSEMBLER_NAME (candidate)
+ && name == DECL_ASSEMBLER_NAME (candidate)))
+ {
+ result = candidate;
+
+ goto read_children;
+ }
+
+ builtins = TREE_CHAIN (candidate);
+ }
+ }
+
result = build_decl (FUNCTION_DECL, name, type);
TREE_PUBLIC (result) = external;
if (inlined == DW_INL_declared_inlined
@@ -2569,6 +2597,7 @@ lto_read_subroutine_type_subprogram_DIE (lto_info_fd *fd,
DECL_RESULT (result)
= build_decl (RESULT_DECL, NULL_TREE,
TYPE_MAIN_VARIANT (ret_type));
+ TREE_CONTEXT (DECL_RESULT (result)) = result;
#if 0
DECL_SOURCE_LOCATION (result) = { input_filename, line };
#endif
diff --git a/gcc/tree.h b/gcc/tree.h
index c0a88e27eab..b20ea938406 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2515,9 +2515,9 @@ struct function;
/* For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or
QUAL_UNION_TYPE node that the field is a member of. For VAR_DECL,
- PARM_DECL, FUNCTION_DECL, LABEL_DECL, and CONST_DECL nodes, this
- points to either the FUNCTION_DECL for the containing function,
- the RECORD_TYPE or UNION_TYPE for the containing type, or
+ PARM_DECL, FUNCTION_DECL, LABEL_DECL, RESULT_DECL, and CONST_DECL
+ nodes, this points to either the FUNCTION_DECL for the containing
+ function, the RECORD_TYPE or UNION_TYPE for the containing type, or
NULL_TREE or a TRANSLATION_UNIT_DECL if the given decl has "file
scope". */
#define DECL_CONTEXT(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.context)