Hi. Second follow-up patch uses flags_from_decl_or_type in LTO merging of declarations. Hope it's more cleaner approach.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Martin
>From 17d598f028c723cb11e8a9f786e3026c0cfca4aa Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Fri, 8 Jun 2018 10:14:47 +0200 Subject: [PATCH] Use flags_from_decl_or_type in lto_symtab_merge_p (PR ipa/85248). gcc/lto/ChangeLog: 2018-06-08 Martin Liska <mli...@suse.cz> PR ipa/85248 * lto-symtab.c (lto_symtab_merge_p): Use flags_from_decl_or_type. --- gcc/lto/lto-symtab.c | 50 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c index b1df9bb77d1..2259358ea5f 100644 --- a/gcc/lto/lto-symtab.c +++ b/gcc/lto/lto-symtab.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "lto-symtab.h" #include "stringpool.h" #include "attribs.h" +#include "calls.h" /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging all edges and removing the old node. */ @@ -547,7 +548,7 @@ lto_symtab_merge_p (tree prevailing, tree decl) { if (DECL_BUILT_IN (prevailing) != DECL_BUILT_IN (decl)) { - if (symtab->dump_file) + if (symtab->dump_file) fprintf (symtab->dump_file, "Not merging decls; " "DECL_BUILT_IN mismatch\n"); return false; @@ -561,44 +562,23 @@ lto_symtab_merge_p (tree prevailing, tree decl) "DECL_BUILT_IN_CLASS or CODE mismatch\n"); return false; } - } - /* FIXME: after MPX is removed, use flags_from_decl_or_type - function instead. PR lto/85248. */ - if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl)) - { - tree prev_attr = lookup_attribute ("error", DECL_ATTRIBUTES (prevailing)); - tree attr = lookup_attribute ("error", DECL_ATTRIBUTES (decl)); - if ((prev_attr == NULL) != (attr == NULL) - || (prev_attr && !attribute_value_equal (prev_attr, attr))) + if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl)) { - if (symtab->dump_file) - fprintf (symtab->dump_file, "Not merging decls; " - "error attribute mismatch\n"); - return false; - } - - prev_attr = lookup_attribute ("warning", DECL_ATTRIBUTES (prevailing)); - attr = lookup_attribute ("warning", DECL_ATTRIBUTES (decl)); - if ((prev_attr == NULL) != (attr == NULL) - || (prev_attr && !attribute_value_equal (prev_attr, attr))) - { - if (symtab->dump_file) - fprintf (symtab->dump_file, "Not merging decls; " - "warning attribute mismatch\n"); - return false; - } - - prev_attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (prevailing)); - attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (decl)); - if ((prev_attr == NULL) != (attr == NULL)) - { - if (symtab->dump_file) - fprintf (symtab->dump_file, "Not merging decls; " - "noreturn attribute mismatch\n"); - return false; + int prev_decl_attrs + = flags_from_decl_or_type (prevailing); + int decl_attrs + = flags_from_decl_or_type (decl); + if (prev_decl_attrs != decl_attrs) + { + if (symtab->dump_file) + fprintf (symtab->dump_file, "Not merging decls; " + "DECL_ATTRIBUTES mismatch\n"); + return false; + } } } + return true; } -- 2.17.0