diff options
author | Richard Guenther <rguenther@suse.de> | 2013-02-04 12:19:25 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2013-02-04 12:19:25 +0000 |
commit | ed73881ea9ff3c99389618defe96b814cb952135 (patch) | |
tree | 621502d44633d587a4706564dbe2902f5db4f1e5 | |
parent | 139a0707cb46308598ece7785130679ea6e737a8 (diff) | |
download | gcc-ed73881ea9ff3c99389618defe96b814cb952135.zip gcc-ed73881ea9ff3c99389618defe96b814cb952135.tar.gz gcc-ed73881ea9ff3c99389618defe96b814cb952135.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/lto-symtab.c | 15 | ||||
-rw-r--r-- | gcc/lto/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/lto/lto.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr56168_0.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr56168_1.c | 4 |
7 files changed, 61 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 12e070a..6d5d53d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +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> PR tree-optimization/56113 diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c index 546601d..2b182ff 100644 --- a/gcc/lto-symtab.c +++ b/gcc/lto-symtab.c @@ -439,12 +439,12 @@ lto_symtab_merge_decls_1 (symtab_node first) && COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl))) 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) { for (e = first; e; e = e->symbol.next_sharing_asm_name) if (TREE_CODE (e->symbol.decl) == FUNCTION_DECL - && DECL_BUILT_IN (e->symbol.decl)) + && !DECL_BUILT_IN (e->symbol.decl)) { prevailing = e; break; @@ -507,12 +507,6 @@ lto_symtab_merge_decls (void) { 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. */ symtab_initialize_asm_name_hash (); @@ -598,6 +592,11 @@ lto_symtab_prevailing_decl (tree decl) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (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. */ gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 503ff80..2da6ae1 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +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> PR lto/45375 diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 9583b910..6edf87a 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -3033,16 +3033,22 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) fprintf (stderr, "Merging declarations\n"); timevar_push (TV_IPA_LTO_DECL_MERGE); - /* Merge global decls. */ - lto_symtab_merge_decls (); + /* Merge global decls. In ltrans mode we read merged cgraph, we do not + 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 - good way to recover here. */ - if (seen_error ()) - fatal_error ("errors during merging of translation units"); + /* If there were errors during symbol merging bail out, we have no + good way to recover here. */ + if (seen_error ()) + fatal_error ("errors during merging of translation units"); - /* Fixup all decls. */ - lto_fixup_decls (all_file_decl_data); + /* Fixup all decls. */ + lto_fixup_decls (all_file_decl_data); + } htab_delete (tree_with_vars); tree_with_vars = NULL; ggc_collect (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c765743..f4eb094 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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> PR fortran/50627 diff --git a/gcc/testsuite/gcc.dg/lto/pr56168_0.c b/gcc/testsuite/gcc.dg/lto/pr56168_0.c new file mode 100644 index 0000000..13f768e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr56168_0.c @@ -0,0 +1,15 @@ +/* { 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; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr56168_1.c b/gcc/testsuite/gcc.dg/lto/pr56168_1.c new file mode 100644 index 0000000..560d0bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr56168_1.c @@ -0,0 +1,4 @@ +/* { dg-options "-fno-lto" } */ + +double __attribute__((noinline,noclone)) +pow (double x, double y) { return 0.0; } |