re PR lto/41858 (-flto -O2 crashes when many source files.)
2009-10-30 Richard Guenther <rguenther@suse.de> PR lto/41858 * lto-streamer.h (struct lto_file_decl_data): Remove fd member. lto/ * lto.c (lto_file_read): Do not set file_data->fd. (lto_read_section_data): Use a single-entry file-descriptor cache. Do not check the result of xmalloc. (free_section_data): Do not use file_data->fd. (lto_read_all_file_options): Likewise. From-SVN: r153758
This commit is contained in:
parent
62f9f3cebf
commit
b207f90082
|
@ -1,3 +1,8 @@
|
||||||
|
2009-10-30 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
|
PR lto/41858
|
||||||
|
* lto-streamer.h (struct lto_file_decl_data): Remove fd member.
|
||||||
|
|
||||||
2009-10-30 Nathan Sidwell <nathan@codesourcery.com>
|
2009-10-30 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* target-def.h (TARGET_ASM_TTYPE): Correct typo of TARGET_ARM_TTYPE.
|
* target-def.h (TARGET_ASM_TTYPE): Correct typo of TARGET_ARM_TTYPE.
|
||||||
|
|
|
@ -555,10 +555,6 @@ struct lto_file_decl_data
|
||||||
/* Nonzero if this file should be recompiled with LTRANS. */
|
/* Nonzero if this file should be recompiled with LTRANS. */
|
||||||
unsigned needs_ltrans_p : 1;
|
unsigned needs_ltrans_p : 1;
|
||||||
|
|
||||||
/* If the file is open, this is the fd of the mapped section. This
|
|
||||||
is -1 if the file has not yet been opened. */
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
/* Hash table maps lto-related section names to location in file. */
|
/* Hash table maps lto-related section names to location in file. */
|
||||||
htab_t section_hash_table;
|
htab_t section_hash_table;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
2009-10-30 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
|
PR lto/41858
|
||||||
|
* lto.c (lto_file_read): Do not set file_data->fd.
|
||||||
|
(lto_read_section_data): Use a single-entry file-descriptor cache.
|
||||||
|
Do not check the result of xmalloc.
|
||||||
|
(free_section_data): Do not use file_data->fd.
|
||||||
|
(lto_read_all_file_options): Likewise.
|
||||||
|
|
||||||
2009-10-22 Richard Guenther <rguenther@suse.de>
|
2009-10-22 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
* lto.c (lto_fixup_jump_functions): Remove.
|
* lto.c (lto_fixup_jump_functions): Remove.
|
||||||
|
|
|
@ -334,7 +334,6 @@ lto_file_read (lto_file *file, FILE *resolution_file)
|
||||||
|
|
||||||
file_data = XCNEW (struct lto_file_decl_data);
|
file_data = XCNEW (struct lto_file_decl_data);
|
||||||
file_data->file_name = file->filename;
|
file_data->file_name = file->filename;
|
||||||
file_data->fd = -1;
|
|
||||||
file_data->section_hash_table = lto_elf_build_section_table (file);
|
file_data->section_hash_table = lto_elf_build_section_table (file);
|
||||||
file_data->renaming_hash_table = lto_create_renaming_table ();
|
file_data->renaming_hash_table = lto_create_renaming_table ();
|
||||||
|
|
||||||
|
@ -363,17 +362,33 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
|
||||||
intptr_t offset, size_t len)
|
intptr_t offset, size_t len)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
|
static int fd = -1;
|
||||||
|
static char *fd_name;
|
||||||
#if LTO_MMAP_IO
|
#if LTO_MMAP_IO
|
||||||
intptr_t computed_len;
|
intptr_t computed_len;
|
||||||
intptr_t computed_offset;
|
intptr_t computed_offset;
|
||||||
intptr_t diff;
|
intptr_t diff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (file_data->fd == -1)
|
/* Keep a single-entry file-descriptor cache. The last file we
|
||||||
file_data->fd = open (file_data->file_name, O_RDONLY);
|
touched will get closed at exit.
|
||||||
|
??? Eventually we want to add a more sophisticated larger cache
|
||||||
if (file_data->fd == -1)
|
or rather fix function body streaming to not stream them in
|
||||||
return NULL;
|
practically random order. */
|
||||||
|
if (fd != -1
|
||||||
|
&& strcmp (fd_name, file_data->file_name) != 0)
|
||||||
|
{
|
||||||
|
free (fd_name);
|
||||||
|
close (fd);
|
||||||
|
fd = -1;
|
||||||
|
}
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
fd_name = xstrdup (file_data->file_name);
|
||||||
|
fd = open (file_data->file_name, O_RDONLY);
|
||||||
|
if (fd == -1)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#if LTO_MMAP_IO
|
#if LTO_MMAP_IO
|
||||||
if (!page_mask)
|
if (!page_mask)
|
||||||
|
@ -387,26 +402,17 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
|
||||||
computed_len = len + diff;
|
computed_len = len + diff;
|
||||||
|
|
||||||
result = (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE,
|
result = (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE,
|
||||||
file_data->fd, computed_offset);
|
fd, computed_offset);
|
||||||
if (result == MAP_FAILED)
|
if (result == MAP_FAILED)
|
||||||
{
|
return NULL;
|
||||||
close (file_data->fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result + diff;
|
return result + diff;
|
||||||
#else
|
#else
|
||||||
result = (char *) xmalloc (len);
|
result = (char *) xmalloc (len);
|
||||||
if (result == NULL)
|
if (lseek (fd, offset, SEEK_SET) != offset
|
||||||
{
|
|| read (fd, result, len) != (ssize_t) len)
|
||||||
close (file_data->fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (lseek (file_data->fd, offset, SEEK_SET) != offset
|
|
||||||
|| read (file_data->fd, result, len) != (ssize_t) len)
|
|
||||||
{
|
{
|
||||||
free (result);
|
free (result);
|
||||||
close (file_data->fd);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +455,7 @@ get_section_data (struct lto_file_decl_data *file_data,
|
||||||
starts at OFFSET and has LEN bytes. */
|
starts at OFFSET and has LEN bytes. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_section_data (struct lto_file_decl_data *file_data,
|
free_section_data (struct lto_file_decl_data *file_data ATTRIBUTE_UNUSED,
|
||||||
enum lto_section_type section_type ATTRIBUTE_UNUSED,
|
enum lto_section_type section_type ATTRIBUTE_UNUSED,
|
||||||
const char *name ATTRIBUTE_UNUSED,
|
const char *name ATTRIBUTE_UNUSED,
|
||||||
const char *offset, size_t len ATTRIBUTE_UNUSED)
|
const char *offset, size_t len ATTRIBUTE_UNUSED)
|
||||||
|
@ -460,9 +466,6 @@ free_section_data (struct lto_file_decl_data *file_data,
|
||||||
intptr_t diff;
|
intptr_t diff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (file_data->fd == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if LTO_MMAP_IO
|
#if LTO_MMAP_IO
|
||||||
computed_offset = ((intptr_t) offset) & page_mask;
|
computed_offset = ((intptr_t) offset) & page_mask;
|
||||||
diff = (intptr_t) offset - computed_offset;
|
diff = (intptr_t) offset - computed_offset;
|
||||||
|
@ -1712,15 +1715,12 @@ lto_read_all_file_options (void)
|
||||||
|
|
||||||
file_data = XCNEW (struct lto_file_decl_data);
|
file_data = XCNEW (struct lto_file_decl_data);
|
||||||
file_data->file_name = file->filename;
|
file_data->file_name = file->filename;
|
||||||
file_data->fd = -1;
|
|
||||||
file_data->section_hash_table = lto_elf_build_section_table (file);
|
file_data->section_hash_table = lto_elf_build_section_table (file);
|
||||||
|
|
||||||
lto_read_file_options (file_data);
|
lto_read_file_options (file_data);
|
||||||
|
|
||||||
lto_elf_file_close (file);
|
lto_elf_file_close (file);
|
||||||
htab_delete (file_data->section_hash_table);
|
htab_delete (file_data->section_hash_table);
|
||||||
if (file_data->fd != -1)
|
|
||||||
close (file_data->fd);
|
|
||||||
free (file_data);
|
free (file_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue