Re: [PATCH] ICF is more strict about non-common function and var, attributes.
On March 1, 2015 1:09:50 AM CET, Jan Hubicka wrote: >> > >> > Half of FAILs are gone, but the rest is correctly merged (alignment >matches). Thus I would omit ICF >> > in this testcase. I'm going to install the patch. > >Richard, I wonder what happens with TYPE_ALIGN at LTO. It is not part >of canonical type >definition and thus we get random alignments on CANONICAL_TYPE_HASH. >func_checker::types_compatible leads to type_compatible_p which will >eventually do >/* If we know the canonical types, compare them. */ > >if (TYPE_CANONICAL (inner_type) > >&& TYPE_CANONICAL (inner_type) == TYPE_CANONICAL (outer_type)) > >return true; > >and thus we will hapilly merge types with different TYPE_ALIGN. >Should func_checker::types_compatible be extended to compare these? >Clearly TYPE_ALIGN matters for vectorizer and other plaes... But it matters on MEM_REFs only, and you can't use canonical types for that. And we don't. Tree merging correctly takes TYPE_ALING into account. >Any chance -malign-double can work and mix with -mno-align-double? I >think we >will mix the alignments because double is one of nodes we do not >stream, right? Right. Richard. > >Honza
Re: [PING] [wwwdocs, patch] Add libgccjit to gcc-5/changes.html
David Malcolm wrote: On Thu, 2015-02-05 at 21:47 -0500, David Malcolm wrote: This patch adds an -level section about libgccjit between the sections on languages and targets. It has various links to the documentation (now that that's on the website), and to a couple of 3rd party repos (the Python and D bindings). It also mentions the license of the library. OK to commit? Ping re: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00371.html (although the patch is slightly mangled in that HTML rendering in the archive, where semicolons have somehow been injected in the tags; the markup is correct in the patch itself). While it would be nice if Gerald could find the time to review the patch, I recall that he once said that maintainers don't need approvals for release-notes changes of their part of the compiler, which also matches what is written at https://gcc.gnu.org/svnwrite.html#policies : "These folks are allowed to make changes to areas they maintain and related documentation, web pages, and test cases without approval from anyone else, and approve other people's changes in those areas." And as you are JIT maintainer ... Cheers, Tobias
Re: [PING] [wwwdocs, patch] Add libgccjit to gcc-5/changes.html
On Sun, 1 Mar 2015, Tobias Burnus wrote: >> Ping re: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00371.html > While it would be nice if Gerald could find the time to review the patch, > I recall that he once said that maintainers don't need approvals for > release-notes changes of their part of the compiler, which also matches > what is written at https://gcc.gnu.org/svnwrite.html#policies : Yep, absolutely agreed. That said, I actually did review and approve this specific patch, cf. https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01672.html And I am always happy to review (and/or provide some editing after a commit), but outside of news items on the main page which generally should be reviewed by a second pair of eyes than the contributor this is more of a service than a mandate. ;-) Gerald
Re: [PATCH] Fix for PR ipa/65245
On 02/28/2015 11:41 PM, Jan Hubicka wrote: >> Hello. >> >> Following patch skips all variable aliases as potential merge candidates. >> Tested on x86_64-linux. >> >> Ready for trunk? >> Thanks, >> Martin > >> >From fbde2e98f98a71105d18cf3e91e8032d0c657139 Mon Sep 17 00:00:00 2001 >> From: mliska >> Date: Fri, 27 Feb 2015 22:42:49 +0100 >> Subject: [PATCH 2/4] ICF: Do not consider variable aliases for merge >> operation. >> >> gcc/ChangeLog: >> >> 2015-02-28 Martin Liska >> Jan Hubicka >> >> PR ipa/65245 >> * ipa-icf.c (sem_function::parse): Do not consider aliases. >> (sem_variable::parse): Likewise. >> (sem_item_optimizer::build_graph): Consider ultimate aliases >> for references. > > OK, can you please add a testcase checking that two functions get merged even > if each of them referrs different alias of an equvalent symbols? Hi. Updated version of patch adds new testcase. Ready for trunk? Thanks, Martin > > Honza >> --- >> gcc/ipa-icf.c | 11 --- >> 1 file changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c >> index 92133fc..864a5d0 100644 >> --- a/gcc/ipa-icf.c >> +++ b/gcc/ipa-icf.c >> @@ -1095,7 +1095,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack >> *stack) >>tree fndecl = node->decl; >>function *func = DECL_STRUCT_FUNCTION (fndecl); >> >> - /* TODO: add support for thunks and aliases. */ >> + /* TODO: add support for thunks. */ >> >>if (!func || !node->has_gimple_body_p ()) >> return NULL; >> @@ -1407,6 +1407,9 @@ sem_variable::parse (varpool_node *node, >> bitmap_obstack *stack) >> { >>tree decl = node->decl; >> >> + if (node->alias) >> +return NULL; >> + >>bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY >> (decl); >>if (!readonly) >> return NULL; >> @@ -2057,7 +2060,8 @@ sem_item_optimizer::build_graph (void) >>cgraph_edge *e = cnode->callees; >>while (e) >> { >> - sem_item **slot = m_symtab_node_map.get (e->callee); >> + sem_item **slot = m_symtab_node_map.get >> +(e->callee->ultimate_alias_target ()); >>if (slot) >> item->add_reference (*slot); >> >> @@ -2068,7 +2072,8 @@ sem_item_optimizer::build_graph (void) >>ipa_ref *ref = NULL; >>for (unsigned i = 0; item->node->iterate_reference (i, ref); i++) >> { >> - sem_item **slot = m_symtab_node_map.get (ref->referred); >> + sem_item **slot = m_symtab_node_map.get >> +(ref->referred->ultimate_alias_target ()); >>if (slot) >> item->add_reference (*slot); >> } >> -- >> 2.1.2 >> > >From 7cedbe5e3736b9eb7b2fab1b931a7bc9ed269f37 Mon Sep 17 00:00:00 2001 From: mliska Date: Fri, 27 Feb 2015 22:42:49 +0100 Subject: [PATCH 2/4] ICF: Do not consider variable aliases for merge operation. gcc/ChangeLog: 2015-02-28 Martin Liska Jan Hubicka * ipa-icf-gimple.c (func_checker::compare_function_decl): Consider ultimate alias as targets. * ipa-icf.c (sem_function::parse): Do not consider aliases. (sem_function::compare_cgraph_references): Consider ultimate alias as targets. (sem_variable::parse): Likewise. (sem_item_optimizer::build_graph): Consider ultimate aliases for references. gcc/testsuite/ChangeLog: 2015-02-28 Martin Liska Jan Hubicka * gcc.dg/ipa/ipa-icf-34.c: New test. * gcc.target/i386/stackalign/longlong-2.c: Omit ICF. --- gcc/ipa-icf-gimple.c | 4 ++-- gcc/ipa-icf.c | 14 +++--- gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c | 28 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index cbeb795..8008e86 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -543,8 +543,8 @@ func_checker::compare_function_decl (tree t1, tree t2) if (t1 == t2) return true; - symtab_node *n1 = symtab_node::get (t1); - symtab_node *n2 = symtab_node::get (t2); + symtab_node *n1 = symtab_node::get (t1)->ultimate_alias_target (); + symtab_node *n2 = symtab_node::get (t2)->ultimate_alias_target (); if (m_ignored_source_nodes != NULL && m_ignored_target_nodes != NULL) { diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 92133fc..b95db0d 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -342,6 +342,9 @@ sem_function::compare_cgraph_references (hash_map &ignored_nodes, symtab_node *n1, symtab_node *n2) { + n1 = n1->ultimate_alias_target (); + n2 = n2->ultimate_alias_target (); + if (n1 == n2 || (ignored_nodes.get (n1) && ignored_nodes.get (n2))) return true; @@ -1095,7 +1098,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) tree fndecl = node->decl; function *func = DECL_STRUCT_FUNCTION (fndecl); - /* TODO: add support for thunks and aliases. */ + /* TODO
Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol
On Sat, Feb 28, 2015 at 5:27 PM, Sandra Loosemore wrote: > On 02/28/2015 09:42 AM, H.J. Lu wrote: >> >> @@ -22704,6 +22705,13 @@ For systems that use the GNU C Library, the >> default is on. >> Specify that the assembler should encode SSE instructions with VEX >> prefix. The option @option{-mavx} turns this on by default. >> >> +@item -mcopyreloc-in-pie >> +@itemx -mno-copyreloc-in-pie >> +@opindex mcopyreloc-in-pie >> +Use copy relocations in Position Independent Executable (PIE). It >> +requires linker support. This option is turned on by default if linker >> +used to build GCC supports it. >> + > > > How about: "...if GCC is configured to use a linker that supports these > relocations." > > I assume this is a property of the target linker, and not literally the host > linker used to build GCC? Yes, that is correct. Here is the updated patch. Thanks. -- H.J. From 91de4b11eb2d7f9b0abd83837deb510a6f69cd81 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 28 Feb 2015 08:31:36 -0800 Subject: [PATCH] Add -mcopyreloc-in-pie Ue copy relocation in PIE improves performance. But copy relocation can't be used to access protected symbols defined in shared libaries and linker in binutils 2.26 enforces doesn't allow it. GCC doesn't know if an external definition is protected or not. This option gives user an option to turn it off to avoid problem at link-time. gcc/ PR target/65248 * config/i386/i386.c (ix86_option_override_internal): Set flag_copyreloc_in_pie to HAVE_LD_PIE_COPYRELOC if not set. (legitimate_pic_address_disp_p): Replace HAVE_LD_PIE_COPYRELOC with flag_copyreloc_in_pie. * config/i386/i386.opt (mcopyreloc-in-pie): New. * doc/invoke.texi: Document -mcopyreloc-in-pie. gcc/testsuite/ PR target/65248 * gcc.target/i386/pr65248-1.c: New. * gcc.target/i386/pr65248-2.c: Likewise. * gcc.target/i386/pr65248-3.c: Likewise. * gcc.target/i386/pr65248-4.c: Likewise. --- gcc/config/i386/i386.c| 6 +- gcc/config/i386/i386.opt | 4 gcc/doc/invoke.texi | 10 +- gcc/testsuite/gcc.target/i386/pr65248-1.c | 13 + gcc/testsuite/gcc.target/i386/pr65248-2.c | 13 + gcc/testsuite/gcc.target/i386/pr65248-3.c | 16 gcc/testsuite/gcc.target/i386/pr65248-4.c | 16 7 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-3.c create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-4.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index bec1324..6768ee8 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4248,6 +4248,10 @@ ix86_option_override_internal (bool main_args_p, #endif } + /* Set the default value for -mcopyreloc-in-pie. */ + if (opts->x_flag_copyreloc_in_pie == -1) +opts->x_flag_copyreloc_in_pie = HAVE_LD_PIE_COPYRELOC; + if (!(opts_set->x_target_flags & MASK_VZEROUPPER)) opts->x_target_flags |= MASK_VZEROUPPER; if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL] @@ -13230,7 +13234,7 @@ legitimate_pic_address_disp_p (rtx disp) } else if (!SYMBOL_REF_FAR_ADDR_P (op0) && (SYMBOL_REF_LOCAL_P (op0) - || (HAVE_LD_PIE_COPYRELOC + || (flag_copyreloc_in_pie && flag_pie && !SYMBOL_REF_WEAK (op0) && !SYMBOL_REF_FUNCTION_P (op0))) diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 301430c..55c712c 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -826,6 +826,10 @@ mfentry Target Report Var(flag_fentry) Init(-1) Emit profiling counter call at function entry before prologue. +mcopyreloc-in-pie +Target Report Var(flag_copyreloc_in_pie) Init(-1) +Use copy relocations in Position Independent Executable (PIE) + mrecord-mcount Target Report Var(flag_record_mcount) Init(0) Generate __mcount_loc section with all mcount or __fentry__ calls. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index a87376e..de228c4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1078,7 +1078,8 @@ See RS/6000 and PowerPC Options. -m32 -m64 -mx32 -m16 -mlarge-data-threshold=@var{num} @gol -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol --malign-data=@var{type} -mstack-protector-guard=@var{guard}} +-malign-data=@var{type} -mstack-protector-guard=@var{guard}} @gol +-mcopyreloc-in-pie @emph{x86 Windows Options} @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol @@ -22704,6 +22705,13 @@ For systems that use the GNU C Library, the default is on. Specify that the assembler should encode SSE instructions with VEX prefix. The option @option{-mavx} turns this on by default. +@item -mcopyreloc-in-pie +@itemx -mno-copyreloc-in-pie +@opindex mcopyrelo
Re: ipa-icf::merge TLC
On 27 February 2015 at 21:49, Jan Hubicka wrote: >> >> ../sysdeps/gnu/siglist.c:72:1: internal compiler error: in >> address_matters_p, at symtab.c:1908 >> versioned_symbol (libc, __new_sys_sigabbrev, sys_sigabbrev, GLIBC_2_3_3); >> ^ >> 0x66a080 symtab_node::address_matters_p() >> /scratch/sellcey/repos/bootstrap/src/gcc/gcc/symtab.c:1908 >> 0xe7cbe5 ipa_icf::sem_variable::merge(ipa_icf::sem_item*) >> /scratch/sellcey/repos/bootstrap/src/gcc/gcc/ipa-icf.c:1443 > > Indeed, the ipa-icf should not try to analyze aliases - just prove ekvialence > of > definitions they are attached to. It already does that for functions (bit by > accident; > it gives up when there is no gimple body), but it does not do that for > variables because > it gets into ctor_for_folding. For that reason it sometimes decides to try to > make two > variable aliases alias of each other that is not a good idea, because of > possible creation > of loops. > > I am just discussing with Martin the fix. > > Honza For the record, I have noticed similar errors on ARM and AArch64 targets, when building glibc. Christophe.
Re: [PATCH] Fix for PR ipa/65245
> >From 7cedbe5e3736b9eb7b2fab1b931a7bc9ed269f37 Mon Sep 17 00:00:00 2001 > From: mliska > Date: Fri, 27 Feb 2015 22:42:49 +0100 > Subject: [PATCH 2/4] ICF: Do not consider variable aliases for merge > operation. > > gcc/ChangeLog: > > 2015-02-28 Martin Liska > Jan Hubicka > > * ipa-icf-gimple.c (func_checker::compare_function_decl): > Consider ultimate alias as targets. > * ipa-icf.c (sem_function::parse): Do not consider aliases. > (sem_function::compare_cgraph_references): Consider ultimate > alias as targets. > (sem_variable::parse): Likewise. > (sem_item_optimizer::build_graph): Consider ultimate aliases > for references. > > gcc/testsuite/ChangeLog: > > 2015-02-28 Martin Liska > Jan Hubicka > > * gcc.dg/ipa/ipa-icf-34.c: New test. > * gcc.target/i386/stackalign/longlong-2.c: Omit ICF. > --- > gcc/ipa-icf-gimple.c | 4 ++-- > gcc/ipa-icf.c | 14 +++--- > gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c | 28 > 3 files changed, 41 insertions(+), 5 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c > > diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c > index cbeb795..8008e86 100644 > --- a/gcc/ipa-icf-gimple.c > +++ b/gcc/ipa-icf-gimple.c > @@ -543,8 +543,8 @@ func_checker::compare_function_decl (tree t1, tree t2) >if (t1 == t2) > return true; > > - symtab_node *n1 = symtab_node::get (t1); > - symtab_node *n2 = symtab_node::get (t2); > + symtab_node *n1 = symtab_node::get (t1)->ultimate_alias_target (); > + symtab_node *n2 = symtab_node::get (t2)->ultimate_alias_target (); Do we really need to compare them here if they are already compared by equals_wpa? The logic here is bit more difficult - it depends on alias if it is interposable or not. This is obtained by symtab_node::get (t1)->ultimate_alias_target (&avail); if one of aliases is interposable, you want to use symtab_node::get (t1)->equal_address_to (symtab_node::get (t2)) if address of given reference matters and semantically_equivalent_p otherwise. This is all done already in WPA checking, so I would suggest just assuming that decl maps if both pass decl_in_symtab_p. > >if (m_ignored_source_nodes != NULL && m_ignored_target_nodes != NULL) > { > diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c > index 92133fc..b95db0d 100644 > --- a/gcc/ipa-icf.c > +++ b/gcc/ipa-icf.c > @@ -342,6 +342,9 @@ sem_function::compare_cgraph_references (hash_map > > &ignored_nodes, > symtab_node *n1, symtab_node *n2) > { > + n1 = n1->ultimate_alias_target (); > + n2 = n2->ultimate_alias_target (); > + >if (n1 == n2 || (ignored_nodes.get (n1) && ignored_nodes.get (n2))) > return true; Here I sent you correct change privately yesterday - you want to use equal_address_to. I would still suggest just putting all those into sensitive reference lists. Rest of the patch looks OK. Honza
[c-family] Fix -fdump-ada-spec ICEs
They were introduced by the latest tree structure re-shuffling. Tested on x86_64-suse-linux, applied on the mainline as obvious. 2015-03-01 Eric Botcazou * c-ada-spec.c (is_tagged_type): Add guard for DECL_VINDEX. (dump_template_types): Adjust DECL_TEMPLATE_INSTANTIATIONS and DECL_TEMPLATE_RESULT emulations. (dump_ada_template)): Add guard for TYPE_METHODS. 2015-03-01 Eric Botcazou * g++.dg/other/dump-ada-spec-3.C: New test. -- Eric BotcazouIndex: c-family/c-ada-spec.c === --- c-family/c-ada-spec.c (revision 220958) +++ c-family/c-ada-spec.c (working copy) @@ -961,7 +961,7 @@ is_tagged_type (const_tree type) return false; for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp)) -if (DECL_VINDEX (tmp)) +if (TREE_CODE (tmp) == FUNCTION_DECL && DECL_VINDEX (tmp)) return true; return false; @@ -1730,10 +1730,15 @@ dump_template_types (pretty_printer *buf static int dump_ada_template (pretty_printer *buffer, tree t, int spc) { - /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context. */ - tree inst = DECL_VINDEX (t); - /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context. */ - tree result = DECL_RESULT_FLD (t); + /* DECL_SIZE_UNIT is DECL_TEMPLATE_INSTANTIATIONS in this context. */ + tree inst = DECL_SIZE_UNIT (t); + /* This emulates DECL_TEMPLATE_RESULT in this context. */ + struct tree_template_decl { +struct tree_decl_common common; +tree arguments; +tree result; + }; + tree result = ((struct tree_template_decl *) t)->result; int num_inst = 0; /* Don't look at template declarations declaring something coming from @@ -1750,7 +1755,7 @@ dump_ada_template (pretty_printer *buffe if (TREE_VEC_LENGTH (types) == 0) break; - if (!TYPE_P (instance) || !TYPE_METHODS (instance)) + if (!RECORD_OR_UNION_TYPE_P (instance) || !TYPE_METHODS (instance)) break; num_inst++; /* { dg-do compile } */ /* { dg-options "-fdump-ada-spec" } */ #include using namespace std; class Base { public: int My_V; virtual void Primitive (); Base (); }; void Base::Primitive () { cout << "C++ Primitive " << this->My_V << "\n"; } Base::Base () { } void Dispatch (Base * B) { B->Primitive (); } /* { dg-final { cleanup-ada-spec } } */
[SH][committed] Add test case for PR 61142
Hi, This adds a test case for PR 61142. Tested with make -k check-gcc RUNTESTFLAGS="sh.exp=pr61142.c --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" Committed as r221089. Cheers, Oleg gcc/testsuite/ChangeLog: PR target/61142 * gcc.target/sh/sh/pr61142.c: New. Index: gcc/testsuite/gcc.target/sh/pr61142.c === --- gcc/testsuite/gcc.target/sh/pr61142.c (revision 0) +++ gcc/testsuite/gcc.target/sh/pr61142.c (revision 0) @@ -0,0 +1,30 @@ +/* Check that @(r0,rm),rn insns load into r0. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "mov.b\t@\\(r0,r\[0123456789\]\\),r0" 1 } } */ +/* { dg-final { scan-assembler-times "mov.w\t@\\(r0,r\[0123456789\]\\),r0" 1 } } */ +/* { dg-final { scan-assembler-times "mov.l\t@\\(r0,r\[0123456789\]\\),r0" 1 } } */ + +int +test_00 (const char* x, int a, int b, int c) +{ + if (x[a] == 92) +return b; + return c; +} + +int +test_01 (const short* x, int a, int b, int c) +{ + if (x[a] == 92) +return b; + return c; +} + +int +test_02 (const int* x, int a, int b, int c) +{ + if (x[a] == 92) +return b; + return c; +}
[patch] FreeBSD powerpc64 remove 32-bit soft-float multilibs.
Hi all, the appended patch removes the soft-float multilib build option from powerpc64-*-freebsd*. These libraries are rarely to never used on 64-bit FreeBSD PowerPC machines. But the build time of these libraries counts. Is this ok for trunk? If yes, at what stage can I commit, 5.0/5.1? Thanks, Andreas 2015-03-01 Andreas Tobler * config/rs6000/t-freebsd64: Remove 32-bit soft-float multilibs. Index: gcc/config/rs6000/t-freebsd64 === --- gcc/config/rs6000/t-freebsd64 (revision 221089) +++ gcc/config/rs6000/t-freebsd64 (working copy) @@ -21,11 +21,9 @@ # On FreeBSD the 32-bit libraries are found under /usr/lib32. # Set MULTILIB_OSDIRNAMES according to this. -MULTILIB_OPTIONS= m32 msoft-float -MULTILIB_DIRNAMES = 32 nof +MULTILIB_OPTIONS= m32 +MULTILIB_DIRNAMES = 32 MULTILIB_EXTRA_OPTS = fPIC mstrict-align MULTILIB_EXCEPTIONS = -MULTILIB_EXCLUSIONS = !m32/msoft-float MULTILIB_OSDIRNAMES= ../lib32 -#MULTILIB_MATCHES= $(MULTILIB_MATCHES_FLOAT)
New Swedish PO file for 'gcc' (version 5.1-b20150208)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'gcc' has been submitted by the Swedish team of translators. The file is available at: http://translationproject.org/latest/gcc/sv.po (This file, 'gcc-5.1-b20150208.sv.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/gcc/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/gcc.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator.
Re: [PATCH] Fix for PR ipa/65245
Hi, here is a variant of patch I intend to commit after x86_64 bootstrap®test and LTO-bootstrap. What i changed are the ipa-icf-gimple.c bits (dorpping all comparsions relying that external references are already matched and used at same spots). Second change is sem_function::compare_cgraph_references doing right thing wrt reference type. I think as an optimization sem_item_optimizer::build_graph can drop all interposable references, because they are already handled earlier as sensitive and cgraph references. Honza 2015-02-28 Martin Liska Jan Hubicka PR ipa/65245 * ipa-icf-gimple.c (func_checker::compare_function_decl): Remove. (func_checker::compare_variable_decl): Skip symtab vars. (func_checker::compare_cst_or_decl): Update. * ipa-icf.c (sem_function::parse): Do not consider aliases. (sem_function::compare_cgraph_references): Add ADDRESS parameter; use correct symtab predicates. (sem_function::equals_wpa): Update uses of compare_cgraph_references. (sem_variable::parse): Update comment. (sem_item_optimizer::build_graph): Consider ultimate aliases for references. gcc/testsuite/ChangeLog: 2015-02-28 Martin Liska Jan Hubicka PR ipa/65245 * gcc.dg/ipa/ipa-icf-34.c: New test. Index: ipa-icf.c === --- ipa-icf.c (revision 221089) +++ ipa-icf.c (working copy) @@ -335,17 +335,26 @@ sem_function::get_hash (void) /* For a given symbol table nodes N1 and N2, we check that FUNCTION_DECLs point to a same function. Comparison can be skipped if IGNORED_NODES - contains these nodes. */ + contains these nodes. ADDRESS indicate if address is taken. */ bool -sem_function::compare_cgraph_references (hash_map -&ignored_nodes, -symtab_node *n1, symtab_node *n2) +sem_function::compare_cgraph_references ( +hash_map &ignored_nodes, +symtab_node *n1, symtab_node *n2, bool address) { - if (n1 == n2 || (ignored_nodes.get (n1) && ignored_nodes.get (n2))) + enum availability avail1, avail2; + + if (address && n1->equal_address_to (n2) == 1) +return true; + if (!address && n1->semantically_equivalent_p (n2)) return true; - /* TODO: add more precise comparison for weakrefs, etc. */ + n1 = n1->ultimate_alias_target (&avail1); + n2 = n2->ultimate_alias_target (&avail2); + + if (avail1 >= AVAIL_INTERPOSABLE && ignored_nodes.get (n1) + && avail2 >= AVAIL_INTERPOSABLE && ignored_nodes.get (n2)) +return true; return return_false_with_msg ("different references"); } @@ -412,7 +421,9 @@ sem_function::equals_wpa (sem_item *item { item->node->iterate_reference (i, ref2); - if (!compare_cgraph_references (ignored_nodes, ref->referred, ref2->referred)) + if (!compare_cgraph_references (ignored_nodes, ref->referred, + ref2->referred, + ref->address_matters_p ())) return false; } @@ -421,7 +432,8 @@ sem_function::equals_wpa (sem_item *item while (e1 && e2) { - if (!compare_cgraph_references (ignored_nodes, e1->callee, e2->callee)) + if (!compare_cgraph_references (ignored_nodes, e1->callee, + e2->callee, false)) return false; e1 = e1->next_callee; @@ -1117,7 +1129,7 @@ sem_function::parse (cgraph_node *node, tree fndecl = node->decl; function *func = DECL_STRUCT_FUNCTION (fndecl); - /* TODO: add support for thunks and aliases. */ + /* TODO: add support for thunks. */ if (!func || !node->has_gimple_body_p ()) return NULL; @@ -1429,6 +1441,9 @@ sem_variable::parse (varpool_node *node, { tree decl = node->decl; + if (node->alias) +return NULL; + bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl); if (!readonly) return NULL; @@ -2086,7 +2101,8 @@ sem_item_optimizer::build_graph (void) cgraph_edge *e = cnode->callees; while (e) { - sem_item **slot = m_symtab_node_map.get (e->callee); + sem_item **slot = m_symtab_node_map.get + (e->callee->ultimate_alias_target ()); if (slot) item->add_reference (*slot); @@ -2097,7 +2113,8 @@ sem_item_optimizer::build_graph (void) ipa_ref *ref = NULL; for (unsigned i = 0; item->node->iterate_reference (i, ref); i++) { - sem_item **slot = m_symtab_node_map.get (ref->referred); + sem_item **slot = m_symtab_node_map.get + (ref->referred->ultimate_alias_target ()); if (slot) item->add_reference (*slot); } Index: ipa-icf.h === --- ipa-icf.h (revision 221089) +++ ipa-icf.h (working copy) @@ -353,10 +353,11 @@ private: /* For a given symbol
Re: [Patch, fortran] PR60898 premature release of entry symbols
Dear Mikael, That looks to be OK for 4.8, 4.9 and 5.0. Strange testcase, though... :-) Thanks for the patch Paul On 15 February 2015 at 18:48, Mikael Morin wrote: > Hello, > > I propose a fix for PR60898, where a symbol is freed despite remaining > reachable in the symbol tree. > The problem comes from this code in resolve_symbol: >> >> /* If we find that a flavorless symbol is an interface in one of the >>parent namespaces, find its symtree in this namespace, free the >>symbol and set the symtree to point to the interface symbol. */ >> for (ns = gfc_current_ns->parent; ns; ns = ns->parent) >> { >> symtree = gfc_find_symtree (ns->sym_root, sym->name); >> if (symtree && [...]) >> { >> this_symtree = gfc_find_symtree (gfc_current_ns->sym_root, >> sym->name); >> gfc_release_symbol (sym); >> symtree->n.sym->refs++; >> this_symtree->n.sym = symtree->n.sym; >> return; >> } >> } >> > > Here, the target of an element of the current namespace's name tree is > changed to point to the outer symbol. And the current symbol is freed, > without checking that it really was what was in the name tree before. > > In the testcase https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60898#c7 , > the problematic symbol is an entry, which is available in the name tree > only through a mangled name (created by gfc_get_unique_symtree in > get_proc_name), so gfc_find_symtree won't find it by name lookup. > In this case, what gfc_find_symtree finds is a symbol that is already > the outer interface symbol, so reassigning this_symtree.n.sym would be a > no-op. > > The patch proposed checks that sym == this_symtree->n.sym, so that the > symbol reassignment is only made in that case. Otherwise, the regular > symbol resolution happens normally. > > This patch is a stripped down version of what I posted before in the PR, > which contained a symbol.c part which was increasing the reference count > locally in do_traverse_symtree, to delay symbol release after all of > them have been processed. That part was useless because if a symbol had > to be processed more than once (meaning it was available under different > names), it will have the corresponding reference count set so that it > won't be freed too early in any case. > Worse, that part was interacting badly with the hack used to break > circular references in gfc_release_symbol, so it was better left out. > > Anyway, this is regression tested[*] on x86_64-unknown-linux-gnu. OK for > trunk/4.9/4.8 ? > > Mikael > > [*] I have a few failing testcases (also without the patch), namely the > following; does this ring a bell ? > FAIL: gfortran.dg/erf_3.F90 > FAIL: gfortran.dg/fmt_g0_7.f08 > FAIL: gfortran.dg/fmt_en.f90 > FAIL: gfortran.dg/nan_7.f90 > FAIL: gfortran.dg/quad_2.f90 > FAIL: gfortran.dg/quad_3.f90 > FAIL: gfortran.dg/round_4.f90 -- Outside of a dog, a book is a man's best friend. Inside of a dog it's too dark to read. Groucho Marx
Strengthen ICF hash
Hi, getting more familiar with ipa-icf I start to understand why it is a compile time hog for firefox. I assumed it spends most of time streaming in bodies and comparing them to see they are equivalent (after all about 10% of all symbols turns out to be and each of that needs to be read to memory). In fact most of time is actually spent by congreuence subdivision and calling final compares in cases that are doomed to fail. This is caused by a weak hash fixed in this patch and the fact that congruence solver works way too hard - it could hash in the information known at WPA time before starting the equivalence busyness. Grepping the ICF logs, the most common reasons for mismatched went from about 2million hits to about 300k. The hash itself is quite simple (borrowing incremental hash for constants adding very simple match for other stuff + logic to skip things that may match even if they are syntactticaly different). The hash can be strenghtened significantly, but I suppose we may do it based on actual profiling. It also is loosely based on varasm.c constant pool hash implementation that was OK for years. Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza * ipa-icf.c (sem_function::init): Fix formating; skip GIMPLE_PREDICT. (sem_item::add_expr): New function. (sem_function::hash_stmt): Handle operands of most statements. (sem_variable::get_hash): Hash the actual constructor. * ipa-icf.h (sem_item): Add add_expr. (sem_function): Update prototype of hash_stmt Index: ipa-icf.c === --- ipa-icf.c (revision 221090) +++ ipa-icf.c (working copy) @@ -1030,7 +1030,8 @@ sem_function::init (void) unsigned nondbg_stmt_count = 0; edge e; -for (edge_iterator ei = ei_start (bb->preds); ei_cond (ei, &e); ei_next (&ei)) +for (edge_iterator ei = ei_start (bb->preds); ei_cond (ei, &e); +ei_next (&ei)) cfg_checksum = iterative_hash_host_wide_int (e->flags, cfg_checksum); @@ -1039,9 +1040,10 @@ sem_function::init (void) { gimple stmt = gsi_stmt (gsi); - if (gimple_code (stmt) != GIMPLE_DEBUG) + if (gimple_code (stmt) != GIMPLE_DEBUG + && gimple_code (stmt) != GIMPLE_PREDICT) { - hash_stmt (&hstate, stmt); + hash_stmt (stmt, hstate); nondbg_stmt_count++; } } @@ -1051,7 +1053,8 @@ sem_function::init (void) /* Inserting basic block to hash table. */ sem_bb *semantic_bb = new sem_bb (bb, nondbg_stmt_count, - EDGE_COUNT (bb->preds) + EDGE_COUNT (bb->succs)); + EDGE_COUNT (bb->preds) + + EDGE_COUNT (bb->succs)); bb_sorted.safe_push (semantic_bb); } @@ -1059,52 +1062,120 @@ sem_function::init (void) parse_tree_args (); } +/* Accumulate to HSTATE a hash of expression EXP. + Identical to inchash::add_expr, but guaranteed to be stable across LTO + and DECL equality classes. */ + +void +sem_item::add_expr (const_tree exp, inchash::hash &hstate) +{ + if (exp == NULL_TREE) +{ + hstate.merge_hash (0); + return; +} + + /* Handled component can be matched in a cureful way proving equivalence + even if they syntactically differ. Just skip them. */ + STRIP_NOPS (exp); + while (handled_component_p (exp)) +exp = TREE_OPERAND (exp, 0); + + enum tree_code code = TREE_CODE (exp); + hstate.add_int (code); + + switch (code) +{ +/* Use inchash::add_expr for everything that is LTO stable. */ +case VOID_CST: +case INTEGER_CST: +case REAL_CST: +case FIXED_CST: +case STRING_CST: +case COMPLEX_CST: +case VECTOR_CST: + inchash::add_expr (exp, hstate); + break; +case CONSTRUCTOR: + { + unsigned HOST_WIDE_INT idx; + tree value; + + hstate.add_wide_int (int_size_in_bytes (TREE_TYPE (exp))); + + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) + if (value) + add_expr (value, hstate); + break; + } +case ADDR_EXPR: +case FDESC_EXPR: + add_expr (get_base_address (TREE_OPERAND (exp, 0)), hstate); + break; +case SSA_NAME: +case VAR_DECL: +case CONST_DECL: +case PARM_DECL: + hstate.add_wide_int (int_size_in_bytes (TREE_TYPE (exp))); + break; +case MEM_REF: +case POINTER_PLUS_EXPR: +case MINUS_EXPR: +case RANGE_EXPR: + add_expr (TREE_OPERAND (exp, 0), hstate); + add_expr (TREE_OPERAND (exp, 1), hstate); + break; +case PLUS_EXPR: + { + inchash::hash one, two; + add_expr (TREE_OPERAND (exp, 0), one); + add_expr (TREE_OPERAND (exp, 1), two); + hstate.add_commutative (one, two); + } + break; +CASE_CONVERT: + hstate.add_wide_int (int_size_in_bytes (TREE_TYPE (exp))
Re: [PATCH] ubsan: improve bounds checking, add -fsanitize=bounds-strict
Bootstrap and regression tested on x86_64. A ubsan-bootstrap for C and C++ works too (although there are other unrelated runtime errors). I tried a bootstrap with -fsanitize=bounds-strict and there are indeed many additional runtime errors due the struct hack with last array element of size 1 (or even 2). So Jakub and Richard were right and putting this into a separate option was the right thing to do. Code-wise it seems to come just from a couple of places such as (rtl.h, tree.h, vec.h, sbitmap.h, ...). Just to see how hard it would be to make this work with strict bounds checking, I started doing this in my tree using a macro: #define CAST_TO_POINTER(x) ((__typeof(x[0])*)(x)) For example, #define RTL_CHECK1(RTX, N, C1) ((RTX)->u.fld[N]) then becomes #define RTL_CHECK1(RTX, N, C1) \ (CAST_TO_POINTER((RTX)->u.fld)[N]) Doing this in a few places gets rid of most of the errors rather quickly (getting rid of all errors would be a bit more work). If one allows VLAs one could also cast to an array of the correct length: #defined CAST_TO_VLA(x, len) (*(__typeof(x[0])(*)[len])&x) For example: #define RTL_CHECK1(RTX, N, C1) \ (CAST_TO_VLA((RTX)->u.fld, GET_RTX_LENGTH( ... ))[N]) and have ubsan auto-generate the bound checking which are now often manually added. Martin Martin Uecker : > > I tested Marek's proposed change and it works correctly, > i.e. arrays which are not part of a struct are now > instrumented when accessed through a pointer. This also > means that the following case is diagnosed (correctly) > as undefined behaviour as pointed out by Richard: > > int > main (void) > { > int *t = (int *) __builtin_malloc (sizeof (int) * 9); > int (*a)[3][3] = (int (*)[3][3])t; > (*a)[0][9] = 1; > } > > > I also wanted arrays which are the last elements of a > struct which are not flexible-array members instrumented > correctly. So I added -fsantitize=bounds-strict which does > this. It seems to do instrumentation similar to clang > with -fsanitize=bounds. > > Comments? > > (regression testing in progress, but ubsan-related > tests all pass) > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > index ec2cb69..cb6df20 100644 > --- a/gcc/ChangeLog > +++ b/gcc/ChangeLog > @@ -1,3 +1,11 @@ > +2015-02-27 Martin Uecker > + > + * opts.c(common_handle_option): Add option for > + -fsanitize=bounds-strict > + * flag-types.h: Add SANITIZE_BOUNDS_STRICT > + * doc/invoke.texi: Improve description for > + -fsanitize=bounds and document -fsanitize=bounds-strict > + > diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog > index ffa01c6..44a1761 100644 > --- a/gcc/c-family/ChangeLog > +++ b/gcc/c-family/ChangeLog > @@ -1,3 +1,9 @@ > +2015-02-27 Martin Uecker > + > + * c-ubsan.c (ubsan_instrument_bounds): Instrument > + arrays which are accessed directly through a pointer. > + For strict checking, instrument last elements of a struct. > + > diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c > index 90d59c0..1a0e2da 100644 > --- a/gcc/c-family/c-ubsan.c > +++ b/gcc/c-family/c-ubsan.c > @@ -293,6 +293,7 @@ ubsan_instrument_bounds (location_t loc, tree array, tree > *index, >tree type = TREE_TYPE (array); >tree domain = TYPE_DOMAIN (type); > > + /* This also takes care of flexible array members. */ >if (domain == NULL_TREE || TYPE_MAX_VALUE (domain) == NULL_TREE) > return NULL_TREE; > > @@ -301,10 +302,13 @@ ubsan_instrument_bounds (location_t loc, tree array, > tree *index, > bound = fold_build2 (PLUS_EXPR, TREE_TYPE (bound), bound, >build_int_cst (TREE_TYPE (bound), 1)); > > - /* Detect flexible array members and suchlike. */ > + /* Don't instrument arrays which are the last element of > + a struct. */ >tree base = get_base_address (array); > - if (base && (TREE_CODE (base) == INDIRECT_REF > -|| TREE_CODE (base) == MEM_REF)) > + if (!(flag_sanitize & SANITIZE_BOUNDS_STRICT) > + && (TREE_CODE (array) == COMPONENT_REF) > + && base && (TREE_CODE (base) == INDIRECT_REF > + || TREE_CODE (base) == MEM_REF)) > { >tree next = NULL_TREE; >tree cref = array; > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index ef4cc75..5a93757 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -5704,8 +5704,15 @@ a++; > @item -fsanitize=bounds > @opindex fsanitize=bounds > This option enables instrumentation of array bounds. Various out of bounds > -accesses are detected. Flexible array members and initializers of variables > -with static storage are not instrumented. > +accesses are detected. Accesses to arrays which are the last member of a > +struct and initializers of variables with static storage are not > instrumented. > + > +@item -fsanitize=bounds-strict > +@opindex fsanitize=bounds-strict > +This option enables strict instrumentation of array bounds. Most out of > bounds > +accesses are dete
Re: [RFC 1/2] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
On Sat, 28 Feb 2015, Max Filippov wrote: > This allows a target to support both windowed and non-windowed ABI. > > 2015-02-28 Max Filippov > > gcc/ > * builtins.c (expand_builtin_return_addr): Add > RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition. If you change the semantics of a target macro you need to update the documentation in tm.texi.in. I'd say you should also change the semantics properly to true/false, not a tristate true/false/undefined (i.e., add a default 0 to defaults.h and remove the #ifdef). -- Joseph S. Myers jos...@codesourcery.com
[PATCH] Fix PR c++/65154 (ICE on braced initializer)
The following patch is supposed to fix the problem related to initializing an array of aggregates with members, which have user-defined default constructors. Bootstrapped and regtested on x86_64-unknown-linux-gnu. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 0274663..0f53146 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3716,11 +3716,9 @@ build_vec_init (tree base, tree maxindex, tree init, { if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) { - if (BRACE_ENCLOSED_INITIALIZER_P (init) - && CONSTRUCTOR_NELTS (init) == 0) - /* Reuse it. */; - else - init = build_constructor (init_list_type_node, NULL); + /* We cannot reuse INIT here, because it must not be shared +with member initializers. */ + init = build_constructor (init_list_type_node, NULL); CONSTRUCTOR_IS_DIRECT_INIT (init) = true; } else diff --git a/gcc/testsuite/g++.dg/init/array39.C b/gcc/testsuite/g++.dg/init/array39.C new file mode 100644 index 000..2fd8937 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array39.C @@ -0,0 +1,46 @@ +// PR c++/65154 +// { dg-do run { target c++11 } } + +int cnt1 = 0, +cnt2 = 0; + +struct S_empty +{ +S_empty () { + cnt1++; +}; +}; + +struct C1 +{ + S_empty s; +}; + +struct S_init +{ + S_init () : i(42) + { +cnt2++; + }; + int i; +}; + +struct C2 +{ + S_init a, b; +}; + +int +main () +{ + C1 c1[5]{}; + C2 c2[1]{}; + + if (c2[0].a.i != 42 || c2[0].b.i != 42) +return 1; + + if (cnt1 != 5 || cnt2 != 2) +return 1; + + return 0; +} Changelog record: 2015-03-02 Mikhail Maltsev PR c++/65154 * gcc/cp/init.c (build_vec_init): Fixed initializing aggregates with empty init list. * gcc/testsuite/g++.dg/init/array39.C: New test. N.B.: Consider the test case. The constructors of S_init and S_empty are called from main (this can be seen in GIMPLE dump, right after gimplification), while clang, for example, generates an explicit call to constructors of C1 and C2. GCC does the same, if direct initializers are removed. I don't know, if such behavior is OK or not. -- Regards, Mikhail Maltsev
[Patch, Fortran] Fix ATOMIC checks
This patch changes the coarray/coindexed check to match what the error message already claimed. OK for the trunk? Tobias diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 3be4fb1..cdb5ff1 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -1022,7 +1022,7 @@ gfc_check_atomic (gfc_expr *atom, int atom_no, gfc_expr *value, int val_no, return false; } - if (!gfc_expr_attr (atom).codimension) + if (!gfc_is_coarray (atom) && !gfc_is_coindexed (atom)) { gfc_error ("ATOM argument at %L of the %s intrinsic function shall be a " "coarray or coindexed", &atom->where, gfc_current_intrinsic); diff --git a/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90 b/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90 new file mode 100644 index 000..ae155ec --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90 @@ -0,0 +1,36 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! Contributed by Reinhold Bader +! +! +program def_and_ref +! compile only + use, intrinsic :: iso_fortran_env + implicit none + type :: e +integer(kind=atomic_int_kind) :: ia = 0 +logical(kind=atomic_logical_kind) :: la = .false. + end type + + type(e) :: a[*] + + integer :: ival = 0 + logical :: lval = .false. + + if (this_image() == 1) then +call atomic_define(a[num_images()]%ia, 4) +call atomic_define(a[num_images()]%la, .true.) + end if + if (this_image() == num_images()) then +do while (ival == 0 .and. .not. lval) + call atomic_ref(ival, a%ia) + call atomic_ref(lval, a%la) +end do +if (ival == 4 .and. lval) then + write(*,*) 'OK' +else + write(*,*) 'FAIL: ival,lval =', ival, lval +end if + end if +end program
Re: [PATCH] ICF is more strict about non-common function and var, attributes.
> >and thus we will hapilly merge types with different TYPE_ALIGN. > >Should func_checker::types_compatible be extended to compare these? > >Clearly TYPE_ALIGN matters for vectorizer and other plaes... > > But it matters on MEM_REFs only, and you can't use canonical types for that. > And we don't. Tree merging correctly takes TYPE_ALING into account. Yep, I wonder about ICF that will match the different MEM_REFs based on useless type conversion assumptions. In fact here is a wrong code testcase: $ more t.c struct a { int a[10]; } __attribute__ ((aligned (32))); struct b { int a[10]; }; t2(struct a *a) { int i; for (i=0;i<10;i++) a->a[i]++; } t(struct b *a) { int i; for (i=0;i<10;i++) a->a[i]++; } $ ./xgcc -B ./ -O3 t.c -flto -c -fno-inline t.c:10:1: warning: return type defaults to �int� [-Wimplicit-int] t2(struct a *a) ^ t.c:16:1: warning: return type defaults to �int� [-Wimplicit-int] t(struct b *a) ^ $ ./xgcc -B ./ -O3 t.o -flto -r -nostdlib $ objdump a.out -d a.out: file format elf64-x86-64 Disassembly of section .text: : 0: 48 8d 87 80 1a 06 00lea0x61a80(%rdi),%rax 7: 66 0f 6f 0d 00 00 00movdqa 0x0(%rip),%xmm1# f e: 00 f: 90 nop 10: 48 83 c7 10 add$0x10,%rdi 14: 66 0f 6f 47 f0 movdqa -0x10(%rdi),%xmm0 19: 66 0f fe c1 paddd %xmm1,%xmm0 1d: 0f 29 47 f0 movaps %xmm0,-0x10(%rdi) 21: 48 39 c7cmp%rax,%rdi 24: 75 ea jne10 26: f3 c3 repz retq 28: 0f 1f 84 00 00 00 00nopl 0x0(%rax,%rax,1) 2f: 00 0030 : 30: e9 00 00 00 00 jmpq 35 Function t should have alignment prologue. We need to match additional MEMREF properties I suppose, including alignment etc. Honza
Re: [PATCH] ICF is more strict about non-common function and var, attributes.
> > >and thus we will hapilly merge types with different TYPE_ALIGN. > > >Should func_checker::types_compatible be extended to compare these? > > >Clearly TYPE_ALIGN matters for vectorizer and other plaes... > > > > But it matters on MEM_REFs only, and you can't use canonical types for that. > > And we don't. Tree merging correctly takes TYPE_ALING into account. > > Yep, I wonder about ICF that will match the different MEM_REFs based on > useless > type conversion assumptions. In fact here is a wrong code testcase: Now tracked as PR65270 Honza
Re: [PATCH] ICF: move readonly decision for variables to the right place
Hi, my comments to your patch was not complete. ipa-icf is quite confused about how to get the constructor. This is how it works: In during in_lto_p DECL_INITIAL may be set to error_mark_node and once you really want to have the constructor there is varpool_node->get_constuctor method. Because in majority cases we care about constructor either when we output the initializer or when we want to use it for folding I also added function ctor_for_fodling that returns the constructor or error_mark_node when for some reason the folding is unsafe (for example the variable is interposable). Now ipa-ICF actually calls ctor_for_folding for every variable it considers that will lead to a lot of streaming at WPA time, but it also check DECL_INITIAL to not be error_mark_node, so it think at WPA, the unification was limited to virtual tables only in case the ctors was already brought in by the devirtualization machinery. This patch prepares for the actual fix by introducing WPA comparsion the same was as already done for function. I also proofread sem_variable::equals and compared it to varasm.c compare_constant that is doing exactly the same to unify constant pool variables. There were quite few disprepancies (such as forgotten checks for start of arrays), so I decided to bring the implementationfrom varasm.c as it is better tested. The code is bit fancier trying to prove equivalence despite bit different representation, but not by too much. There are two additional fixes. I forbidden mixing data from different sections. In the cases like kernel, where one section may be discarded from memory this is clearly undesirable. I also noticed that we fixed the CONSTANT_POOL problem twice, so removed the check in sem_variable::equals. For complete paranoia I also forbidden unification of DECL_VIRTUAL and !DECL_VIRTUAL. One cares about addresses while other doesn't. I do not think it can make difference in practice as there is no valid way to write identical datastructure to a virtual table. Next stage1 we ought to unify the code and perhaps use ICF macinery to replace tree constant pool. Bootstrapped/regtested x86_64-linux, comited. Honza * ipa-icf.c: Include stor-layout.h (sem_function::compare_cgraph_references): Rename to ... (sem_item::compare_cgraph_references): ... this one. (sem_variable::equals_wpa): New function (sem_variable::equals): Do not check stuff already verified by equals_wpa. (sem_variable::equals): Reorg based on varasm.c:compare_constant. * ipa-icf.h (sem_item): Add compare_cgraph_references. (sem_function): Remove compare_cgraph_references. (sem_variable): Turns equals_wpa into non-inline. Index: ipa-icf.c === --- ipa-icf.c (revision 221092) +++ ipa-icf.c (working copy) @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. #include "config.h" #include "system.h" +#include #include "coretypes.h" #include "hash-set.h" #include "machmode.h" @@ -119,9 +120,9 @@ along with GCC; see the file COPYING3. #include "lto-streamer.h" #include "data-streamer.h" #include "ipa-utils.h" -#include #include "ipa-icf-gimple.h" #include "ipa-icf.h" +#include "stor-layout.h" using namespace ipa_icf_gimple; @@ -338,7 +339,7 @@ sem_function::get_hash (void) contains these nodes. ADDRESS indicate if address is taken. */ bool -sem_function::compare_cgraph_references ( +sem_item::compare_cgraph_references ( hash_map &ignored_nodes, symtab_node *n1, symtab_node *n2, bool address) { @@ -1395,6 +1396,58 @@ sem_variable::sem_variable (varpool_node gcc_checking_assert (get_node ()); } +/* Fast equality function based on knowledge known in WPA. */ + +bool +sem_variable::equals_wpa (sem_item *item, + hash_map &ignored_nodes) +{ + gcc_assert (item->type == VAR); + + sem_variable *compared_var = static_cast (item); + + if (node->num_references () != item->node->num_references ()) +return return_false_with_msg ("different number of references"); + + if (DECL_TLS_MODEL (decl) || DECL_TLS_MODEL (item->decl)) +return return_false_with_msg ("TLS model"); + + if (DECL_ALIGN (decl) != DECL_ALIGN (item->decl)) +return return_false_with_msg ("alignment mismatch"); + + if (DECL_VIRTUAL_P (decl) != DECL_VIRTUAL_P (item->decl)) +return return_false_with_msg ("Virtual flag mismatch"); + + if (DECL_SIZE (decl) != DECL_SIZE (item->decl) + && ((!DECL_SIZE (decl) || !DECL_SIZE (item->decl)) + || !operand_equal_p (DECL_SIZE (decl), + DECL_SIZE (item->decl), OEP_ONLY_CONST))) +return return_false_with_msg ("size mismatch"); + + /* Do not attempt to mix data from different user sections; + we do not know what user intends with those. */ + if (((DECL_SECTION_NAME (decl) && !node->implicit_section) + || (DECL_SECTION_NAME (item->decl) && !item->nod
[PATCH][ARM]Automatically add -mthumb for thumb-only target when mode isn't specified
Hi there, If target mode isn't specified via either gcc configuration option --with-mode or command line, this patch intends to improve gcc driver to automatically add option -mthumb for thumb-only target. Tested with gcc regression test for various arm targets, no regression. Is it OK? BR, Terry gcc/ChangeLog: 2015-03-02 Terry Guo * common/config/arm/arm-common.c (arm_is_target_thumb_only): New function. * config/arm/arm-protos.h (FL_ Macros): Move to ... * config/arm/arm-opts.h (FL_ Macros): ... here. (struct arm_arch_core_flag): New struct. (arm_arch_core_flags): New array for arch/core and flag map. * config/arm/arm.h (MODE_SET_SPEC_FUNCTIONS): Define new SPEC function. (EXTRA_SPEC_FUNCTIONS): Include new SPEC function. (MODE_SET_SPECS): New SPEC. (DRIVER_SELF_SPECS): Include new SPEC.diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 86673b7..e17ee03 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -97,6 +97,28 @@ arm_rewrite_mcpu (int argc, const char **argv) return arm_rewrite_selected_cpu (argv[argc - 1]); } +/* Called by driver to check whether the target denoted by current + command line options is thumb-only target. If -march present, + check the last -march option. If no -march, check the last -mcpu + option. */ +const char * +arm_is_target_thumb_only (int argc, const char **argv) +{ + unsigned int opt; + + if (argc) +{ + for (opt = 0; opt < (ARRAY_SIZE (arm_arch_core_flags) - 1); opt++) + if ((strcmp (argv[argc - 1], arm_arch_core_flags[opt].name) == 0) + && ((arm_arch_core_flags[opt].flags & FL_NOTM) == 0)) + return "-mthumb"; + + return NULL; +} + else +return NULL; +} + #undef ARM_CPU_NAME_LENGTH diff --git a/gcc/config/arm/arm-opts.h b/gcc/config/arm/arm-opts.h index 039e333..222d20e 100644 --- a/gcc/config/arm/arm-opts.h +++ b/gcc/config/arm/arm-opts.h @@ -77,4 +77,93 @@ enum arm_tls_type { TLS_GNU, TLS_GNU2 }; + +/* Flags used to identify the presence of processor capabilities. */ + +/* Bit values used to identify processor capabilities. */ +#define FL_CO_PROC(1 << 0)/* Has external co-processor bus */ +#define FL_ARCH3M (1 << 1)/* Extended multiply */ +#define FL_MODE26 (1 << 2)/* 26-bit mode support */ +#define FL_MODE32 (1 << 3)/* 32-bit mode support */ +#define FL_ARCH4 (1 << 4)/* Architecture rel 4 */ +#define FL_ARCH5 (1 << 5)/* Architecture rel 5 */ +#define FL_THUMB (1 << 6)/* Thumb aware */ +#define FL_LDSCHED(1 << 7) /* Load scheduling necessary */ +#define FL_STRONG (1 << 8) /* StrongARM */ +#define FL_ARCH5E (1 << 9)/* DSP extensions to v5 */ +#define FL_XSCALE (1 << 10) /* XScale */ +/* spare (1 << 11) */ +#define FL_ARCH6 (1 << 12) /* Architecture rel 6. Adds +media instructions. */ +#define FL_VFPV2 (1 << 13) /* Vector Floating Point V2. */ +#define FL_WBUF (1 << 14) /* Schedule for write buffer ops. +Note: ARM6 & 7 derivatives only. */ +#define FL_ARCH6K (1 << 15) /* Architecture rel 6 K extensions. */ +#define FL_THUMB2 (1 << 16) /* Thumb-2. */ +#define FL_NOTM (1 << 17) /* Instructions not present in the 'M' +profile. */ +#define FL_THUMB_DIV (1 << 18) /* Hardware divide (Thumb mode). */ +#define FL_VFPV3 (1 << 19) /* Vector Floating Point V3. */ +#define FL_NEON (1 << 20) /* Neon instructions. */ +#define FL_ARCH7EM(1 << 21) /* Instructions present in the ARMv7E-M +architecture. */ +#define FL_ARCH7 (1 << 22) /* Architecture 7. */ +#define FL_ARM_DIV(1 << 23) /* Hardware divide (ARM mode). */ +#define FL_ARCH8 (1 << 24) /* Architecture 8. */ +#define FL_CRC32 (1 << 25) /* ARMv8 CRC32 instructions. */ + +#define FL_SMALLMUL (1 << 26) /* Small multiply supported. */ + +#define FL_IWMMXT (1 << 29) /* XScale v2 or "Intel Wireless MMX technology". */ +#define FL_IWMMXT2(1 << 30) /* "Intel Wireless MMX2 technology". */ + +/* Flags that only effect tuning, not available instructions. */ +#define FL_TUNE(FL_WBUF | FL_VFPV2 | FL_STRONG | FL_LDSCHED \ +| FL_CO_PROC) + +#define FL_FOR_ARCH2 FL_NOTM +#define FL_FOR_ARCH3 (FL_FOR_ARCH2 | FL_MODE32) +#define FL_FOR_ARCH3M (FL_FOR_ARCH3 | FL_ARCH3M) +#define FL_FOR_ARCH4 (FL_FOR_ARCH3M | FL_ARCH4) +#define FL_FOR_ARCH4T (FL_FOR_ARCH4 | FL_THUMB) +#define FL_FOR_ARCH5 (FL_FOR_ARCH4 | FL_ARCH5) +
Re: Strengthen ICF hash
Jan Hubicka writes: > > The hash itself is quite simple (borrowing incremental hash for constants > adding > very simple match for other stuff + logic to skip things that may match even > if > they are syntactticaly different). The hash can be strenghtened significantly, > but I suppose we may do it based on actual profiling. It also is loosely based > on varasm.c constant pool hash implementation that was OK for years. FWIW i have some older patches to use a stronger/faster spooky hash for incremential hash. But I never submitted them because I wasn't able to show clear gains for the type hashing (that was the original motivator) since you fixed it. But if you're interested I can update them to the latest tree. spooky is very good at dealing with a lot of input data quickly. -Andi -- a...@linux.intel.com -- Speaking for myself only
Re: [RFC 1/2] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
On Mon, Mar 2, 2015 at 1:07 AM, Joseph Myers wrote: > > On Sat, 28 Feb 2015, Max Filippov wrote: > > > This allows a target to support both windowed and non-windowed ABI. > > > > 2015-02-28 Max Filippov > > > > gcc/ > > * builtins.c (expand_builtin_return_addr): Add > > RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition. > > If you change the semantics of a target macro you need to update the > documentation in tm.texi.in. I'd say you should also change the semantics > properly to true/false, not a tristate true/false/undefined (i.e., add a > default 0 to defaults.h and remove the #ifdef). Will do. Thanks! -- Max
[patch/committed] PR middle-end/65233 make walk-ssa_copies handle empty PHIs
As I mention in the PR... What's happening here is that the ipa_polymorphic_call_context constructor is calling walk_ssa_copies on a PHI node that has no arguments. This happens because finalize_jump_threads eventually removes some PHI arguments as it's redirecting some edges, leaving a PHI with no arguments: SR.33_23 = PHI <> This should get cleaned up later, but the IPA polymorphic code gets called during the actual CFG clean-up, and walk_ssa_copies cannot handle an empty PHI. Approved by Honza. Fully tested on x86-64 Linux and verified that the patch fixes the ICE on an x86-64 Linux cross aarch64-linux-gnu cc1plus. Committed to mainline. commit cdb5a8f26178f61d6a2fdb2543f6c8b4c7136c94 Author: Aldy Hernandez Date: Sun Mar 1 21:21:37 2015 -0800 PR middle-end/65233 * ipa-polymorphic-call.c (walk_ssa_copies): Handle empty PHIs. diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index aaa549e..13cc7f6 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -835,7 +835,10 @@ walk_ssa_copies (tree op, hash_set **global_visited = NULL) { gimple phi = SSA_NAME_DEF_STMT (op); - if (gimple_phi_num_args (phi) > 2) + if (gimple_phi_num_args (phi) > 2 + /* We can be called while cleaning up the CFG and can +have empty PHIs about to be removed. */ + || gimple_phi_num_args (phi) == 0) goto done; if (gimple_phi_num_args (phi) == 1) op = gimple_phi_arg_def (phi, 0);
Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol
On Sun, Mar 01, 2015 at 07:33:14AM -0800, H.J. Lu wrote: > +mcopyreloc-in-pie I'm not calling for a change in the name of the option (*), but technically it isn't completely correct to call your optimisation "copy reloc in pie". What you are really doing is using a linker generated variable (in .dynbss of an executable), in place of a variable definition in a shared library. Not all such variables use copy relocs! So it is quite possible for your optimisation to trigger but there be no sign of an R__COPY relocation in the final executable. I do think your documentation should be talking about .dynbss copies of variables rather than copy relocations, which are just a way of initializing such variables. *) I should have fixed the name of the linker option added here: https://sourceware.org/ml/binutils/2001-09/msg00506.html -- Alan Modra Australia Development Lab, IBM
Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol
On Sat, Feb 28, 2015 at 5:42 PM, H.J. Lu wrote: > Ue copy relocation in PIE improves performance. But copy relocation > can't be used to access protected symbols defined in shared libaries > and linker in binutils 2.26 enforces doesn't allow it. GCC doesn't > know if an external definition is protected or not. This option adds > -mcopyreloc-in-pie to give user an option to turn it off to avoid problem > at link-time. OK for trunk? If the option does not work universally for all cases, then the default should be off. Uros.
Re: [PATCH] ICF: move readonly decision for variables to the right place
Hi, this is a variant of patch I commited. It takes care to load the constructor to memory in sem_variable::equals and donot touch it earlier. I also made sem_variable::parse to skip volatile and reigster variables. Bootstrapped/regtested x86_64-linux, lto-bootstrapped with -fmerge-all-constants comitted. Honza 2015-02-28 Martin Liska Jan Hubicka * ipa-icf.c (sem_variable::equals): Improve debug output; get variable constructor. (sem_variable::parse): Do not filter out too early; give up on volatile and register vars. (sem_item_optimizer::filter_removed_items): Filter out nonreadonly variables. * ipa-icf.h (sem_variable::init): Do not set ctor. (sem_variable::ctor): Remove. gcc/testsuite/ChangeLog: 2015-02-28 Martin Liska Jan Hubicka * gcc.dg/ipa/ipa-icf-35.c: New test. * gcc.dg/ipa/ipa-icf-36.c: New test. * gcc.dg/ipa/ipa-icf-37.c: New test. Index: ipa-icf.c === --- ipa-icf.c (revision 221096) +++ ipa-icf.c (working copy) @@ -1448,18 +1452,29 @@ sem_variable::equals_wpa (sem_item *item /* Returns true if the item equals to ITEM given as argument. */ +/* Returns true if the item equals to ITEM given as argument. */ + bool sem_variable::equals (sem_item *item, - hash_map & ARG_UNUSED (ignored_nodes)) + hash_map &) { gcc_assert (item->type == VAR); + bool ret; - sem_variable *v = static_cast(item); - - if (!ctor || !v->ctor) -return return_false_with_msg ("ctor is missing for semantic variable"); + if (DECL_INITIAL (decl) == error_mark_node && in_lto_p) +dyn_cast (node)->get_constructor (); + if (DECL_INITIAL (item->decl) == error_mark_node && in_lto_p) +dyn_cast (item->node)->get_constructor (); + + ret = sem_variable::equals (DECL_INITIAL (decl), + DECL_INITIAL (item->node->decl)); + if (dump_file && (dump_flags & TDF_DETAILS)) +fprintf (dump_file, +"Equals called for vars:%s:%s (%u:%u) (%s:%s) with result: %s\n\n", +name(), item->name (), node->order, item->node->order, asm_name (), +item->asm_name (), ret ? "true" : "false"); - return sem_variable::equals (ctor, v->ctor); + return ret; } /* Compares trees T1 and T2 for semantic equality. */ @@ -1653,24 +1668,7 @@ sem_variable::equals (tree t1, tree t2) sem_variable * sem_variable::parse (varpool_node *node, bitmap_obstack *stack) { - tree decl = node->decl; - - if (node->alias) -return NULL; - - bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl); - if (!readonly) -return NULL; - - bool can_handle = DECL_VIRTUAL_P (decl) - || flag_merge_constants >= 2 - || (!TREE_ADDRESSABLE (decl) && !node->externally_visible); - - if (!can_handle || DECL_EXTERNAL (decl)) -return NULL; - - tree ctor = ctor_for_folding (decl); - if (!ctor) + if (TREE_THIS_VOLATILE (node->decl) || DECL_HARD_REGISTER (node->decl)) return NULL; sem_variable *v = new sem_variable (node, 0, stack); @@ -1686,8 +1684,8 @@ hashval_t sem_variable::get_hash (void) { if (hash) -return hash; +return hash; /* All WPA streamed in symbols should have their hashes computed at compile time. At this point, the constructor may not be in memory at all. DECL_INITIAL (decl) would be error_mark_node in that case. */ @@ -2155,7 +2153,14 @@ sem_item_optimizer::filter_removed_items if (!flag_ipa_icf_variables) remove_item (item); else - filtered.safe_push (item); + { + /* Filter out non-readonly variables. */ + tree decl = item->decl; + if (TREE_READONLY (decl)) + filtered.safe_push (item); + else + remove_item (item); + } } } Index: ipa-icf.h === --- ipa-icf.h (revision 221096) +++ ipa-icf.h (working copy) @@ -393,7 +393,6 @@ public: inline virtual void init (void) { decl = get_node ()->decl; -ctor = ctor_for_folding (decl); } virtual hashval_t get_hash (void); @@ -415,9 +414,6 @@ public: /* Parser function that visits a varpool NODE. */ static sem_variable *parse (varpool_node *node, bitmap_obstack *stack); - /* Variable constructor. */ - tree ctor; - private: /* Iterates though a constructor and identifies tree references we are interested in semantic function equality. */ Index: testsuite/gcc.dg/ipa/ipa-icf-35.c === --- testsuite/gcc.dg/ipa/ipa-icf-35.c (revision 0) +++ testsuite/gcc.dg/ipa/ipa-icf-35.c (revision 0) @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +void