This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] fix a few more reader issues
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: zadeck at naturalbridge dot com
- Date: Wed, 17 Oct 2007 09:08:35 -0700
- Subject: [lto] fix a few more reader issues
The patch fixes a couple of issues:
- It eliminates superfluous error messages about not being able to
handle particular DWARF tags and not being able to find bodies for
functions. In the former case, we have been fine with simply reading
in the tags' children, so we continue doing that explicitly. In the
latter case, the functions in question have either been inlined in all
callers or are found in external code.
- When we are in input_cfg, cfun is not necessarily equal to the
function whose cfg we are reading, so we need to use
basic_block_info_for_function. The code further on in that function
seems to think we are constructing cfun, though
(e.g. SET_BASIC_BLOCK_FOR_FUNCTION and {ENTRY,EXIT}_BLOCK); I'm not
sure what the right coruse of action there is.
- It adds a debugging aid when reading SSA_NAMEs in input_expr_operand.
The moves the error back from a segfault into an assert, which will
hopefully make for easier debugging. A missing case for the
mechanical cases was also added (I haven't hit that case as far as I
know, but Murphy says we eventually will).
Committed to the lto branch.
-Nathan
2007-10-17 Nathan Froyd <froydnj@codesourcery.com>
* lto.c (lto_read_only_for_child_DIEs): New function.
(lto_read_DIE): Use it for lexical_block and inlined_subroutine DIEs.
* lto-elf.c (lto_elf_map_lto_section): Remove.
(lto_elf_file_vtable): Use lto_elf_map_optional_lto_section instead.
* lto-read.c (input_expr_operand): Assert that we never read a NULL
SSA_NAME. Add missing case for mechanical codes.
(input_cfg): Use basic_block_info_for_function instead of
basic_block_info.
Index: lto-elf.c
===================================================================
--- lto-elf.c (revision 129405)
+++ lto-elf.c (working copy)
@@ -60,9 +60,6 @@ typedef struct lto_elf_file lto_elf_file
/* Forward Declarations */
static const void *
-lto_elf_map_lto_section (lto_file *file, const char *id);
-
-static const void *
lto_elf_map_optional_lto_section (lto_file *file, const char *id);
static void
@@ -70,7 +67,7 @@ lto_elf_unmap_fn_body (lto_file *file, c
/* The vtable for ELF input files. */
static const lto_file_vtable lto_elf_file_vtable = {
- lto_elf_map_lto_section,
+ lto_elf_map_optional_lto_section,
lto_elf_unmap_fn_body,
lto_elf_map_optional_lto_section,
lto_elf_unmap_fn_body
@@ -449,20 +446,6 @@ lto_elf_map_optional_lto_section (lto_fi
return (const void *)(data->d_buf);
}
-/* Like lto_elf_map_optional_lto_section, but report an error
- if the section is not present. */
-static const void *
-lto_elf_map_lto_section (lto_file *file,
- const char *id)
-{
- const void *data = lto_elf_map_optional_lto_section (file, id);
-
- if (! data)
- error ("unable to find LTO data for %qs: %s", id, elf_errmsg (0));
-
- return data;
-}
-
static void
lto_elf_unmap_fn_body (lto_file *file ATTRIBUTE_UNUSED,
const char *fn ATTRIBUTE_UNUSED,
Index: lto-read.c
===================================================================
--- lto-read.c (revision 129405)
+++ lto-read.c (working copy)
@@ -580,6 +580,8 @@ input_expr_operand (struct input_block *
case SSA_NAME:
result = VEC_index (tree, SSANAMES (fn), input_uleb128 (ib));
+ /* We should not get an SSA_NAME that has been freed. */
+ gcc_assert (result);
break;
case CONST_DECL:
@@ -867,6 +869,10 @@ input_expr_operand (struct input_block *
result = build5 (code, type, ops[0], ops[1], ops[2], ops[3],
ops[4]);
break;
+ case 6:
+ result = build5 (code, type, ops[0], ops[1], ops[2], ops[3],
+ ops[4], ops[5]);
+ break;
case 7:
result = build7 (code, type, ops[0], ops[1], ops[2], ops[3],
ops[4], ops[5], ops[6]);
@@ -1166,7 +1172,8 @@ input_cfg (struct input_block *ib, struc
last_basic_block_for_function (fn) = bb_count;
basic_block_info_for_function (fn)
= VEC_alloc (basic_block, gc, bb_count);
- VEC_safe_grow (basic_block, gc, basic_block_info, bb_count);
+ VEC_safe_grow (basic_block, gc,
+ basic_block_info_for_function (fn), bb_count);
memset (VEC_address (basic_block,
basic_block_info_for_function (fn)),
0, sizeof (basic_block) * bb_count);
Index: lto.c
===================================================================
--- lto.c (revision 129405)
+++ lto.c (working copy)
@@ -2119,6 +2119,23 @@ lto_read_variable_formal_parameter_const
return decl;
}
+/* Used when we only care about reading the DIE's children. */
+
+static tree
+lto_read_only_for_child_DIEs (lto_info_fd *fd,
+ lto_die_ptr die,
+ const DWARF2_abbrev *abbrev,
+ lto_context *context)
+{
+ LTO_BEGIN_READ_ATTRS_UNCHECKED ()
+ {
+ }
+ LTO_END_READ_ATTRS ();
+
+ lto_read_child_DIEs (fd, abbrev, context);
+
+ return NULL_TREE;
+}
static tree
lto_read_member_DIE (lto_info_fd *fd,
@@ -3025,7 +3042,7 @@ lto_read_DIE (lto_info_fd *fd, lto_conte
NULL, /* imported_declaration */
NULL, /* padding */
NULL, /* label */
- NULL, /* lexical_block */
+ lto_read_only_for_child_DIEs, /* lexical_block */
NULL, /* padding */
lto_read_member_DIE,
NULL, /* padding */
@@ -3043,7 +3060,7 @@ lto_read_DIE (lto_info_fd *fd, lto_conte
NULL, /* common_block */
NULL, /* common_inclusion */
NULL, /* inheritance */
- NULL, /* inlined_subroutine */
+ lto_read_only_for_child_DIEs, /* inlined_subroutine */
NULL, /* module */
NULL, /* ptr_to_member_type */
NULL, /* set_type */