Commit ed73881e by Richard Guenther Committed by Richard Biener

re PR lto/56168 (GCC seems to disregard -fno-builtin when compiling with LTO)

2013-02-04  Richard Guenther  <rguenther@suse.de>

	PR lto/56168
	* lto-symtab.c (lto_symtab_merge_decls_1): Make non-builtin
	node prevail as last resort.
	(lto_symtab_merge_decls): Remove guard on LTRANS here.
	(lto_symtab_prevailing_decl): Builtins are their own prevailing
	decl.

	lto/
	* lto.c (read_cgraph_and_symbols): Do not call lto_symtab_merge_decls
	or lto_fixup_decls at LTRANS time.

	* gcc.dg/lto/pr56168_0.c: New testcase.
	* gcc.dg/lto/pr56168_1.c: Likewise.

From-SVN: r195709
parent 139a0707
2013-02-04 Richard Guenther <rguenther@suse.de>
PR lto/56168
* lto-symtab.c (lto_symtab_merge_decls_1): Make non-builtin
node prevail as last resort.
(lto_symtab_merge_decls): Remove guard on LTRANS here.
(lto_symtab_prevailing_decl): Builtins are their own prevailing
decl.
2013-02-04 Richard Biener <rguenther@suse.de> 2013-02-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/56113 PR tree-optimization/56113
......
...@@ -439,12 +439,12 @@ lto_symtab_merge_decls_1 (symtab_node first) ...@@ -439,12 +439,12 @@ lto_symtab_merge_decls_1 (symtab_node first)
&& COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl))) && COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl)))
prevailing = e; prevailing = e;
} }
/* For variables prefer the builtin if one is available. */ /* For variables prefer the non-builtin if one is available. */
else if (TREE_CODE (prevailing->symbol.decl) == FUNCTION_DECL) else if (TREE_CODE (prevailing->symbol.decl) == FUNCTION_DECL)
{ {
for (e = first; e; e = e->symbol.next_sharing_asm_name) for (e = first; e; e = e->symbol.next_sharing_asm_name)
if (TREE_CODE (e->symbol.decl) == FUNCTION_DECL if (TREE_CODE (e->symbol.decl) == FUNCTION_DECL
&& DECL_BUILT_IN (e->symbol.decl)) && !DECL_BUILT_IN (e->symbol.decl))
{ {
prevailing = e; prevailing = e;
break; break;
...@@ -507,12 +507,6 @@ lto_symtab_merge_decls (void) ...@@ -507,12 +507,6 @@ lto_symtab_merge_decls (void)
{ {
symtab_node node; symtab_node node;
/* In ltrans mode we read merged cgraph, we do not really need to care
about resolving symbols again, we only need to replace duplicated declarations
read from the callgraph and from function sections. */
if (flag_ltrans)
return;
/* Populate assembler name hash. */ /* Populate assembler name hash. */
symtab_initialize_asm_name_hash (); symtab_initialize_asm_name_hash ();
...@@ -598,6 +592,11 @@ lto_symtab_prevailing_decl (tree decl) ...@@ -598,6 +592,11 @@ lto_symtab_prevailing_decl (tree decl)
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl)) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl))
return decl; return decl;
/* Likewise builtins are their own prevailing decl. This preserves
non-builtin vs. builtin uses from compile-time. */
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
return decl;
/* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */ /* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */
gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
......
2013-02-04 Richard Guenther <rguenther@suse.de>
PR lto/56168
* lto.c (read_cgraph_and_symbols): Do not call lto_symtab_merge_decls
or lto_fixup_decls at LTRANS time.
2013-01-09 Jan Hubicka <jh@suse.cz> 2013-01-09 Jan Hubicka <jh@suse.cz>
PR lto/45375 PR lto/45375
......
...@@ -3033,16 +3033,22 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -3033,16 +3033,22 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
fprintf (stderr, "Merging declarations\n"); fprintf (stderr, "Merging declarations\n");
timevar_push (TV_IPA_LTO_DECL_MERGE); timevar_push (TV_IPA_LTO_DECL_MERGE);
/* Merge global decls. */ /* Merge global decls. In ltrans mode we read merged cgraph, we do not
lto_symtab_merge_decls (); need to care about resolving symbols again, we only need to replace
duplicated declarations read from the callgraph and from function
sections. */
if (!flag_ltrans)
{
lto_symtab_merge_decls ();
/* If there were errors during symbol merging bail out, we have no /* If there were errors during symbol merging bail out, we have no
good way to recover here. */ good way to recover here. */
if (seen_error ()) if (seen_error ())
fatal_error ("errors during merging of translation units"); fatal_error ("errors during merging of translation units");
/* Fixup all decls. */ /* Fixup all decls. */
lto_fixup_decls (all_file_decl_data); lto_fixup_decls (all_file_decl_data);
}
htab_delete (tree_with_vars); htab_delete (tree_with_vars);
tree_with_vars = NULL; tree_with_vars = NULL;
ggc_collect (); ggc_collect ();
......
2013-02-04 Richard Guenther <rguenther@suse.de>
PR lto/56168
* gcc.dg/lto/pr56168_0.c: New testcase.
* gcc.dg/lto/pr56168_1.c: Likewise.
2013-02-02 Thomas Koenig <tkoenig@gcc.gnu.org> 2013-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50627 PR fortran/50627
......
/* { dg-lto-do run } */
/* { dg-lto-options { { -flto -O -ffast-math -fno-builtin } } } */
extern double pow(double, double);
extern void abort (void);
volatile double x = 1.0;
int main(int argc, char **argv)
{
double d1 = x;
double d2 = pow(d1, 1.0 / 3.0);
double d3 = d1 * d1;
if (d3 != 1.0 || d2 != 0.0)
abort ();
return 0;
}
/* { dg-options "-fno-lto" } */
double __attribute__((noinline,noclone))
pow (double x, double y) { return 0.0; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment