Re: Do not produce empty try-finally statements
Jakub Jelinek wrote: >On Sun, Jan 19, 2014 at 11:46:09PM +0100, Jan Hubicka wrote: >> Bootstrapped/regtested x86_64-linux, OK? > >This looks very wrong. By ignoring the clobbers in the cleanups you >ensure clobbers are hardly ever emitted, but the TRY/FINALLY is the way >how >to make sure the clobbers appear in all the places where they are >supposed >to be, so that DSE, expansion etc. can take advantage of them. >Just look at say: >struct A { char buf[64]; }; >void foo (char *); >void test () >{ > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } >} >where with your patch we don't DSE the a.buf[6] and a.buf[7] stores >anymore. > >If optimize_clobbers isn't performed at -O0, perhaps we should consider >performing at at -O0 (just that and not the other EH optimizations)? Or, as clobbers are removed during rtl expansion make sure we remove empty eh stuff there? Richard. > Jakub
Re: [Patch] Fix regex multiple consecutive quantifiers bug.
On Sun, Jan 19, 2014 at 4:59 PM, Tim Shen wrote: > Tested and committed. It's quite interesting that after this change in the patch: - this->_M_quantifier(); + while (this->_M_quantifier()); ...even the regex input is nothing to do with quantifiers at all (say regex re(" ")), g++ -O3 generates slower code than -O2: ~ # g++ -O2 perf.cc && time ./a.out ./a.out 0.46s user 0.00s system 99% cpu 0.461 total ~ # g++ -O3 perf.cc && time ./a.out ./a.out 0.56s user 0.00s system 99% cpu 0.569 total perf.cc is almost the same as testsuite/performance/28_regex/split.cc. Following the man page, I found that g++ claims that the difference between -O3 and -O2 are: ~ # /usr/bin/g++ -c -Q -O3 --help=optimizers > /tmp/O3-opts ~ # /usr/bin/g++ -c -Q -O2 --help=optimizers > /tmp/O2-opts ~ # diff /tmp/O2-opts /tmp/O3-opts | grep enabled > -fgcse-after-reload [enabled] > -finline-functions [enabled] > -fipa-cp-clone [enabled] > -fpredictive-commoning [enabled] > -ftree-loop-distribute-patterns [enabled] > -ftree-loop-vectorize [enabled] > -ftree-partial-pre [enabled] > -ftree-slp-vectorize[enabled] > -funswitch-loops[enabled] However, -O2 with those flags give me a postive result: ~ # g++ -O2 perf.cc -fgcse-after-reload -finline-functions -fipa-cp-clone -fpredictive-commoning -ftree-loop-distribute-patterns -ftree-loop-vectorize -ftree-partial-pre -ftree-slp-vectorize -funswitch-loops && time ./a.out ./a.out 0.45s user 0.01s system 99% cpu 0.460 total By the way, my "g++" is alas to "g++ -g -Wall -std=c++11", and I'm sure -g doesn't matter. I don't know much about it. Is there any explanations as interesting as the question? ;) Thank you! -- Regards, Tim Shen
Re: [Patch] Fix regex multiple consecutive quantifiers bug.
On Mon, 20 Jan 2014, Tim Shen wrote: ...even the regex input is nothing to do with quantifiers at all (say regex re(" ")), g++ -O3 generates slower code than -O2: ~ # g++ -O2 perf.cc && time ./a.out ./a.out 0.46s user 0.00s system 99% cpu 0.461 total ~ # g++ -O3 perf.cc && time ./a.out ./a.out 0.56s user 0.00s system 99% cpu 0.569 total perf.cc is almost the same as testsuite/performance/28_regex/split.cc. Following the man page, I found that g++ claims that the difference between -O3 and -O2 are: It is a FAQ that you can't get the effects of -Oy with -Ox and a bunch of -f flags. Some things depend directly on the optimization level. Note that you can also try the reverse: start from -O3 and use -fno-* flags. I would first add -march=native to make sure this isn't the result of optimizing for a different platform. I would suggest you use -fdump-tree-optimized and look at the generated files at -O2 and -O3 and see (they are in a vaguely C-like dialect) if you can find a difference that might explain the result. If so, then you can use -fdump-tree-all and find out where exactly gcc is going wrong. If not, there is -da, but the files will be much harder to read. In any case, reducing the testcase can only make it easier to understand the issue. -- Marc Glisse
[PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)
Hi! As mentioned in the PR or even in the comment below, ix86_decompose_address sometimes sets parts.base to some REG and parts.disp to const0_rtx, even when the operands aren't of a lea insn, but normal or zero extending mov. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-01-20 Jakub Jelinek PR target/59880 * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false if operands[1] is a REG or ZERO_EXTEND of a REG. * gcc.target/i386/pr59880.c: New test. --- gcc/config/i386/i386.c.jj 2014-01-19 12:18:49.0 +0100 +++ gcc/config/i386/i386.c 2014-01-19 19:02:34.078168289 +0100 @@ -18159,8 +18159,19 @@ ix86_avoid_lea_for_addr (rtx insn, rtx o if (!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun)) return false; + /* The "at least two components" test below might not catch simple + *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is + non-NULL and parts.disp is const0_rtx as the only components in + the address, e.g. if the register is %rbp or %r13. As this + test is much cheaper and moves or zero extensions are the common + case, do this check first. */ + if (REG_P (operands[1]) + || (GET_CODE (operands[1]) == ZERO_EXTEND + && REG_P (XEXP (operands[1], 0 +return false; + /* Check it is correct to split here. */ - if (!ix86_ok_to_clobber_flags(insn)) + if (!ix86_ok_to_clobber_flags (insn)) return false; ok = ix86_decompose_address (operands[1], &parts); --- gcc/testsuite/gcc.target/i386/pr59880.c.jj 2014-01-19 19:24:44.094382629 +0100 +++ gcc/testsuite/gcc.target/i386/pr59880.c 2014-01-19 19:25:30.0 +0100 @@ -0,0 +1,14 @@ +/* PR target/59880 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mtune=silvermont" } */ + +register unsigned int r13 __asm ("r13"); +unsigned long long +foo (void) +{ + return r13; +} + +/* Ensure we don't emit a useless zero-extension after another + zero-extension. */ +/* { dg-final { scan-assembler-not "%eax, %eax" } } */ Jakub
Re: [Patch] Fix regex multiple consecutive quantifiers bug.
Hi, On 01/20/2014 09:31 AM, Marc Glisse wrote: It is a FAQ that you can't get the effects of -Oy with -Ox and a bunch of -f flags. Some things depend directly on the optimization level. For example, inlining of free functions. By the way, I think it is a *very* common experience that -O3 doesn't do better than -O2. Thus I'm not particularly surprised or worried ;) Paolo.
Re: [PATCH][buildrobot] PR59496: Fix unused variable warning
On Tue, Jan 14, 2014 at 05:59:11PM +0100, Jan-Benedict Glaw wrote: > 2014-01-14 Jan-Benedict Glaw > > PR bootstrap/59496 > * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Fix unused variable > warning. Ok, thanks. > diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h > index 43a2ab5..fc1f862 100644 > --- a/gcc/config/rs6000/darwin.h > +++ b/gcc/config/rs6000/darwin.h > @@ -328,9 +328,10 @@ extern int darwin_emit_branch_islands; > behavior is dealt with by > darwin_rs6000_special_round_type_align. */ > #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ > - (TARGET_ALIGN_NATURAL ? (COMPUTED) \ > - : (COMPUTED) == 128 ? 128 \ > - : MIN ((COMPUTED), 32)) > + ((void) (FIELD), \ > + (TARGET_ALIGN_NATURAL ? (COMPUTED)\ > +: (COMPUTED) == 128 ? 128\ > +: MIN ((COMPUTED), 32))) > > /* Darwin increases natural record alignment to doubleword if the first > field is an FP double while the FP fields remain word aligned. */ > Jakub
Re: [PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)
On Mon, Jan 20, 2014 at 9:38 AM, Jakub Jelinek wrote: > As mentioned in the PR or even in the comment below, ix86_decompose_address > sometimes sets parts.base to some REG and parts.disp to const0_rtx, even > when the operands aren't of a lea insn, but normal or zero extending mov. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for > trunk? > > 2014-01-20 Jakub Jelinek > > PR target/59880 > * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false > if operands[1] is a REG or ZERO_EXTEND of a REG. > > * gcc.target/i386/pr59880.c: New test. > --- gcc/config/i386/i386.c.jj 2014-01-19 12:18:49.0 +0100 > +++ gcc/config/i386/i386.c 2014-01-19 19:02:34.078168289 +0100 > @@ -18159,8 +18159,19 @@ ix86_avoid_lea_for_addr (rtx insn, rtx o >if (!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun)) > return false; > > + /* The "at least two components" test below might not catch simple > + *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is > + non-NULL and parts.disp is const0_rtx as the only components in > + the address, e.g. if the register is %rbp or %r13. As this > + test is much cheaper and moves or zero extensions are the common > + case, do this check first. */ > + if (REG_P (operands[1]) > + || (GET_CODE (operands[1]) == ZERO_EXTEND > + && REG_P (XEXP (operands[1], 0 > +return false; > + >/* Check it is correct to split here. */ > - if (!ix86_ok_to_clobber_flags(insn)) > + if (!ix86_ok_to_clobber_flags (insn)) > return false; > >ok = ix86_decompose_address (operands[1], &parts); > --- gcc/testsuite/gcc.target/i386/pr59880.c.jj 2014-01-19 19:24:44.094382629 > +0100 > +++ gcc/testsuite/gcc.target/i386/pr59880.c 2014-01-19 19:25:30.0 > +0100 > @@ -0,0 +1,14 @@ > +/* PR target/59880 */ > +/* { dg-do compile { target { ! ia32 } } } */ > +/* { dg-options "-O2 -mtune=silvermont" } */ > + > +register unsigned int r13 __asm ("r13"); > +unsigned long long > +foo (void) > +{ > + return r13; > +} > + > +/* Ensure we don't emit a useless zero-extension after another > + zero-extension. */ > +/* { dg-final { scan-assembler-not "%eax, %eax" } } */ > > Jakub This is OK for mainline, I will take care for a backport (together with 59379) to other release branches. Thanks, Uros.
Re: [PATCH] Don't combine across likely spilled hard reg setters (PR rtl-optimization/59477)
> I think the problem is still either a missed feature in LRA/reload > (split live-ranges), a problem in how we represent calls & argument > setup (magic hard-reg uses), or a backend problem (should spill > itself if necessary, via a post-reload splitter or always spill > and undo via a peephole2). > > Of course papering over in combine might be the best at this > stage. So the above was just observations from the less experienced > people in this area. Yes, this is ultimately a RA issue, but an ancient and hard one as far as I understand so papering over it makes sense I think. That being said, while Joern's machinery was IMO acceptable because relatively simple and localized, Jakub's looks more complicated and far-reaching (that's why I suggested to try to extend the existing machinery if possible) so I think that we ought to try something simpler first. -- Eric Botcazou
Re: Resolve pr44194-1.c failure by refining scan-rtl-dump-not pattern
> I have made the adjustment and test it. Please check the new attachment. Thanks, applied on the mainline as obvious. -- Eric Botcazou
Re: experimental testsuite patch
On 19 January 2014 20:50, François Dumont wrote: > So here is another patch proposal with the faulty debug assertion commented > for the moment. > > 2014-01-20 François Dumont > > > * scripts/create_testsuite_files: Add testsuite/experimental in > the list of folders to introspect for tests. > * include/experimental/string_view > (basic_string_view<>::operator[]): Comment _GLIBCXX_DEBUG_ASSERT, > incompatible with constexpr qualifier. > (basic_string_view<>::front()): Likewise. > (basic_string_view<>::back()): Likewise. > > * testsuite/experimental/string_view/element_access/wchar_t/2.cc: > Merge dg-options directives into one. > * testsuite/experimental/string_view/element_access/char/2.cc: > Likewise. Remove invalid experimental namespace scope on > string_view_type. > > Tested under Linux x86_64 normal, debug modes. > > Ok to commit ? Yes, but please change "introspect" in the ChangeLog to just "inspect" or "search" - thanks.
Re: Allow passing arrays in registers on AArch64
On 17/01/14 23:56, Michael Hudson-Doyle wrote: > Ian Lance Taylor writes: > >> On Fri, Jan 17, 2014 at 11:32 AM, Michael Hudson-Doyle >> wrote: >>> >>> On 18 Jan 2014 07:50, "Yufeng Zhang" wrote: Also can you please try to add some new test(s)? It may not be that straightforward to add non-C/C++ tests, but give it a try. >>> >>> Can you give some hints? Like at least where in the tree such a test would >>> go? I don't know this code at all. >> >> There is already a test in libgo, of course. >> >> I think it would be pretty hard to write a test that doesn't something >> like what libgo does. The problem is that GCC is entirely consistent >> with and without your patch. You could add a Go test that passes an >> array in gcc/testsuite/go.go-torture/execute/ easily enough, but it >> would be quite hard to add a test that doesn't pass whether or not >> your patch is applied. > > I think it would have to be a code generation test, i.e. that compiling > something like > > func second(e [2]int64) int64 { > return e[1] > } > > does not access memory or something along those lines. I'll have a look > next week. > > Cheers, > mwh > Michael, Can you have a look at how the tests in gcc.target/aarch64/aapcs64 work; it ought to be possible to write a test (though not in C) to catch this. The tests work by calling a wrapper function written in assembler -- that wrapper stores out all the registers used for parameter passing and then calls back into the test's validator with the register dump available. Code can then check that values are passed in the places expected. This gives the compiler the separation between caller and callee that's needed to test this feature. My preferred languages for these tests would be (in approximate order) c, c++, fortran, java, ada, go. That order is based on which languages are tested most by users. R.
Patch ping: [C++ PATCH] Emit array initialization from ctor as loop if possible (PR c++/59659)
On Fri, Jan 10, 2014 at 09:35:22PM +0100, Jakub Jelinek wrote: > 2014-01-10 Jakub Jelinek > > PR c++/59659 > * init.c (build_vec_init): If there are 10+ elements with the > same value in the CONSTRUCTOR, construct them using a runtime loop > rather than one by one. > > * g++.dg/opt/pr59659.C: New test. Ping. Jakub
Re: C++ PATCH to deal with trivial but non-callable [cd]tors
> 2013-10-31 Eric Botcazou > > c-family/ > * c-ada-spec.h (cpp_operation): Add IS_TRIVIAL. > (dump_ada_specs): Adjust prototype of second callback. It turns out that adjusting (constifying) the prototype of the second callback was a gratuitous change and future enhancements will run afoul of it, so I've adjusted it back with the attached patch. No functional changes. Tested on x86_64-suse-linux, applied on the mainline. 2014-01-20 Eric Botcazou c-family/ * c-ada-spec.h (dump_ada_specs): Revert prototype change. * c-ada-spec.c (dump_ads): Likewise. (cpp_check): Likewise. (dump_ada_specs): Likewise. cp/ * decl2.c (cpp_check): Revert prototype change. -- Eric BotcazouIndex: c-family/c-ada-spec.h === --- c-family/c-ada-spec.h (revision 206790) +++ c-family/c-ada-spec.h (working copy) @@ -37,6 +37,6 @@ extern location_t decl_sloc (const_tree, extern void collect_ada_nodes (tree, const char *); extern void collect_source_ref (const char *); extern void dump_ada_specs (void (*)(const char *), - int (*)(const_tree, cpp_operation)); + int (*)(tree, cpp_operation)); #endif /* ! C_ADA_SPEC_H */ Index: c-family/c-ada-spec.c === --- c-family/c-ada-spec.c (revision 206790) +++ c-family/c-ada-spec.c (working copy) @@ -58,7 +58,7 @@ static void dump_ada_nodes (pretty_print static void reset_ada_withs (void); static void dump_ada_withs (FILE *); static void dump_ads (const char *, void (*)(const char *), - int (*)(const_tree, cpp_operation)); + int (*)(tree, cpp_operation)); static char *to_ada_name (const char *, int *); static bool separate_class_package (tree); @@ -68,7 +68,7 @@ static bool separate_class_package (tree #define INDENT_INCR 3 /* Global hook used to perform C++ queries on nodes. */ -static int (*cpp_check) (const_tree, cpp_operation) = NULL; +static int (*cpp_check) (tree, cpp_operation) = NULL; /* Given a cpp MACRO, compute the max length BUFFER_LEN of the macro, as well @@ -975,7 +975,7 @@ is_tagged_type (const_tree type) sufficiently simple. */ static bool -has_nontrivial_methods (const_tree type) +has_nontrivial_methods (tree type) { tree tmp; @@ -3263,7 +3263,7 @@ print_ada_struct_decl (pretty_printer *b static void dump_ads (const char *source_file, void (*collect_all_refs)(const char *), - int (*check)(const_tree, cpp_operation)) + int (*check)(tree, cpp_operation)) { char *ads_name; char *pkg_name; @@ -3364,7 +3364,7 @@ collect_source_ref (const char *filename void dump_ada_specs (void (*collect_all_refs)(const char *), - int (*check)(const_tree, cpp_operation)) + int (*check)(tree, cpp_operation)) { int i; Index: cp/decl2.c === --- cp/decl2.c (revision 206790) +++ cp/decl2.c (working copy) @@ -3817,7 +3817,7 @@ build_java_method_aliases (struct pointe /* Return C++ property of T, based on given operation OP. */ static int -cpp_check (const_tree t, cpp_operation op) +cpp_check (tree t, cpp_operation op) { switch (op) {
[Ada] Minor code reorganization
This revamps the E_Component case of gnat_to_gnu_entity and improves comments. No functional changes, tested on x86_64-suse-linux, applied on the mainline. 2014-01-20 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Remove obsolete code for type_annotate_only mode, simplify code and slightly improve wording of comments. -- Eric BotcazouIndex: gcc-interface/decl.c === --- gcc-interface/decl.c (revision 206790) +++ gcc-interface/decl.c (working copy) @@ -491,19 +491,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entit run-time library. */ goto object; -case E_Discriminant: case E_Component: +case E_Discriminant: { /* The GNAT record where the component was defined. */ Entity_Id gnat_record = Underlying_Type (Scope (gnat_entity)); - /* If the variable is an inherited record component (in the case of - extended record types), just return the inherited entity, which - must be a FIELD_DECL. Likewise for discriminants. - For discriminants of untagged records which have explicit - stored discriminants, return the entity for the corresponding - stored discriminant. Also use Original_Record_Component - if the record has a private extension. */ + /* If the entity is an inherited component (in the case of extended + tagged record types), just return the original entity, which must + be a FIELD_DECL. Likewise for discriminants. If the entity is a + non-girder discriminant (in the case of derived untagged record + types), return the stored discriminant it renames. */ if (Present (Original_Record_Component (gnat_entity)) && Original_Record_Component (gnat_entity) != gnat_entity) { @@ -514,18 +512,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entit break; } - /* If the enclosing record has explicit stored discriminants, - then it is an untagged record. If the Corresponding_Discriminant - is not empty then this must be a renamed discriminant and its - Original_Record_Component must point to the corresponding explicit - stored discriminant (i.e. we should have taken the previous - branch). */ - else if (Present (Corresponding_Discriminant (gnat_entity)) - && Is_Tagged_Type (gnat_record)) + /* If this is a discriminant of an extended tagged type used to rename + a discriminant of the parent type, return the latter. */ + else if (Present (Corresponding_Discriminant (gnat_entity))) { - /* A tagged record has no explicit stored discriminants. */ - gcc_assert (First_Discriminant (gnat_record) - == First_Stored_Discriminant (gnat_record)); + /* If the derived type is untagged, then this is a non-girder + discriminant and its Original_Record_Component must point to + the stored discriminant it renames (i.e. we should have taken + the previous branch). */ + gcc_assert (Is_Tagged_Type (gnat_record)); + gnu_decl = gnat_to_gnu_entity (Corresponding_Discriminant (gnat_entity), gnu_expr, definition); @@ -533,26 +529,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit break; } - else if (Present (CR_Discriminant (gnat_entity)) - && type_annotate_only) - { - gnu_decl = gnat_to_gnu_entity (CR_Discriminant (gnat_entity), - gnu_expr, definition); - saved = true; - break; - } - - /* If the enclosing record has explicit stored discriminants, then - it is an untagged record. If the Corresponding_Discriminant - is not empty then this must be a renamed discriminant and its - Original_Record_Component must point to the corresponding explicit - stored discriminant (i.e. we should have taken the first - branch). */ - else if (Present (Corresponding_Discriminant (gnat_entity)) - && (First_Discriminant (gnat_record) - != First_Stored_Discriminant (gnat_record))) - gcc_unreachable (); - /* Otherwise, if we are not defining this and we have no GCC type for the containing record, make one for it. Then we should have made our own equivalent. */ @@ -586,7 +562,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit else /* Here we have no GCC type and this is a reference rather than a definition. This should never happen. Most likely the cause is - reference before declaration in the gnat tree for gnat_entity. */ + reference before declaration in the GNAT tree for gnat_entity. */ gcc_unreachable (); }
Re: [PATCH, testsuite] Fix g++.dg/debug/ra1.C
On 16/01/14 18:44, Yufeng Zhang wrote: > Hi, > > g++.dg/debug/ra1.C fails on arm-none-eabi with the following message > because enum types in arm eabi are represented by the smallest integral > type: > > warning: width of 'tree_base::code' exceeds its type [enabled by default] > > This patch updates the test by changing the width of the 'code' bitfield > from 16 to 8. > > The patch passes make check-g++ RUNTESTFLAGS="debug.exp=ra1.C" on > arm-none-eabi and x86_64. > > OK for the mainline? > > Thanks, > Yufeng > > > gcc/testsuite > > * g++.dg/debug/ra1.C (struct tree_base): Change the width of > the 'code' bitfield from 16 to 8. > OK. R.
[Ada] Fix alignment of array aggregates
This fixes a long-standing issue in the Ada compiler, whereby the alignment of aggregates whose type is an over-aligned array is lost in translation. Tested on x86_64-suse-linux, applied on the mainline. 2014-01-20 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Tidy up. For a subtype with discriminants and variant part, if a variant is statically selected and the fields all have a constant position, put them in order of increasing position. Likewise if no variant part but representation clause is present. * gcc-interface/utils.c (make_packable_type): Robustify. (maybe_pad_type): Use local variable and tidy up condition. If no alignment is specified, use the original one. (create_type_stub_decl): Minor tweak. (convert) : Fix typo. : Deal with padding types around the same type. Do not punt on missing fields. (unchecked_convert): Call finish_record_type to lay out the special record types made for conversions from/to problematic integer types. Bump the alignment of CONSTRUCTORs before converting them to a more aligned type. -- Eric BotcazouIndex: gcc-interface/utils.c === --- gcc-interface/utils.c (revision 206790) +++ gcc-interface/utils.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2013, Free Software Foundation, Inc. * + * Copyright (C) 1992-2014, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -869,8 +869,9 @@ make_packable_type (tree type, bool in_r finish_record_type (new_type, nreverse (field_list), 2, false); relate_alias_sets (new_type, type, ALIAS_SET_COPY); - SET_DECL_PARALLEL_TYPE (TYPE_STUB_DECL (new_type), - DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type))); + if (TYPE_STUB_DECL (type)) +SET_DECL_PARALLEL_TYPE (TYPE_STUB_DECL (new_type), + DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type))); /* If this is a padding record, we never want to make the size smaller than what was specified. For QUAL_UNION_TYPE, also copy the size. */ @@ -1049,6 +1050,7 @@ maybe_pad_type (tree type, tree size, un bool is_user_type, bool definition, bool set_rm_size) { tree orig_size = TYPE_SIZE (type); + unsigned int orig_align = TYPE_ALIGN (type); tree record, field; /* If TYPE is a padded type, see if it agrees with any size and alignment @@ -1059,21 +1061,18 @@ maybe_pad_type (tree type, tree size, un if (TYPE_IS_PADDING_P (type)) { if ((!size - || operand_equal_p (round_up (size, - MAX (align, TYPE_ALIGN (type))), - round_up (TYPE_SIZE (type), - MAX (align, TYPE_ALIGN (type))), - 0)) - && (align == 0 || align == TYPE_ALIGN (type))) + || operand_equal_p (round_up (size, orig_align), orig_size, 0)) + && (align == 0 || align == orig_align)) return type; if (!size) - size = TYPE_SIZE (type); + size = orig_size; if (align == 0) - align = TYPE_ALIGN (type); + align = orig_align; type = TREE_TYPE (TYPE_FIELDS (type)); orig_size = TYPE_SIZE (type); + orig_align = TYPE_ALIGN (type); } /* If the size is either not being changed or is being made smaller (which @@ -1086,7 +1085,7 @@ maybe_pad_type (tree type, tree size, un && tree_int_cst_lt (size, orig_size size = NULL_TREE; - if (align == TYPE_ALIGN (type)) + if (align == orig_align) align = 0; if (align == 0 && !size) @@ -1110,7 +1109,7 @@ maybe_pad_type (tree type, tree size, un if (Present (gnat_entity)) TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD"); - TYPE_ALIGN (record) = align; + TYPE_ALIGN (record) = align ? align : orig_align; TYPE_SIZE (record) = size ? size : orig_size; TYPE_SIZE_UNIT (record) = convert (sizetype, @@ -2063,8 +2062,7 @@ create_type_stub_decl (tree type_name, t /* Using a named TYPE_DECL ensures that a type name marker is emitted in STABS while setting DECL_ARTIFICIAL ensures that no DW_TAG_typedef is emitted in DWARF. */ - tree type_decl = build_decl (input_location, - TYPE_DECL, type_name, type); + tree type_decl = build_decl (input_location, TYPE_DECL, type_name, type); DECL_ARTIFICIAL (type_decl) = 1; TYPE_ARTIFICIAL (type) = 1; return type_decl; @@ -4626,7 +4624,7 @@ convert (tree type, tree expr) break; case VECTOR_CST: - /* If we are converting a VECTOR_CST to a mere var
Re: [PATCH][RFC] Fix PR59860
On Sun, 19 Jan 2014, Jakub Jelinek wrote: > On Sun, Jan 19, 2014 at 07:05:12PM +0100, Richard Biener wrote: > > The following patch fixes PR59860 by removing the only folding > > builtins.c does that can end up recursing to GIMPLE call stmt > > folding. It does that via strcat -> strlen + strcpy folding > > and then folding the strlen gimple stmt via gimplify which > > then can use the SSA web to fold that to a constant and then > > the strcpy call to memcpy. This confuses the virtual operand > > updating code - not that it ends up creating wrong virtual SSA > > form but by bogously marking virtual operands for renaming > > through the operand scanner as the folding on the just gimplified > > sequence doesn't see any VOPs yet. > > > > Bootstrapped on x86_64-unknown-linux-gnu, testing reveals that I > > have to adjust gcc.c-torture/execute/builtins/strcat.c expectations > > and gcc.dg/strlenopt-* likely because of different input. > > > > I still think this patch is better than the second option, avoiding > > to call fold_stmt from the gimplifier in this case (either by > > a new ctx flag or looking at ctx->into_ssa). I also think that > > "fixing" this by scheduling update-ssa after objsz is wrong. > > > > Any opinions? Maybe any different preferences for branch / trunk? > > If you verify that strlen pass does the right thing here (I hope it does, > but haven't verified), then I think this is the way for the trunk, not > sure about the branch, I'd prefer there something less intrusive at this > point, even if it is say just through setting some global flag that will > disable the strcat folding at the problematic spot, or folds it on the tree > before gimplification, or gimplifies operands and builds the call in gimple > by hand for the strcat case. > > > 2014-01-17 Richard Biener > > > > PR middle-end/59860 > > * builtins.c (fold_builtin_strcat): Remove case better handled > > by tree-ssa-strlen.c > > Missing dot at the end ;) > > > > * gcc.dg/pr59860.c: New testcase. > > Ok, the following simpler patch also fixes the issue and causes no testsuite fallout - we restrict the folding in builtins.c to the case with known src strlen. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk and branch. Richard. 2014-01-17 Richard Biener PR middle-end/59860 * builtins.c (fold_builtin_strcat): Remove case better handled by tree-ssa-strlen.c. * gcc.dg/pr59860.c: New testcase. Index: gcc/testsuite/gcc.dg/pr59860.c === *** gcc/testsuite/gcc.dg/pr59860.c (revision 0) --- gcc/testsuite/gcc.dg/pr59860.c (working copy) *** *** 0 --- 1,15 + /* { dg-do compile } */ + /* { dg-options "-O" } */ + + extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * __attribute__ ((__nothrow__ , __leaf__)) + strcat (char *__restrict __dest, const char *__restrict __src) + { + return __builtin___strcat_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); + } + static char raw_decode; + void foo (char **argv, char *outfilename) + { + if (**argv == 'r') + raw_decode = 1; + strcat (outfilename, raw_decode ? ".raw" : ".wav"); + } Index: gcc/builtins.c === *** gcc/builtins.c (revision 206772) --- gcc/builtins.c (working copy) *** fold_builtin_strcat (location_t loc ATTR *** 11759,11775 if (!strlen_fn || !strcpy_fn) return NULL_TREE; ! /* If we don't have a movstr we don't want to emit an strcpy !call. We have to do that if the length of the source string !isn't computable (in that case we can use memcpy probably !later expanding to a sequence of mov instructions). If we !have movstr instructions we can emit strcpy calls. */ ! if (!HAVE_movstr) ! { ! tree len = c_strlen (src, 1); ! if (! len || TREE_SIDE_EFFECTS (len)) ! return NULL_TREE; ! } /* Stabilize the argument list. */ dst = builtin_save_expr (dst); --- 11759,11769 if (!strlen_fn || !strcpy_fn) return NULL_TREE; ! /* If the length of the source string isn't computable don't !split strcat into strlen and strcpy. */ ! tree len = c_strlen (src, 1); ! if (! len || TREE_SIDE_EFFECTS (len)) ! return NULL_TREE; /* Stabilize the argument list. */ dst = builtin_save_expr (dst);
[Ada] Fix latent issues with thin pointers
This fixes latent issues with thin pointers, which get exposed with -gnatd6. Tested on x86_64-suse-linux, applied on the mainline. 2014-01-20 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Robustify tests for aliased objects with an unconstrained nominal subtype. * gcc-interface/trans.c (Call_to_gnu): Likewise. (gnat_to_gnu) : Robustify test for private type. : Remove useless code. (Exception_Handler_to_gnu_zcx): Minor tweaks. -- Eric BotcazouIndex: gcc-interface/decl.c === --- gcc-interface/decl.c (revision 206796) +++ gcc-interface/decl.c (working copy) @@ -771,8 +771,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit || (TYPE_SIZE (gnu_type) && integer_zerop (TYPE_SIZE (gnu_type)) && !TREE_OVERFLOW (TYPE_SIZE (gnu_type - && (!Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity)) - || !Is_Array_Type (Etype (gnat_entity))) + && !Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity)) && No (Renamed_Object (gnat_entity)) && No (Address_Clause (gnat_entity))) gnu_size = bitsize_unit_node; @@ -864,7 +863,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit /* If this is an aliased object with an unconstrained nominal subtype, make a type that includes the template. */ if (Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity)) - && Is_Array_Type (Etype (gnat_entity)) + && (Is_Array_Type (Etype (gnat_entity)) + || (Is_Private_Type (Etype (gnat_entity)) + && Is_Array_Type (Full_View (Etype (gnat_entity) && !type_annotate_only) { tree gnu_array @@ -1390,7 +1391,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit Note that we have to do that this late because of the couple of allocation adjustments that might be made just above. */ if (Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity)) - && Is_Array_Type (Etype (gnat_entity)) + && (Is_Array_Type (Etype (gnat_entity)) + || (Is_Private_Type (Etype (gnat_entity)) + && Is_Array_Type (Full_View (Etype (gnat_entity) && !type_annotate_only) { tree gnu_array @@ -4788,10 +4791,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit from the full view. But always get the type from the full view for define on use types, since otherwise we won't see them! */ else if (!definition - || (Is_Itype (full_view) - && No (Freeze_Node (gnat_entity))) - || (Is_Itype (gnat_entity) - && No (Freeze_Node (full_view + || (Is_Itype (full_view) && No (Freeze_Node (gnat_entity))) + || (Is_Itype (gnat_entity) && No (Freeze_Node (full_view { gnu_decl = gnat_to_gnu_entity (full_view, NULL_TREE, 0); maybe_present = true; Index: gcc-interface/trans.c === --- gcc-interface/trans.c (revision 206790) +++ gcc-interface/trans.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2013, Free Software Foundation, Inc. * + * Copyright (C) 1992-2014, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -4156,7 +4156,9 @@ Call_to_gnu (Node_Id gnat_node, tree *gn if (TREE_CODE (TREE_TYPE (gnu_actual)) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (gnu_actual)) && Is_Constr_Subt_For_UN_Aliased (Etype (gnat_actual)) - && Is_Array_Type (Etype (gnat_actual))) + && (Is_Array_Type (Etype (gnat_actual)) + || (Is_Private_Type (Etype (gnat_actual)) + && Is_Array_Type (Full_View (Etype (gnat_actual)) gnu_actual = convert (gnat_to_gnu_type (Etype (gnat_actual)), gnu_actual); } @@ -4826,10 +4828,7 @@ static tree Exception_Handler_to_gnu_zcx (Node_Id gnat_node) { tree gnu_etypes_list = NULL_TREE; - tree gnu_expr; - tree gnu_etype; - tree gnu_current_exc_ptr; - tree prev_gnu_incoming_exc_ptr; + tree gnu_current_exc_ptr, prev_gnu_incoming_exc_ptr; Node_Id gnat_temp; /* We build a TREE_LIST of nodes representing what exception types this @@ -4840,20 +4839,19 @@ Exception_Handler_to_gnu_zcx (Node_Id gn for (gnat_temp = First (Exception_Choices (gnat_node)); gnat_temp; gnat_temp = Next (gnat_temp)) { + tree gnu_expr, gnu_etype; + if (Nkind (gnat_temp) == N_Others_Choice) { - tree gnu_expr - = All_Others (gnat_temp) ? all_others_decl : others_decl; - - gnu_etype - = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr); + gnu_expr = All_Others (gnat_temp) ? all_others_decl : oth
Re: [AArch64] Make -mcpu, -march and -mtune case-insensitive.
On Fri, Jan 17, 2014 at 12:00:19PM +, Richard Earnshaw wrote: > On 17/01/14 11:12, Alan Lawrence wrote: > > Small patch to make the -mcpu, -march and -mtune command-line options > > case-insensitive, allowing e.g. -mcpu=CortexA57 -march=ARMv8-A. > > > > Tested on aarch64-none-elf with no regressions; options passed onto e.g. > > ld are always lowercase (as before). > > > > OK for trunk? > > > > --Alan > > > > ChangeLog: > > 2014-01-17 Alan Lawrence > > * config/aarch64/aarch64.opt (mcpu, march, mtune): Make > > case-insensitive. > > > > OK. > > R. I've committed this on Alan's behalf as revision 206797. Thanks, James
Re: [AArch64] Fix behaviour of -mcpu option to match ARM.
On 16/01/14 17:32, James Greenhalgh wrote: > > Hi, > > While clarifying the documentation of the -mcpu, -march and -mtune > options for AArch64 and ARM I spotted that their behaviour is not > consistent. > > This patch fixes that in the AArch64 port. > > Now, -mcpu=$CPU is treated as a shorthand for -march=arch_of_$CPU and > -mtune=$CPU. -march and -mtune therefore override only their respective > components of -mcpu. If the architecture picked by -march does not match > that given by -mcpu, a warning is given. > > Regression tested on aarch64-none-elf and checked manually to > ensure things are working as expected. > > OK? > > Thanks, > James > > --- > gcc/ > > 2014-01-16 James Greenhalgh > > * common/config/aarch64/aarch64-common.c > (aarch64_handle_option): Don't handle any option order logic here. > * config/aarch64/aarch64.c (aarch64_parse_arch): Do not override > selected_cpu, warn on architecture version mismatch. > (aarch64_override_options): Fix parsing order for option strings. > > OK. R.
Re: [Patch AArch64] Implement Vector Permute Support
On 17/01/14 15:55, Richard Earnshaw wrote: On 16/01/14 14:43, Alex Velenko wrote: On 14/01/14 15:51, pins...@gmail.com wrote: On Jan 14, 2014, at 7:19 AM, Alex Velenko wrote: Hi, This patch turns off the vec_perm patterns for aarch64_be, this should resolve the issue highlighted here http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00321.html With this patch applied, the test case provided in that link compiles without an ICE. However, the Big-Endian port is still in development. This patch exposes another known but unrelated issue with Big-Endian Large-Int modes. The patch has been tested on aarch64-none-elf and aarch64_be-none-elf resulting in five further regression due to the broken implementation of Big-Endian Large-Int modes. Kind regards, Alex Velenko gcc/ 2014-01-14 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. gcc/testsuite/ 2014-01-14 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise. I think you want to use a function to check if the target is effectively big-endian instead. Internally at Cavium, our elf compiler has big-endian multi-lib. Thanks, Andrew Hi, Here is a vec-perm patch with changes proposed previously. Little and Big-Endian tested with no additional issues appearing. Kind regards, Alex gcc/ 2014-01-16 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. gcc/testsuite/ 2014-01-16 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise. The patch is missing the hunk for aarch64.c. Hi, It is a faulty changelog entry, not patch. Should be: gcc/ 2014-01-16 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. gcc/testsuite/ 2014-01-16 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise.
Re: [Patch AArch64] Implement Vector Permute Support
On 20/01/14 11:15, Alex Velenko wrote: > On 17/01/14 15:55, Richard Earnshaw wrote: >> On 16/01/14 14:43, Alex Velenko wrote: >>> On 14/01/14 15:51, pins...@gmail.com wrote: > On Jan 14, 2014, at 7:19 AM, Alex Velenko wrote: > > Hi, > > This patch turns off the vec_perm patterns for aarch64_be, this should > resolve > the issue highlighted here > http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00321.html > With this patch applied, the test case provided in that link compiles > without an ICE. > > However, the Big-Endian port is still in development. This patch exposes > another known but unrelated issue with Big-Endian Large-Int modes. > > The patch has been tested on aarch64-none-elf and aarch64_be-none-elf > resulting in five > further regression due to the broken implementation of Big-Endian > Large-Int modes. > > Kind regards, > Alex Velenko > > gcc/ > > 2014-01-14 Alex Velenko > > * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. > * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. > > gcc/testsuite/ > > 2014-01-14 Alex Velenko > > * lib/target-supports.exp > (check_effective_target_vect_perm): Exclude aarch64_be. > (check_effective_target_vect_perm_byte): Likewise. > (check_effective_target_vect_perm_short): Likewise. I think you want to use a function to check if the target is effectively big-endian instead. Internally at Cavium, our elf compiler has big-endian multi-lib. Thanks, Andrew > > >>> >>> Hi, >>> Here is a vec-perm patch with changes proposed previously. >>> Little and Big-Endian tested with no additional issues appearing. >>> >>> Kind regards, >>> Alex >>> >>> gcc/ >>> >>> 2014-01-16 Alex Velenko >>> >>> * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. >>> * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. >>> >>> gcc/testsuite/ >>> >>> 2014-01-16 Alex Velenko >>> >>> * lib/target-supports.exp >>> (check_effective_target_vect_perm): Exclude aarch64_be. >>> (check_effective_target_vect_perm_byte): Likewise. >>> (check_effective_target_vect_perm_short): Likewise. >>> >> >> The patch is missing the hunk for aarch64.c. >> >> > > Hi, > It is a faulty changelog entry, not patch. > Should be: > > gcc/ > > 2014-01-16 Alex Velenko > > * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. > > gcc/testsuite/ > > 2014-01-16 Alex Velenko > > * lib/target-supports.exp > (check_effective_target_vect_perm): Exclude aarch64_be. > (check_effective_target_vect_perm_byte): Likewise. > (check_effective_target_vect_perm_short): Likewise. > On that basis, OK. R.
Re: [PATCH][buildrobot] PR59496: Fix unused variable warning
On 20 Jan 2014, at 08:45, Jakub Jelinek wrote: > On Tue, Jan 14, 2014 at 05:59:11PM +0100, Jan-Benedict Glaw wrote: >> 2014-01-14 Jan-Benedict Glaw >> >> PR bootstrap/59496 >> * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Fix unused variable >> warning. > > Ok, thanks. As discussed on irc, I have applied a slightly modified version (differs in whitespace and amends the comment to explain the dummy use of FIELD). Iain r206802: Index: gcc/ChangeLog === --- gcc/ChangeLog (revision 206801) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,10 @@ +2014-01-20 Jan-Benedict Glaw + Iain Sandoe + + PR bootstrap/59496 + * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Fix unused variable + warning. Amend comment to reflect current functionality. + 2014-01-20 Richard Biener PR middle-end/59860 Index: gcc/config/rs6000/darwin.h === --- gcc/config/rs6000/darwin.h (revision 206801) +++ gcc/config/rs6000/darwin.h (working copy) @@ -321,16 +321,19 @@ ? GENERAL_REGS \ : (CLASS)) -/* Compute field alignment. This is similar to the version of the - macro in the Apple version of GCC, except that version supports - 'mac68k' alignment, and that version uses the computed alignment - always for the first field of a structure. The first-field - behavior is dealt with by - darwin_rs6000_special_round_type_align. */ -#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)\ - (TARGET_ALIGN_NATURAL ? (COMPUTED) \ - : (COMPUTED) == 128 ? 128 \ - : MIN ((COMPUTED), 32)) +/* Compute field alignment. + This implements the 'power' alignment rule by pegging the alignment of + items (beyond the first aggregate field) to 32 bits. The pegging is + suppressed for vector and long double items (both 128 in size). + There is a dummy use of the FIELD argument to avoid an unused variable + warning (see PR59496). */ +#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)\ + ((void) (FIELD), \ +(TARGET_ALIGN_NATURAL \ + ? (COMPUTED) \ + : (COMPUTED) == 128 \ + ? 128 \ + : MIN ((COMPUTED), 32))) /* Darwin increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */
[AArch64 Documentation] Clarify meaning of -mcpu, -mtune, -march
Hi, These three options can be a pain to remember how they interact with one another, this patch clarifies the situation giving explicit documentation as to the expected behaviour where they are combined. OK? Thanks, James --- gcc/ 2014-01-20 James Greenhalgh * doc/invoke.texi (-march): Clarify documentation for AArch64. (-mtune): Likewise. (-mcpu): Likewise. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9e16b3b..00bcfa6 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11379,46 +11379,55 @@ of TLS variables. Specify the name of the target architecture, optionally suffixed by one or more feature modifiers. This option has the form @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where the -only value for @var{arch} is @samp{armv8-a}. The possible values for -@var{feature} are documented in the sub-section below. +only permissible value for @var{arch} is @samp{armv8-a}. The permissible +values for @var{feature} are documented in the sub-section below. Where conflicting feature modifiers are specified, the right-most feature is used. GCC uses this name to determine what kind of instructions it can emit when -generating assembly code. This option can be used in conjunction with or -instead of the @option{-mcpu=} option. +generating assembly code. + +Where @option{-march} is specified without either of @option{-mtune} +or @option{-mcpu} also being specified, the code will be tuned to perform +well across a range of target processors implementing the target +architecture. + +@item -mtune=@var{name} +@opindex mtune +Specify the name of the target processor for which GCC should tune the +performance of the code. Permissible values for this option are: +@samp{generic}, @samp{cortex-a53}, @samp{cortex-a57}. + +Additionally, this option can specify that GCC should tune the performance +of the code for a big.LITTLE system. The only permissible value is +@samp{cortex-a57.cortex-a53}. + +Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} +are specified, the code will be tuned to perform well across a range +of target processors. + +This option cannot be suffixed by feature modifiers. @item -mcpu=@var{name} @opindex mcpu Specify the name of the target processor, optionally suffixed by one or more feature modifiers. This option has the form @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where the -possible values for @var{cpu} are @samp{generic}, @samp{cortex-a53}, -@samp{cortex-a57}. The possible values for @var{feature} are documented -in the sub-section below. +permissible values for @var{cpu} are the same as those available for +@option{-mtune}. -Additionally, this option can specify that the target is a big.LITTLE system. -The only possible value is @samp{cortex-a57.cortex-a53}. +The permissible values for @var{feature} are documented in the sub-section below. Where conflicting feature modifiers are specified, the right-most feature is used. GCC uses this name to determine what kind of instructions it can emit when -generating assembly code. - -@item -mtune=@var{name} -@opindex mtune -Specify the name of the processor to tune the performance for. The code will -be tuned as if the target processor were of the type specified in this option, -but still using instructions compatible with the target processor specified -by a @option{-mcpu=} option. Where no @option{-mtune=} option is -specified, the code will be tuned to perform well on the target processor -given by @option{-mcpu=} or @option{-march=}. Where none of -@option{-mtune=}, @option{-mcpu=} or @option{-march=} are specified, -the code will be tuned to perform well across a range of target -processors. This option cannot be suffixed by feature modifiers. - +generating assembly code (as if by @option{-march}) and to determine +the target processor for which to tune for performance (as if +by @option{-mtune}). Where this option is used in conjunction +with @option{-march} or @option{-mtune}, those options override this +option. @end table @subsubsection @option{-march} and @option{-mcpu} feature modifiers
Re: Commit: MSP430: Add -mcpu= option
Hi Gerald, Mind adding an entry to the release notes? Happy to help if you have any questions. Is the following acceptable ? I even remembered to run it through the validator... Cheers Nick Index: htdocs/gcc-4.9/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v retrieving revision 1.52 diff -u -3 -p -r1.52 changes.html --- htdocs/gcc-4.9/changes.html 13 Jan 2014 17:34:43 - 1.52 +++ htdocs/gcc-4.9/changes.html 20 Jan 2014 11:48:24 - @@ -425,6 +425,16 @@ auto incr = [](auto x) { return x++; }; is now available through the -march=bdver4 and -mtune=bdver4 options. +MSP430 + +A new command line option -mcpu= has been added to the MSP430 backend. +This option is used to specify the ISA to be used. Accepted values are +msp430 (the default), msp430x and msp430xv2. The ISA is no longer deduced +from the -mmcu= option as there are far too many different MCU names. The +-mmcu= option is still supported, and this is still used to select linker +scripts and generate a C preprocessor symbol that will be recognised by the +msp430.h header file. + NDS32 A new nds32 port supports the 32-bit architecture from Andes
Re: [PATCH][RFC] Fix PR59860
On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > Ok, the following simpler patch also fixes the issue and causes > no testsuite fallout - we restrict the folding in builtins.c to > the case with known src strlen. But then we simply never optimize this anymore. Or regress when you e.g. in your testcase replace __builtin___strcat_chk with __builtin_strcat and remove last argument (while if there is no inline, it is still optimized). tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, known second strlen or movstr pattern, will only transform that if the length of the resulting string is needed afterwards), and isn't run for -Os or -O1 anyway. For other builtins, this case is usually handled in gimple-fold.c (gimple_fold_builtin), but BUILT_IN_STRCAT isn't handled there. So perhaps it should and add one argument to fold_builtin_strcat if we know the length, but don't know where the argument points to. And/or handle src being SSA_NAME with GIMPLE_PHI def stmt, by calling c_strlen on each of the phi arguments individually (i.e. handle it similarly to the COND_EXPR case) and verifying it is the same. But I guess if we optimize it again, your testcase would crash again, right? > 2014-01-17 Richard Biener > > PR middle-end/59860 > * builtins.c (fold_builtin_strcat): Remove case better handled > by tree-ssa-strlen.c. > > * gcc.dg/pr59860.c: New testcase. > > Index: gcc/testsuite/gcc.dg/pr59860.c > === > *** gcc/testsuite/gcc.dg/pr59860.c(revision 0) > --- gcc/testsuite/gcc.dg/pr59860.c(working copy) > *** > *** 0 > --- 1,15 > + /* { dg-do compile } */ > + /* { dg-options "-O" } */ > + > + extern __inline __attribute__ ((__always_inline__)) __attribute__ > ((__gnu_inline__)) __attribute__ ((__artificial__)) char * __attribute__ > ((__nothrow__ , __leaf__)) > + strcat (char *__restrict __dest, const char *__restrict __src) > + { > + return __builtin___strcat_chk (__dest, __src, __builtin_object_size > (__dest, 2 > 1)); > + } > + static char raw_decode; > + void foo (char **argv, char *outfilename) > + { > + if (**argv == 'r') > + raw_decode = 1; > + strcat (outfilename, raw_decode ? ".raw" : ".wav"); > + } > Index: gcc/builtins.c > === > *** gcc/builtins.c(revision 206772) > --- gcc/builtins.c(working copy) > *** fold_builtin_strcat (location_t loc ATTR > *** 11759,11775 > if (!strlen_fn || !strcpy_fn) > return NULL_TREE; > > ! /* If we don't have a movstr we don't want to emit an strcpy > ! call. We have to do that if the length of the source string > ! isn't computable (in that case we can use memcpy probably > ! later expanding to a sequence of mov instructions). If we > ! have movstr instructions we can emit strcpy calls. */ > ! if (!HAVE_movstr) > ! { > ! tree len = c_strlen (src, 1); > ! if (! len || TREE_SIDE_EFFECTS (len)) > ! return NULL_TREE; > ! } > > /* Stabilize the argument list. */ > dst = builtin_save_expr (dst); > --- 11759,11769 > if (!strlen_fn || !strcpy_fn) > return NULL_TREE; > > ! /* If the length of the source string isn't computable don't > ! split strcat into strlen and strcpy. */ > ! tree len = c_strlen (src, 1); > ! if (! len || TREE_SIDE_EFFECTS (len)) > ! return NULL_TREE; > > /* Stabilize the argument list. */ > dst = builtin_save_expr (dst); Jakub
Re: [PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)
On Mon, Jan 20, 2014 at 10:11 AM, Uros Bizjak wrote: >> As mentioned in the PR or even in the comment below, ix86_decompose_address >> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even >> when the operands aren't of a lea insn, but normal or zero extending mov. >> >> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for >> trunk? >> >> 2014-01-20 Jakub Jelinek >> >> PR target/59880 >> * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false >> if operands[1] is a REG or ZERO_EXTEND of a REG. >> >> * gcc.target/i386/pr59880.c: New test. > This is OK for mainline, I will take care for a backport (together > with 59379) to other release branches. There are some additional zero-extension insns (SUBREG and AND, all conveniently detected in SImode_address_operand predicate) that should be considered here. I am testing following patch: Index: config/i386/i386.c === --- config/i386/i386.c (revision 206792) +++ config/i386/i386.c (working copy) @@ -18160,13 +18160,12 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) return false; /* The "at least two components" test below might not catch simple - *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is - non-NULL and parts.disp is const0_rtx as the only components in - the address, e.g. if the register is %rbp or %r13. As this - test is much cheaper and moves or zero extensions are the common - case, do this check first. */ + move or zero extension insns if parts.base is non-NULL and parts.disp + is const0_rtx as the only components in the address, e.g. if the + register is %rbp or %r13. As this test is much cheaper and moves or + zero extensions are the common case, do this check first. */ if (REG_P (operands[1]) - || (GET_CODE (operands[1]) == ZERO_EXTEND + || (SImode_address_operand (operands[1], VOIDmode) && REG_P (XEXP (operands[1], 0 return false; Uros.
Re: reload autoinc fix
On 01/16/2014 09:53 PM, Jeff Law wrote: I happened to be going through the list of regressions and came across this again. I went ahead and installed the patch on the trunk and closed the BZ. Thanks. I was travelling and decided not to install any patches before or during that. Bernd
Re: [build, libgcc] Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR target/59788)
Rainer Orth writes: > Unfortunately, the patch needs a change to the bundled ltmain.sh: by > default, libtool `optimizes' -lgcc_s -lc -lgcc_s into -lc -lgcc_s. > Combined with direct binding, this lead to exactly the failure the patch > intends to avoid. The libtool bug has already been reported and a patch > proposed: > > http://lists.gnu.org/archive/html/libtool-patches/2014-01/msg5.html The patch has been accepted upstream now. > I don't need approval for the Solaris specific parts, but another pair > of eyes would certainly be helpful. Given that there were no other comments, I'd like to install the patch now. Ian, could you please install the ltmain.sh patch in libgo/config, or should I do so myself? Thanks. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [build, libgcc] Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR target/59788)
Il 17/01/2014 15:21, Rainer Orth ha scritto: > As described in the PR, the 64-bit Solaris 10+/x86 libc contains an > implementation of those _Unwind_* functions required by the AMD64 ABI, > i.e. those contained in libgcc_s.so.1 at version GCC_3.0. > > If by some circumstance (use of -Bdirect, -z lazyload, maybe others) > libc.so.1 happens to be searched by ld.so.1 before libgcc_s.so.1 and > some library (e.g. libstdc++.so.6) uses functions both from GCC_3.0 > (then resolved from libc.so.1) and others (resolved from libgcc_s.so.1), > crashes result due to mixing those different implementations with > different internal data structures. > > To avoid this, I suggest linking libgcc_s.so.1 with a mapfile that > enforces direct binding to the libgcc_s.so.1 implementation to avoid > that mixture. > > The following patch does just that. Initially, I tried to only use the > mapfile when -lgcc_s is used, but libtool often links shared objects > with -shared -nostdlib, adding -lgcc_s -lc -lgcc_s itself (for whatever > reason it deems appropriate to second-guess the compiler driver here). > Therefore I'm keying the mapfile use off -shared resp. -shared-libgcc > instead. > > Unfortunately, the patch needs a change to the bundled ltmain.sh: by > default, libtool `optimizes' -lgcc_s -lc -lgcc_s into -lc -lgcc_s. > Combined with direct binding, this lead to exactly the failure the patch > intends to avoid. The libtool bug has already been reported and a patch > proposed: > > http://lists.gnu.org/archive/html/libtool-patches/2014-01/msg5.html > > The patch has been tested on i386-pc-solaris2.{9,10,11} and > sparc-sun-solaris2.{9,10,11} with Sun as/ld and on i386-pc-solaris2.10 > with Sun as/GNU ld. > > I don't need approval for the Solaris specific parts, but another pair > of eyes would certainly be helpful. > > One potential issue would be a version of gcc containing the patch used > with a libtool without the change. The last libtool release was almost > two years ago, so this is quite a likely condition. Fortunately, > problems would only ensure if some 64-bit Solaris/x86 program/library > uses the gcc extensions to the AMD64 unwinder. According to a code > search, uses of those functions are very rare outside of gcc, and the > problem can be worked around by invoking libtool with > --preserve-dup-deps, so I consider this risk acceptable. > > Rainer > > > 2014-01-14 Rainer Orth > > gcc: > PR target/59788 > * config/sol2.h (LINK_LIBGCC_MAPFILE_SPEC): Define. > (LINK_SPEC): Use it for -shared, -shared-libgcc. > > libgcc: > PR target/59788 > * config/t-slibgcc-sld (libgcc-unwind.map): New target. > (install-libgcc-unwind-map-forbuild): New target. > (all): Depend on install-libgcc-unwind-map-forbuild. > (install-libgcc-unwind-map): New target. > (install): Depend on install-libgcc-unwind-map. > > gcc/testsuite: > PR target/59788 > * g++.dg/eh/unwind-direct.C: New test. > > libgo: > PR target/59788 > * config/ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on > *solaris2*. > > toplevel: > PR target/59788 > * ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on > *solaris2*. > > > > Thanks for getting the patch upstream! Paolo
Re: [PATCH][RFC] Fix PR59860
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > > Ok, the following simpler patch also fixes the issue and causes > > no testsuite fallout - we restrict the folding in builtins.c to > > the case with known src strlen. > > But then we simply never optimize this anymore. > Or regress when you e.g. in your testcase replace > __builtin___strcat_chk with __builtin_strcat and remove last argument > (while if there is no inline, it is still optimized). > > tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, > known second strlen or movstr pattern, will only transform that if the > length of the resulting string is needed afterwards), and isn't run > for -Os or -O1 anyway. Well, I'm not sure under which circumstances this should be an unconditional win anyway (I expect the strcat library fn to be optimized well enough, and only if you can avoid the strlen on the dest in the end it will be profitable) > For other builtins, this case is usually handled in gimple-fold.c > (gimple_fold_builtin), but BUILT_IN_STRCAT isn't handled there. > So perhaps it should and add one argument to fold_builtin_strcat > if we know the length, but don't know where the argument points to. > > And/or handle src being SSA_NAME with GIMPLE_PHI def stmt, by > calling c_strlen on each of the phi arguments individually (i.e. handle > it similarly to the COND_EXPR case) and verifying it is the same. > > But I guess if we optimize it again, your testcase would crash again, right? Right. We can apply the optimization at RTL expansion time though, or handle the folding completely in gimple-fold with not needing to dispatch to the gimplifier. Richard. > > 2014-01-17 Richard Biener > > > > PR middle-end/59860 > > * builtins.c (fold_builtin_strcat): Remove case better handled > > by tree-ssa-strlen.c. > > > > * gcc.dg/pr59860.c: New testcase. > > > > Index: gcc/testsuite/gcc.dg/pr59860.c > > === > > *** gcc/testsuite/gcc.dg/pr59860.c (revision 0) > > --- gcc/testsuite/gcc.dg/pr59860.c (working copy) > > *** > > *** 0 > > --- 1,15 > > + /* { dg-do compile } */ > > + /* { dg-options "-O" } */ > > + > > + extern __inline __attribute__ ((__always_inline__)) __attribute__ > > ((__gnu_inline__)) __attribute__ ((__artificial__)) char * __attribute__ > > ((__nothrow__ , __leaf__)) > > + strcat (char *__restrict __dest, const char *__restrict __src) > > + { > > + return __builtin___strcat_chk (__dest, __src, __builtin_object_size > > (__dest, 2 > 1)); > > + } > > + static char raw_decode; > > + void foo (char **argv, char *outfilename) > > + { > > + if (**argv == 'r') > > + raw_decode = 1; > > + strcat (outfilename, raw_decode ? ".raw" : ".wav"); > > + } > > Index: gcc/builtins.c > > === > > *** gcc/builtins.c (revision 206772) > > --- gcc/builtins.c (working copy) > > *** fold_builtin_strcat (location_t loc ATTR > > *** 11759,11775 > > if (!strlen_fn || !strcpy_fn) > > return NULL_TREE; > > > > ! /* If we don't have a movstr we don't want to emit an strcpy > > !call. We have to do that if the length of the source string > > !isn't computable (in that case we can use memcpy probably > > !later expanding to a sequence of mov instructions). If we > > !have movstr instructions we can emit strcpy calls. */ > > ! if (!HAVE_movstr) > > ! { > > ! tree len = c_strlen (src, 1); > > ! if (! len || TREE_SIDE_EFFECTS (len)) > > ! return NULL_TREE; > > ! } > > > > /* Stabilize the argument list. */ > > dst = builtin_save_expr (dst); > > --- 11759,11769 > > if (!strlen_fn || !strcpy_fn) > > return NULL_TREE; > > > > ! /* If the length of the source string isn't computable don't > > !split strcat into strlen and strcpy. */ > > ! tree len = c_strlen (src, 1); > > ! if (! len || TREE_SIDE_EFFECTS (len)) > > ! return NULL_TREE; > > > > /* Stabilize the argument list. */ > > dst = builtin_save_expr (dst); > > Jakub > > -- Richard Biener SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer
Re: [PATCH][RFC] Fix PR59860
On Mon, Jan 20, 2014 at 01:35:05PM +0100, Richard Biener wrote: > > tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, > > known second strlen or movstr pattern, will only transform that if the > > length of the resulting string is needed afterwards), and isn't run > > for -Os or -O1 anyway. > > Well, I'm not sure under which circumstances this should be an > unconditional win anyway (I expect the strcat library fn to be > optimized well enough, and only if you can avoid the strlen on the > dest in the end it will be profitable) No, while the strcat library fn can be very optimized, it still has no info about how long the second parameter is. strcat is implementation is typically an optimized strchr (dst, 0) followed by an optimized strcpy, where the two can perhaps avoid some alignment adjustments or something. But the strcpy still has to for each word or whatever chunk it reads test for terminating zeros, while if you do an (optimized) strlen followed by memcpy where you already know the length, that is a win. > > But I guess if we optimize it again, your testcase would crash again, right? > > Right. We can apply the optimization at RTL expansion time though, > or handle the folding completely in gimple-fold with not needing to > dispatch to the gimplifier. After playing with the testcase in a debugger, my strong preference at least for the 4.8 branch would be just a global flag (or context flag) to prevent the nested folding. I think the only problematic thing is what starts with the avoid_folding_inline_builtin check in gimple_fold_builtin, and we should just prevent that from happening when called from within gimplify_and_update_call_from_tree (or just during that call when called from gimple_fold_call?). Normally, if folding of a builtin folds it into a call to some other builtin, that other builtin is folded right away, so the common case is optimized immediately, the only problem is if gimple_fold_builtin tries harder to optimize using maximum lengths or exact length (as in this case). And, for this it wouldn't even help if we handled STRCAT/STRCAT_CHK specially too and passed the src length to the folder routine, because gimple_fold_builtin first folds normally and only if that fails, attempts harder. Jakub
Re: [PATCH][RFC] Fix PR59860
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 01:35:05PM +0100, Richard Biener wrote: > > > tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, > > > known second strlen or movstr pattern, will only transform that if the > > > length of the resulting string is needed afterwards), and isn't run > > > for -Os or -O1 anyway. > > > > Well, I'm not sure under which circumstances this should be an > > unconditional win anyway (I expect the strcat library fn to be > > optimized well enough, and only if you can avoid the strlen on the > > dest in the end it will be profitable) > > No, while the strcat library fn can be very optimized, it still has no info > about how long the second parameter is. strcat is implementation is > typically an optimized strchr (dst, 0) followed by an optimized strcpy, > where the two can perhaps avoid some alignment adjustments or something. > But the strcpy still has to for each word or whatever chunk it reads test > for terminating zeros, while if you do an (optimized) strlen followed by > memcpy where you already know the length, that is a win. Well, strcat itself can do that ... but yes, as I said, if you can CSE that strlen call then it's a win. But you can't know this without more context. > > > But I guess if we optimize it again, your testcase would crash again, > > > right? > > > > Right. We can apply the optimization at RTL expansion time though, > > or handle the folding completely in gimple-fold with not needing to > > dispatch to the gimplifier. > > After playing with the testcase in a debugger, my strong preference at > least for the 4.8 branch would be just a global flag (or context flag) to > prevent > the nested folding. I think the only problematic thing is what starts with > the avoid_folding_inline_builtin check in gimple_fold_builtin, and we should > just prevent that from happening when called from within > gimplify_and_update_call_from_tree (or just during that call when called > from gimple_fold_call?). Yes, that is the piece that is the problem (iff otherwise recursive folding would never fold anything). > Normally, if folding of a builtin folds it into a call to some other > builtin, that other builtin is folded right away, so the common case is > optimized immediately, the only problem is if gimple_fold_builtin tries > harder to optimize using maximum lengths or exact length (as in this case). > And, for this it wouldn't even help if we handled STRCAT/STRCAT_CHK > specially too and passed the src length to the folder routine, because > gimple_fold_builtin first folds normally and only if that fails, attempts > harder. But we still can re-introduce the folding I removed from builtins.c below the avoid_folding_inline_builtin section as in that case builtins.c didn't do the folding and the gimple folding has strictly more information. No? I don't really like a special flag ... if, then I'd rather have a flag to tell the gimplfier not to fold stmts which we can set on the gimpifier context we push in gimplify_and_update_call_from_tree. Btw, I already applied the patch (I can of course revert it if we arrive at a better solution). I don't think I removed an important optimization (in fact usually it will be a pessimization if the strlen cannot be re-used - sth tree-ssa-strlen should be able to figure out). Richard.
[Ada] Change SPARK_Mode into GNATprove_Mode, and avoid expansion
The use of SPARK_Mode to refer to GNAT being called in the context of formal verification was confusing, because of the recent addition of a new pragma SPARK_Mode with a different meaning. This mode of the frontend has been renamed GNATprove_Mode, to refer to the tool it is used in. (This is similar to CodePeer_Mode.) The default setting of Expander_Active to True in this mode has also been changed to False, which better reflects the light expansion done in this mode, which has little in common with the true expansion. This should facilitate maintenance, as Expander_Active is restored to its meaning of generating code, and explicit mention of GNATprove_Mode is added each time some specific action is needed in GNATprove mode. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Yannick Moy * adabkend.adb, ali-util.adb, errout.adb, exp_ch7.adb, * exp_dbug.adb, freeze.adb, lib-xref.adb, restrict.adb, * sem_attr.adb, sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, * sem_prag.adb, sem_res.adb, sem_util.adb Rename SPARK_Mode into GNATprove_Mode. * sem_ch13.adb: Remove blank. * exp_spark.adb, exp_spark.ads (Expand_SPARK_Call): Only replace subprograms by alias for renamings, not for inherited primitive operations. * exp_util.adb (Expand_Subtype_From_Expr): Apply the expansion in GNATprove mode. (Remove_Side_Effects): Apply the removal in GNATprove mode, for the full analysis of expressions. * expander.adb (Expand): Call the light SPARK expansion in GNATprove mode. (Expander_Mode_Restore, Expander_Mode_Save_And_Set): Ignore save/restore actions for Expander_Active flag in GNATprove mode, similar to what is done in ASIS mode. * frontend.adb (Frontend): Generic bodies are instantiated in GNATprove mode. * gnat1drv.adb (Adjust_Global_Switches): Set operating mode to Check_Semantics in GNATprove mode, although a light expansion is still performed. (Gnat1drv): Set Back_End_Mode to Declarations_Only in GNATprove mode, and later on special case the GNATprove mode to continue analysis anyway. * lib-writ.adb (Write_ALI): Always generate ALI files in GNATprove mode. * opt.adb, opt.ads (Full_Expander_Active): Make it equivalent to Expander_Active. (SPARK_Mode): Renamed as GNATprove_Mode. * sem_aggr.adb (Aggregate_Constraint_Checks): Add checks in the tree in GNATprove_Mode. * sem_ch12.adb (Analyze_Package_Instantiation): Always instantiate body in GNATprove mode. (Need_Subprogram_Instance_Body): Always instantiate body in GNATprove mode. * sem_ch3.adb (Constrain_Index, Process_Range_Expr_In_Decl): Make sure side effects are removed in GNATprove mode. Index: sem_aggr.adb === --- sem_aggr.adb(revision 206790) +++ sem_aggr.adb(working copy) @@ -454,10 +454,14 @@ Check_Unset_Reference (Exp); end if; - -- This is really expansion activity, so make sure that expansion - -- is on and is allowed. + -- This is really expansion activity, so make sure that expansion is + -- on and is allowed. In GNATprove mode, we also want check flags to be + -- added in the tree, so that the formal verification can rely on those + -- to be present. - if not Expander_Active or else In_Spec_Expression then + if not (Expander_Active or GNATprove_Mode) +or In_Spec_Expression + then return; end if; @@ -996,10 +1000,10 @@ -- frozen so that initialization procedures can properly be called -- in the resolution that follows. The replacement of boxes with -- initialization calls is properly an expansion activity but it must - -- be done during revolution. + -- be done during resolution. if Expander_Active -and then Present (Component_Associations (N)) +and then Present (Component_Associations (N)) then declare Comp : Node_Id; Index: sem_ch3.adb === --- sem_ch3.adb (revision 206790) +++ sem_ch3.adb (working copy) @@ -10084,7 +10084,7 @@ -- SPARK mode. Since this is legal code with respect to theorem -- proving, do not emit the error. - if SPARK_Mode + if GNATprove_Mode and then Nkind (Exp) = N_Function_Call and then Nkind (Parent (Exp)) = N_Object_Declaration and then not Comes_From_Source @@ -12223,12 +12223,12 @@ -- needed, since checks may cause duplication of the expressions -- which must not be reevaluated. - -- The forced evaluation removes side effect
[Ada] Remove obsolete mode Full_Expander_Active
With the rewriting of the GNATprove mode of the frontend, the pseudo-flag Full_Expander_Active is now the same as Expander_Active, so remove it. Also, the special rewriting of renamings into renamed subprograms for each call done in GNATprove mode is now moved to the GNATprove backend. 2014-01-20 Yannick Moy * exp_spark.adb (Expand_SPARK_Call): Remove procedure. * opt.adb, opt.ads (Full_Expander_Active): Remove function. * checks.adb, exp_ch6.adb, exp_ch9.adb, exp_disp.adb, sem_aggr.adb, * sem_ch10.adb, sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, sem_ch9.adb, * sem_disp.adb, sem_res.adb Replace Full_Expander_Active by Expander_Active. Index: checks.adb === --- checks.adb (revision 206804) +++ checks.adb (working copy) @@ -478,7 +478,7 @@ -- are cases (e.g. with pragma Debug) where generating the checks -- can cause real trouble). - if not Full_Expander_Active then + if not Expander_Active then return; end if; @@ -960,7 +960,7 @@ if Backend_Overflow_Checks_On_Target or else not Do_Overflow_Check (N) - or else not Full_Expander_Active + or else not Expander_Active or else (Present (Parent (N)) and then Nkind (Parent (N)) = N_Type_Conversion and then Integer_Promotion_Possible (Parent (N))) @@ -1419,7 +1419,7 @@ -- Nothing to do if discriminant checks are suppressed or else no code -- is to be generated - if not Full_Expander_Active + if not Expander_Active or else Discriminant_Checks_Suppressed (T_Typ) then return; @@ -1732,7 +1732,7 @@ -- Proceed here in SUPPRESSED or CHECKED modes - if Full_Expander_Active + if Expander_Active and then not Backend_Divide_Checks_On_Target and then Check_Needed (Right, Division_Check) then @@ -1803,7 +1803,7 @@ Right : constant Node_Id:= Right_Opnd (N); begin - if Full_Expander_Active + if Expander_Active and then not Backend_Divide_Checks_On_Target and then Check_Needed (Right, Division_Check) then @@ -1914,7 +1914,7 @@ -- the frontend to expand these checks, which are dealt with directly -- in the formal verification backend. - if not Full_Expander_Active then + if not Expander_Active then return; end if; @@ -2945,7 +2945,7 @@ or else (not Length_Checks_Suppressed (Target_Typ)); begin - if not Full_Expander_Active then + if not Expander_Active then return; end if; @@ -3052,7 +3052,7 @@ or else (not Range_Checks_Suppressed (Target_Typ)); begin - if not Full_Expander_Active or else not Checks_On then + if not Expander_Active or else not Checks_On then return; end if; @@ -6290,7 +6290,7 @@ -- enhanced to check for an always True value in the condition and to -- generate a compilation warning??? - if not Full_Expander_Active or else not Checks_On then + if not Expander_Active or else not Checks_On then return; end if; @@ -8321,7 +8321,7 @@ -- Start of processing for Selected_Length_Checks begin - if not Full_Expander_Active then + if not Expander_Active then return Ret_Result; end if; @@ -8871,7 +8871,7 @@ -- Start of processing for Selected_Range_Checks begin - if not Full_Expander_Active then + if not Expander_Active then return Ret_Result; end if; Index: exp_ch6.adb === --- exp_ch6.adb (revision 206804) +++ exp_ch6.adb (working copy) @@ -9603,7 +9603,7 @@ -- may end up with a call that is neither resolved to an entity, nor -- an indirect call. - if not Full_Expander_Active then + if not Expander_Active then return False; end if; Index: exp_ch9.adb === --- exp_ch9.adb (revision 206804) +++ exp_ch9.adb (working copy) @@ -5813,7 +5813,7 @@ Ldecl2 : Node_Id; begin - if Full_Expander_Active then + if Expander_Active then -- If we have no handled statement sequence, we may need to build -- a dummy sequence consisting of a null statement. This can be @@ -6123,7 +6123,7 @@ -- barrier just as a protected function, and discard the protected -- version of it because it is never called. - if Full_Expander_Active then + if Expander_Active then B_F := Build_Barrier_Function (N, Ent, Prot); Func := Barrier_Function (Ent); Set_Corresponding_Spec (B_F, Func); @@ -6161,7 +6161,7 @@ -- condition does not reference any of the generated renam
[Ada] Abstract views of states and variables
This patch implements abstract views of states and variables defined as: State abstractions are visible in the limited view of packages in SPARK 2014. The notion of an abstract view of a variable declaration is also introduced, and the limited view of a package includes the abstract view of any variables declared in the visible part of that package. The only allowed uses of an abstract view of a variable are where the use of a state abstraction would be allowed (for example, in a Global aspect_specification). A name denoting the abstract view of a variable shall occur only: * As a global_item in a Global or Refined_Global aspect specification; or * As an input or output in a Depends or Refined_Depends aspect specification. Any state abstractions declared within a given package are present in the limited view of the package. [This means that, for example, a Globals aspect_specification for a subprogram declared in a library unit package P1 could refer to a state abstraction declared in a package P2 if P1 has a limited with of P2.] For every variable object declared by an object_declaration occurring immediately within the visible part of a given package, the limited view of the package contains an abstract view of the object. -- Source -- -- lim_pack.ads package Lim_Pack with Abstract_State => ((In_State with External, Input_Only), (Out_State with External, Output_Only)) is In_Var : Integer; Out_Var : Integer; end Lim_Pack; -- pack.ads limited with Lim_Pack; package Pack with Abstract_State => (S1, S2) is procedure Proc (Formal : Integer) with Global => (Input => (Lim_Pack.In_State, Lim_Pack.In_Var, S1), Output => (Lim_Pack.Out_State, Lim_Pack.Out_Var, S2)), Depends => ((Lim_Pack.Out_State, Lim_Pack.Out_Var, S2) => (Lim_Pack.In_State, Lim_Pack.In_Var, S1, Formal)); end Pack; -- pack.adb with Lim_Pack; use Lim_Pack; package body Pack with Refined_State => (S1 => V1, S2 => V2) is V1 : Integer := 0; V2 : Integer := 0; procedure Proc (Formal : Integer) with Refined_Global => (Input => (In_State, In_Var, V1), Output => (Out_State, Out_Var, V2)), Refined_Depends => ((Out_State, Out_Var, V2) => (In_State, In_Var, V1, Formal)) is begin null; end Proc; end Pack; - -- Compilation -- - $ gcc -c -gnatd.V pack.adb Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * einfo.adb (Non_Limited_View): Applies to abstract states. (Set_From_Limited_With): Applies to abstract states. (Set_Non_Limited_View): Applies to abstract states. (Write_Field17): Output the non-limited view of an abstract state. * einfo.ads: Update the comment on usage and occurrences in nodes for attributes From_Limited_With and Non_Limited_View. * sem_aux.adb (Available_View): This routine can now handle abstract states. * sem_aux.ads (Available_View): This routine can now handle abstract states. Update the comment on usage. * sem_ch8.adb (Find_Expanded_Name): Handle abstract views of states and variables. (In_Pragmas_Depends_Or_Global): New routine. * sem_ch10.adb (Build_Limited_Views): Implement abstract (limited) views of variables and states. (Build_Shadow_Entity): This routine is now a procedure. Add formal parameter Shadow. Update the comment on usage. Add context-specific decoration for states and variables. (Decorate_State): New routine. (Decorate_Variable): New routine. (Find_And_Process_States): New routine. (Process_Declarations): Renamed to Process_Declarations_And_States. (Process_Declarations_And_States): Add formal parameters Pack and Create_Abstract_Views. Update the comment on usage. (Process_States): New routine. * sem_prag.adb (Check_Dependency_Clause): Handle abstract views of states and variables. Match the abstract view of a state against its corresponding non-abstract view. (Is_Matching_Input): Handle abstract views of states and variables. Match the abstract view of a state against its corresponding non-abstract view. (Process_Global_Item): Handle abstract views of states and variables. Index: sem_aux.adb === --- sem_aux.adb (revision 206804) +++ sem_aux.adb (working copy) @@ -76,28 +76,35 @@ -- Available_View -- - function Available_View (Typ : Entity_Id) return Entity_Id is + function Available_View (Ent : Entity_Id) return Entity_Id is begin - if Is_Incomplete_Type (Typ) -and then Present (Non_Limited_View (Typ)) + -- Obtain the non-limited (non-ab
[Ada] Memory corruption in GNAT.Array_Split (and String_Split)
Use a copy-on-write scheme to ensure that a Slice_Set is not deallocated twice. The following program must execute under valgrind without error: with Ada.Text_IO; use Ada.Text_IO; with GNAT.String_Split; use GNAT.String_Split; procedure Gspl is C, C2 : Slice_Set; begin declare S : Slice_Set; begin Create (S, "toto|tutt", "|"); C := S; Create (S, "toto|tutt", "|"); Set (S, "|"); end; end Gspl; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Pascal Obry * g-arrspl.ads (Slice_Set): New definition (will use a copy on write scheme). * g-arrspl.adb: Adapt all routine to this new implementation. (Set): Copy the Slice_Set definition before reusing it. Index: g-arrspl.adb === --- g-arrspl.adb(revision 206804) +++ g-arrspl.adb(working copy) @@ -39,9 +39,6 @@ procedure Free is new Ada.Unchecked_Deallocation (Separators_Indexes, Indexes_Access); - procedure Free is - new Ada.Unchecked_Deallocation (Element_Sequence, Element_Access); - function Count (Source : Element_Sequence; Pattern : Element_Set) return Natural; @@ -54,7 +51,7 @@ procedure Adjust (S : in out Slice_Set) is begin - S.Ref_Counter.all := S.Ref_Counter.all + 1; + S.D.Ref_Counter := S.D.Ref_Counter + 1; end Adjust; @@ -81,10 +78,11 @@ Separators : Element_Set; Mode : Separator_Mode := Single) is + Result : Slice_Set; begin - Free (S.Source); - S.Source := new Element_Sequence'(From); - Set (S, Separators, Mode); + Result.D.Source := new Element_Sequence'(From); + Set (Result, Separators, Mode); + S := Result; end Create; --- @@ -116,23 +114,23 @@ new Ada.Unchecked_Deallocation (Element_Sequence, Element_Access); procedure Free is - new Ada.Unchecked_Deallocation (Natural, Counter); + new Ada.Unchecked_Deallocation (Data, Data_Access); - Ref_Counter : Counter := S.Ref_Counter; + D : Data_Access := S.D; begin -- Ensure call is idempotent - S.Ref_Counter := null; + S.D := null; - if Ref_Counter /= null then - Ref_Counter.all := Ref_Counter.all - 1; + if D /= null then + D.Ref_Counter := D.Ref_Counter - 1; - if Ref_Counter.all = 0 then -Free (S.Source); -Free (S.Indexes); -Free (S.Slices); -Free (Ref_Counter); + if D.Ref_Counter = 0 then +Free (D.Source); +Free (D.Indexes); +Free (D.Slices); +Free (D); end if; end if; end Finalize; @@ -143,7 +141,7 @@ procedure Initialize (S : in out Slice_Set) is begin - S.Ref_Counter := new Natural'(1); + S.D := new Data'(1, null, 0, null, null); end Initialize; @@ -155,11 +153,11 @@ Index : Slice_Number) return Slice_Separators is begin - if Index > S.N_Slice then + if Index > S.D.N_Slice then raise Index_Error; elsif Index = 0 -or else (Index = 1 and then S.N_Slice = 1) +or else (Index = 1 and then S.D.N_Slice = 1) then -- Whole string, or no separator used @@ -168,15 +166,15 @@ elsif Index = 1 then return (Before => Array_End, - After => S.Source (S.Slices (Index).Stop + 1)); + After => S.D.Source (S.D.Slices (Index).Stop + 1)); - elsif Index = S.N_Slice then - return (Before => S.Source (S.Slices (Index).Start - 1), + elsif Index = S.D.N_Slice then + return (Before => S.D.Source (S.D.Slices (Index).Start - 1), After => Array_End); else - return (Before => S.Source (S.Slices (Index).Start - 1), - After => S.Source (S.Slices (Index).Stop + 1)); + return (Before => S.D.Source (S.D.Slices (Index).Start - 1), + After => S.D.Source (S.D.Slices (Index).Stop + 1)); end if; end Separators; @@ -186,7 +184,7 @@ function Separators (S : Slice_Set) return Separators_Indexes is begin - return S.Indexes.all; + return S.D.Indexes.all; end Separators; - @@ -211,21 +209,55 @@ Separators : Element_Set; Mode : Separator_Mode := Single) is - Count_Sep : constant Natural := Count (S.Source.all, Separators); - J : Positive; + + procedure Copy_On_Write (S : in out Slice_Set); + -- Make a copy of S if shared with another variable + + --- + -- Copy_On_Write -- + --- + + procedure Copy_On_Write (S : in out Slice_Set) is + begin + if S.D.Ref_Counter > 1 then +-- First let's remove our count from the current data + +S.D
Re: [AArch64 Documentation] Clarify meaning of -mcpu, -mtune, -march
On 20/01/14 11:39, James Greenhalgh wrote: > > Hi, > > These three options can be a pain to remember how they interact > with one another, this patch clarifies the situation giving explicit > documentation as to the expected behaviour where they are combined. > > OK? > > Thanks, > James > > --- > gcc/ > > 2014-01-20 James Greenhalgh > > * doc/invoke.texi (-march): Clarify documentation for AArch64. > (-mtune): Likewise. > (-mcpu): Likewise. > > > 0001-AArch64-Documentation-Clarify-meaning-of-mcpu-mtune-.patch > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 9e16b3b..00bcfa6 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -11379,46 +11379,55 @@ of TLS variables. > Specify the name of the target architecture, optionally suffixed by one or > more feature modifiers. This option has the form > @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where the > -only value for @var{arch} is @samp{armv8-a}. The possible values for > -@var{feature} are documented in the sub-section below. > +only permissible value for @var{arch} is @samp{armv8-a}. The permissible > +values for @var{feature} are documented in the sub-section below. > > Where conflicting feature modifiers are specified, the right-most feature is > used. > > GCC uses this name to determine what kind of instructions it can emit when > -generating assembly code. This option can be used in conjunction with or > -instead of the @option{-mcpu=} option. > +generating assembly code. > + > +Where @option{-march} is specified without either of @option{-mtune} > +or @option{-mcpu} also being specified, the code will be tuned to perform > +well across a range of target processors implementing the target > +architecture. > + > +@item -mtune=@var{name} > +@opindex mtune > +Specify the name of the target processor for which GCC should tune the > +performance of the code. Permissible values for this option are: > +@samp{generic}, @samp{cortex-a53}, @samp{cortex-a57}. > + > +Additionally, this option can specify that GCC should tune the performance > +of the code for a big.LITTLE system. The only permissible value is > +@samp{cortex-a57.cortex-a53}. > + > +Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} > +are specified, the code will be tuned to perform well across a range > +of target processors. > + > +This option cannot be suffixed by feature modifiers. > > @item -mcpu=@var{name} > @opindex mcpu > Specify the name of the target processor, optionally suffixed by one or more > feature modifiers. This option has the form > @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where the > -possible values for @var{cpu} are @samp{generic}, @samp{cortex-a53}, > -@samp{cortex-a57}. The possible values for @var{feature} are documented > -in the sub-section below. > +permissible values for @var{cpu} are the same as those available for > +@option{-mtune}. > > -Additionally, this option can specify that the target is a big.LITTLE system. > -The only possible value is @samp{cortex-a57.cortex-a53}. > +The permissible values for @var{feature} are documented in the sub-section > below. > > Where conflicting feature modifiers are specified, the right-most feature is > used. > > GCC uses this name to determine what kind of instructions it can emit when > -generating assembly code. > - > -@item -mtune=@var{name} > -@opindex mtune > -Specify the name of the processor to tune the performance for. The code will > -be tuned as if the target processor were of the type specified in this > option, > -but still using instructions compatible with the target processor specified > -by a @option{-mcpu=} option. Where no @option{-mtune=} option is > -specified, the code will be tuned to perform well on the target processor > -given by @option{-mcpu=} or @option{-march=}. Where none of > -@option{-mtune=}, @option{-mcpu=} or @option{-march=} are specified, > -the code will be tuned to perform well across a range of target > -processors. This option cannot be suffixed by feature modifiers. > - > +generating assembly code (as if by @option{-march}) and to determine > +the target processor for which to tune for performance (as if > +by @option{-mtune}). Where this option is used in conjunction > +with @option{-march} or @option{-mtune}, those options override this > +option. > @end table > The override is partial in each case, so I suggest "..., those options take precedence." Otherwise, OK. R.
[Ada] Preliminary work to support ARM unwinder
Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Tristan Gingold * raise-gcc.c (exception_class_eq): New function. (is_handled_by): Use it to compare exception classes. (PERSONALITY_STORAGE): Define. (continue_unwind): New function to be called to return URC_CONTINUE_UNWIND. (personality_body): New function, extracted from PERSONALITY_ROUTINE. (PERSONALITY_ROUTINE): Add an implementation for the ARM unwinder. Index: raise-gcc.c === --- raise-gcc.c (revision 206804) +++ raise-gcc.c (working copy) @@ -212,7 +212,7 @@ { const phase_descriptor *a = phase_descriptors; - if (! (db_accepted_codes() & DB_PHASES)) + if (! (db_accepted_codes () & DB_PHASES)) return; db (DB_PHASES, "\n"); @@ -860,15 +860,33 @@ extern struct Exception_Data Non_Ada_Error; #endif +/* Return true iff the exception class of EXCEPT is EC. */ + +static int +exception_class_eq (const _GNAT_Exception *except, unsigned long long ec) +{ +#ifdef __ARM_EABI_UNWINDER__ + union { +char exception_class[8]; +unsigned long long ec; + } u; + + u.ec = ec; + return memcmp (except->common.exception_class, u.exception_class, 8) == 0; +#else + return except->common.exception_class == ec; +#endif +} + static enum action_kind -is_handled_by (_Unwind_Ptr choice, _GNAT_Exception * propagated_exception) +is_handled_by (_Unwind_Ptr choice, _GNAT_Exception *propagated_exception) { /* All others choice match everything. */ if (choice == GNAT_ALL_OTHERS) return handler; /* GNAT exception occurrence. */ - if (propagated_exception->common.exception_class == GNAT_EXCEPTION_CLASS) + if (exception_class_eq (propagated_exception, GNAT_EXCEPTION_CLASS)) { /* Pointer to the GNAT exception data corresponding to the propagated occurrence. */ @@ -913,7 +931,7 @@ return handler; /* C++ exception occurrences. */ - if (propagated_exception->common.exception_class == CXX_EXCEPTION_CLASS + if (exception_class_eq (propagated_exception, CXX_EXCEPTION_CLASS) && Language_For (choice) == 'C') { void *choice_typeinfo = Foreign_Data_For (choice); @@ -1070,14 +1088,120 @@ /* Below is the eh personality routine per se. We currently assume that only GNU-Ada exceptions are met. */ +/* By default, the personality routine is public. */ +#define PERSONALITY_STORAGE + #ifdef __USING_SJLJ_EXCEPTIONS__ #define PERSONALITY_FUNCTION__gnat_personality_sj0 #elif defined (__SEH__) #define PERSONALITY_FUNCTION__gnat_personality_imp +/* The public personality routine for seh is __gnat_personality_seh0, defined + below using the SEH convention. This is a wrapper around the GNU routine, + which is static. */ +#undef PERSONALITY_STORAGE +#define PERSONALITY_STORAGE static #else #define PERSONALITY_FUNCTION__gnat_personality_v0 #endif +/* Code executed to continue unwinding. With the ARM unwinder, the + personality routine must unwind one frame. */ + +static _Unwind_Reason_Code +continue_unwind (struct _Unwind_Exception* ue_header, +struct _Unwind_Context* uw_context) +{ +#ifdef __ARM_EABI_UNWINDER__ + if (__gnu_unwind_frame (ue_header, uw_context) != _URC_OK) +return _URC_FAILURE; +#endif + return _URC_CONTINUE_UNWIND; +} + +/* Common code for the body of GNAT personality routine. This code is shared + between all unwinders. */ + +static _Unwind_Reason_Code +personality_body (_Unwind_Action uw_phases, + _Unwind_Exception *uw_exception, + _Unwind_Context *uw_context) +{ + region_descriptor region; + action_descriptor action; + _Unwind_Ptr ip; + + /* Debug traces. */ + db_indent (DB_INDENT_RESET); + db_phases (uw_phases); + db_indent (DB_INDENT_INCREASE); + + /* Get the region description for the context we were provided with. This + will tell us if there is some lsda, call_site, action and/or ttype data + for the associated ip. */ + get_region_description_for (uw_context, ®ion); + + /* No LSDA => no handlers or cleanups => we shall unwind further up. */ + if (! region.lsda) +return continue_unwind (uw_exception, uw_context); + + /* Get the instruction pointer. */ + ip = get_ip_from_context (uw_context); + db_region_for (®ion, ip); + + /* Search the call-site and action-record tables for the action associated + with this IP. */ + get_action_description_for (ip, uw_exception, uw_phases, ®ion, &action); + db_action_for (&action, ip); + + /* Whatever the phase, if there is nothing relevant in this frame, + unwinding should just go on. */ + if (action.kind == nothing) +return continue_unwind (uw_exception, uw_context); + + /* If we found something in search phase, we should return a code indicating + what to do next depending on what we found. If we only have cleanups + around, we shall try to unwind further up to find a h
Re: [PATCH][RFC] Fix PR59860
On Mon, Jan 20, 2014 at 02:37:21PM +0100, Richard Biener wrote: > Well, strcat itself can do that ... but yes, as I said, if you can > CSE that strlen call then it's a win. But you can't know this without It can't, strcat doesn't know the length of the src string, we don't have any 3 argument strcat alternative API where the compiler tells it the length of the string that the compiler knows, but the function doesn't. > > Normally, if folding of a builtin folds it into a call to some other > > builtin, that other builtin is folded right away, so the common case is > > optimized immediately, the only problem is if gimple_fold_builtin tries > > harder to optimize using maximum lengths or exact length (as in this case). > > And, for this it wouldn't even help if we handled STRCAT/STRCAT_CHK > > specially too and passed the src length to the folder routine, because > > gimple_fold_builtin first folds normally and only if that fails, attempts > > harder. > > But we still can re-introduce the folding I removed from builtins.c > below the avoid_folding_inline_builtin section as in that case > builtins.c didn't do the folding and the gimple folding has > strictly more information. No? I don't really like a special There are two cases. One is where the length of the second string is really variable or not known to the compiler. Then I agree library strcat ought to do the exact same job, it is strlen + movstr instruction. The other case is your testcase, where it is just because the compiler did a poor job. I guess we can use something like following untested patch for that. Or supposedly we could only change fold_builtin_strcat and leave strcat_chk unmodified, after all strcat_chk folding is only handling the case where the size is -1UL (i.e. unknown) and then folds to strcat. 2014-01-20 Jakub Jelinek * tree.h (fold_builtin_strcat, fold_builtin_strcat_chk): New prototypes. * builtins.c (fold_builtin_strcat): No longer static. Add len argument, if non-NULL, don't call c_strlen. Optimize directly into __builtin_memcpy instead of __builtin_strcpy. (fold_builtin_strcat_chk): No longer static. Add len argument, if non-NULL, call fold_builtin_strcat. (fold_builtin_2): Adjust fold_builtin_strcat{,_chk} callers. * gimple-fold.c (gimple_fold_builtin): Handle BUILT_IN_STRCAT and BUILT_IN_STRCAT_CHK. --- gcc/tree.h.jj 2014-01-07 17:49:40.0 +0100 +++ gcc/tree.h 2014-01-20 15:04:48.273418236 +0100 @@ -5854,12 +5854,14 @@ extern tree fold_call_expr (location_t, extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree); extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree); extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree); +extern tree fold_builtin_strcat (location_t, tree, tree, tree); extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree, tree, bool, enum built_in_function); extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, bool, enum built_in_function); extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree, bool, enum built_in_function); +extern tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree, tree); extern tree fold_builtin_snprintf_chk (location_t, tree, tree, enum built_in_function); extern bool fold_builtin_next_arg (tree, bool); extern enum built_in_function builtin_mathfn_code (const_tree); --- gcc/builtins.c.jj 2014-01-20 12:41:48.0 +0100 +++ gcc/builtins.c 2014-01-20 15:19:23.585947825 +0100 @@ -180,7 +180,6 @@ static tree fold_builtin_varargs (locati static tree fold_builtin_strpbrk (location_t, tree, tree, tree); static tree fold_builtin_strstr (location_t, tree, tree, tree); static tree fold_builtin_strrchr (location_t, tree, tree, tree); -static tree fold_builtin_strcat (location_t, tree, tree); static tree fold_builtin_strncat (location_t, tree, tree, tree); static tree fold_builtin_strspn (location_t, tree, tree); static tree fold_builtin_strcspn (location_t, tree, tree); @@ -194,7 +193,6 @@ static void maybe_emit_chk_warning (tree static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function); static void maybe_emit_free_warning (tree); static tree fold_builtin_object_size (tree, tree); -static tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree); static tree fold_builtin_strncat_chk (location_t, tree, tree, tree, tree, tree); static tree fold_builtin_sprintf_chk (location_t, tree, enum built_in_function); static tree fold_builtin_printf (location_t, tree, tree, tree, bool, enum built_in_function); @@ -10770,7 +10768,7 @@ fold_builtin_2 (location_t loc, tree fnd return fold_builtin_strstr (loc, arg0, arg1, type); case BUILT_IN_STRCAT: - return fold_builtin
Re: [PATCH][RFC] Fix PR59860
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 02:37:21PM +0100, Richard Biener wrote: > > Well, strcat itself can do that ... but yes, as I said, if you can > > CSE that strlen call then it's a win. But you can't know this without > > It can't, strcat doesn't know the length of the src string, we don't have > any 3 argument strcat alternative API where the compiler tells it the length > of the string that the compiler knows, but the function doesn't. > > > > Normally, if folding of a builtin folds it into a call to some other > > > builtin, that other builtin is folded right away, so the common case is > > > optimized immediately, the only problem is if gimple_fold_builtin tries > > > harder to optimize using maximum lengths or exact length (as in this > > > case). > > > And, for this it wouldn't even help if we handled STRCAT/STRCAT_CHK > > > specially too and passed the src length to the folder routine, because > > > gimple_fold_builtin first folds normally and only if that fails, attempts > > > harder. > > > > But we still can re-introduce the folding I removed from builtins.c > > below the avoid_folding_inline_builtin section as in that case > > builtins.c didn't do the folding and the gimple folding has > > strictly more information. No? I don't really like a special > > There are two cases. One is where the length of the second string > is really variable or not known to the compiler. Then I agree library > strcat ought to do the exact same job, it is strlen + movstr instruction. > The other case is your testcase, where it is just because the compiler did a > poor job. I guess we can use something like following untested patch > for that. Or supposedly we could only change fold_builtin_strcat and > leave strcat_chk unmodified, after all strcat_chk folding is only handling > the case where the size is -1UL (i.e. unknown) and then folds to strcat. That works for me. Richard. > 2014-01-20 Jakub Jelinek > > * tree.h (fold_builtin_strcat, fold_builtin_strcat_chk): New > prototypes. > * builtins.c (fold_builtin_strcat): No longer static. Add len > argument, if non-NULL, don't call c_strlen. Optimize > directly into __builtin_memcpy instead of __builtin_strcpy. > (fold_builtin_strcat_chk): No longer static. Add len argument, > if non-NULL, call fold_builtin_strcat. > (fold_builtin_2): Adjust fold_builtin_strcat{,_chk} callers. > * gimple-fold.c (gimple_fold_builtin): Handle BUILT_IN_STRCAT > and BUILT_IN_STRCAT_CHK. > > --- gcc/tree.h.jj 2014-01-07 17:49:40.0 +0100 > +++ gcc/tree.h2014-01-20 15:04:48.273418236 +0100 > @@ -5854,12 +5854,14 @@ extern tree fold_call_expr (location_t, > extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree); > extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree); > extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree); > +extern tree fold_builtin_strcat (location_t, tree, tree, tree); > extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, > tree, tree, bool, >enum built_in_function); > extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, > tree, bool, >enum built_in_function); > extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, > tree, bool, > enum built_in_function); > +extern tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree, > tree); > extern tree fold_builtin_snprintf_chk (location_t, tree, tree, enum > built_in_function); > extern bool fold_builtin_next_arg (tree, bool); > extern enum built_in_function builtin_mathfn_code (const_tree); > --- gcc/builtins.c.jj 2014-01-20 12:41:48.0 +0100 > +++ gcc/builtins.c2014-01-20 15:19:23.585947825 +0100 > @@ -180,7 +180,6 @@ static tree fold_builtin_varargs (locati > static tree fold_builtin_strpbrk (location_t, tree, tree, tree); > static tree fold_builtin_strstr (location_t, tree, tree, tree); > static tree fold_builtin_strrchr (location_t, tree, tree, tree); > -static tree fold_builtin_strcat (location_t, tree, tree); > static tree fold_builtin_strncat (location_t, tree, tree, tree); > static tree fold_builtin_strspn (location_t, tree, tree); > static tree fold_builtin_strcspn (location_t, tree, tree); > @@ -194,7 +193,6 @@ static void maybe_emit_chk_warning (tree > static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function); > static void maybe_emit_free_warning (tree); > static tree fold_builtin_object_size (tree, tree); > -static tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree); > static tree fold_builtin_strncat_chk (location_t, tree, tree, tree, tree, > tree); > static tree fold_builtin_sprintf_chk (location_t, tree, enum > built_in_function); > static tree fold_builtin_printf (location_t, tree
[Ada] Cleanup of aspect/pragma Refined_Post
This patch adds logic to verify that the expression of aspect/pragma Refined_Post mentions 'Result and introduces a post-state when applied to a function. -- Source -- -- result_and_post.ads package Result_And_Post is function OK (Formal : Integer) return Integer; function Error (Formal : Integer) return Integer; end Result_And_Post; -- result_and_post.adb package body Result_And_Post is function OK (Formal : Integer) return Integer with Refined_Post => OK'Result = Formal + 1 is begin return Formal + 1; end OK; function Error (Formal : Integer) return Integer with Refined_Post => True is begin return Formal + 1; end Error; end Result_And_Post; -- Compilation and output -- $ gcc -c -gnatw.t result_and_post.adb result_and_post.adb:10:11: warning: aspect "Refined_Post" does not mention function result Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * sem_attr.adb (Analyze_Attribute): Attributes 'Old and 'Result can now apply to a refined postcondition. * sem_ch6.adb (Analyze_Subprogram_Contract): Remove local variable Result_Seen. Add variables Case_Prag, Post_Prag, Seen_In_Case and Seen_In_Post. Update the mechanism that detects whether postconditions and/or constract-cases mention attribute 'Result and introduce a post-state when applied to functions. (Check_Result_And_Post_State): Removed. * sem_prag.adb (Analyze_Pragma): Add local variable Result_Seen. Verify that the expression of pragma Refined_Post mentions attribute 'Result and introduces a post-state. * sem_util.ads, sem_util.adb (Check_Result_And_Post_State): New routine. Index: sem_prag.adb === --- sem_prag.adb(revision 206818) +++ sem_prag.adb(working copy) @@ -17331,9 +17331,10 @@ -- pragma Refined_Post (boolean_EXPRESSION); when Pragma_Refined_Post => Refined_Post : declare -Body_Id : Entity_Id; -Legal : Boolean; -Spec_Id : Entity_Id; +Body_Id : Entity_Id; +Legal : Boolean; +Result_Seen : Boolean := False; +Spec_Id : Entity_Id; begin Analyze_Refined_Pragma (Spec_Id, Body_Id, Legal); @@ -17342,6 +17343,20 @@ if Legal then Analyze_Pre_Post_Condition_In_Decl_Part (N, Spec_Id); + + -- Verify that the refined postcondition mentions attribute + -- 'Result and its expression introduces a post-state. + + if Warn_On_Suspicious_Contract + and then Ekind_In (Spec_Id, E_Function, E_Generic_Function) + then + Check_Result_And_Post_State (N, Result_Seen); + + if not Result_Seen then + Error_Pragma + ("pragma % does not mention function result?T?"); + end if; + end if; end if; end Refined_Post; Index: sem_util.adb === --- sem_util.adb(revision 206805) +++ sem_util.adb(working copy) @@ -2396,6 +2396,168 @@ end loop; end Check_Potentially_Blocking_Operation; + - + -- Check_Result_And_Post_State -- + - + + procedure Check_Result_And_Post_State + (Prag: Node_Id; + Result_Seen : in out Boolean) + is + procedure Check_Expression (Expr : Node_Id); + -- Perform the 'Result and post-state checks on a given expression + + function Is_Function_Result (N : Node_Id) return Traverse_Result; + -- Attempt to find attribute 'Result in a subtree denoted by N + + function Is_Trivial_Boolean (N : Node_Id) return Boolean; + -- Determine whether source node N denotes "True" or "False" + + function Mentions_Post_State (N : Node_Id) return Boolean; + -- Determine whether a subtree denoted by N mentions any construct that + -- denotes a post-state. + + procedure Check_Function_Result is +new Traverse_Proc (Is_Function_Result); + + -- + -- Check_Expression -- + -- + + procedure Check_Expression (Expr : Node_Id) is + begin + if not Is_Trivial_Boolean (Expr) then +Check_Function_Result (Expr); + +if not Mentions_Post_State (Expr) then + if Pragma_Name (Prag) = Name_Contract_Cases then + Error_Msg_N +("contract case refers only to pre-state?T?", Expr); + + elsif Pragma_Name (Prag) = Name_Refined_Post then + Error_Msg_N +
[Ada] Missing finalization of transient result with exception
This patch corrects the finalization machinery to ensure that a controlled transient result is finalized when the related context raises an exception. -- Source -- -- pack.ads with Ada.Finalization; use Ada.Finalization; package Pack is type Ctrl is new Controlled with record Id : Natural; end record; procedure Adjust (Obj : in out Ctrl); procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); function Bomb (Val : Ctrl) return Boolean; function Exists (Val : Ctrl) return Boolean; function Is_Even (Val : Natural) return Boolean; function New_Ctrl return Ctrl; end Pack; -- pack.adb with Ada.Text_IO; use Ada.Text_IO; package body Pack is Id_Gen : Natural := 0; function Next_Id return Natural; procedure Adjust (Obj : in out Ctrl) is Old_Id : constant Natural := Obj.Id; New_Id : constant Natural := Old_Id * 100; begin Put_Line (" adj" & Old_Id'Img & " ->" & New_Id'Img); Obj.Id := New_Id; end Adjust; function Bomb (Val : Ctrl) return Boolean is pragma Unreferenced (Val); begin raise Program_Error; return False; end Bomb; function Exists (Val : Ctrl) return Boolean is begin return Val.Id > 0; end Exists; procedure Finalize (Obj : in out Ctrl) is begin Put_Line (" fin" & Obj.Id'Img); Obj.Id := 0; end Finalize; procedure Initialize (Obj : in out Ctrl) is begin Obj.Id := Next_Id; Put_Line (" ini" & Obj.Id'Img); end Initialize; function Is_Even (Val : Natural) return Boolean is begin return Val / 2 = 0; end Is_Even; function Next_Id return Natural is begin Id_Gen := Id_Gen + 1; return Id_Gen; end Next_Id; function New_Ctrl return Ctrl is Result : Ctrl; begin return Result; end New_Ctrl; end Pack; -- main.adb with Ada.Text_IO; use Ada.Text_IO; with Pack;use Pack; procedure Main is function Factorial (Val : Natural) return Natural is begin if Val > 1 then return Factorial (Val - 1) * Val; else return 1; end if; end Factorial; begin Put_Line ("Normal execution"); if Is_Even (Factorial (2)) or Exists (New_Ctrl) then Put_Line ("Normal execution -> True"); else Put_Line ("Normal execition -> False"); end if; Put_Line ("Exception"); begin if Is_Even (Factorial (3)) or Bomb (New_Ctrl) then Put_Line ("ERROR"); else Put_Line ("ERROR"); end if; exception when Program_Error => null; when others => Put_Line ("ERROR"); end; Put_Line ("End"); end Main; -- Compilation and output -- $ gnatmake -q main.adb $ ./main Normal execution ini 1 adj 1 -> 100 fin 1 fin 100 Normal execution -> True Exception ini 2 adj 2 -> 200 fin 2 fin 200 End Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * exp_ch7.adb (Is_Subprogram_Call): New routine. (Process_Transient_Objects): Make variable Must_Hook global with respect to all locally declared subprograms. Search the context for at least one subprogram call. (Requires_Hooking): Removed. Index: exp_ch7.adb === --- exp_ch7.adb (revision 206805) +++ exp_ch7.adb (working copy) @@ -4480,33 +4480,45 @@ Last_Object : Node_Id; Related_Node : Node_Id) is - function Requires_Hooking return Boolean; - -- Determine whether the context requires transient variable export - -- to the outer finalizer. This scenario arises when the context may - -- raise an exception. + Must_Hook : Boolean := False; + -- Flag denoting whether the context requires transient variable + -- export to the outer finalizer. - -- - -- Requires_Hooking -- - -- + function Is_Subprogram_Call (N : Node_Id) return Traverse_Result; + -- Determine whether an arbitrary node denotes a subprogram call - function Requires_Hooking return Boolean is + + -- Is_Subprogram_Call -- + + + function Is_Subprogram_Call (N : Node_Id) return Traverse_Result is begin --- The context is either a procedure or function call or an object --- declaration initialized by a function call. Note that in the --- latter case, a function call that returns on the secondary --- stack is usually rewritten into something else. Its proper --- detection requires examination of the original initialization --- expression. +-- A regular procedure or function call -return Nki
Re: [PATCH] Don't combine across likely spilled hard reg setters (PR rtl-optimization/59477)
On 1/20/2014, 4:12 AM, Eric Botcazou wrote: I think the problem is still either a missed feature in LRA/reload (split live-ranges), a problem in how we represent calls & argument setup (magic hard-reg uses), or a backend problem (should spill itself if necessary, via a post-reload splitter or always spill and undo via a peephole2). Of course papering over in combine might be the best at this stage. So the above was just observations from the less experienced people in this area. Yes, this is ultimately a RA issue, but an ancient and hard one as far as I understand so papering over it makes sense I think. That being said, while Joern's machinery was IMO acceptable because relatively simple and localized, Jakub's looks more complicated and far-reaching (that's why I suggested to try to extend the existing machinery if possible) so I think that we ought to try something simpler first. I've just started to work on fixing this in LRA. But I am not going to work on fixing this in reload. It would be just wasting enormous amount of time.
[Ada] Aspects Depends and Global on subprogram body stubs
This patch corrects the relocation of aspects related to a subprogram body stub that also acts as a spect. -- Source -- -- stubs.ads package Stubs is procedure S1 (L, R : in out Integer) with Depends => (L => R, R => L); procedure Error1 (L, R : in out Integer) with Depends => (L => R, R => L); end Stubs; -- stubs.adb package body Stubs is procedure S1 (L, R : in out Integer) is separate; procedure S2 (L, R : in out Integer) is separate with Depends => (L => R, R => L); procedure Error1 (L, R : in out Integer) is separate; procedure Error2 (L, R : in out Integer) is separate with Depends => (L => R, R => L); procedure Error3 (L, R : in out Integer) is separate; end Stubs; -- stubs-error1.adb separate (Stubs) procedure Error1 (L, R : in out Integer) with Depends => (L => R, R => L) is begin null; end Error1; -- stubs-error2.adb separate (Stubs) procedure Error2 (L, R : in out Integer) with Depends => (L => R, R => L) is begin null; end Error2; -- stubs-error3.adb separate (Stubs) procedure Error3 (L, R : in out Integer) with Depends => (L => R, R => L) is begin null; end Error3; -- stubs-s1.adb separate (Stubs) procedure S1 (L, R : in out Integer) is begin null; end S1; -- stubs-s2.adb separate (Stubs) procedure S2 (L, R : in out Integer) is begin null; end S2; -- Compilation and output -- $ gcc -c -gnatd.V stubs.adb stubs-error1.adb:3:01: aspect specifications must appear in subprogram declaration stubs-error2.adb:4:08: incorrect placement of aspect "Depends" stubs-error3.adb:4:08: incorrect placement of aspect "Depends" Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * aspects.adb (Move_Or_Merge_Aspects): Reimplemented. Index: aspects.adb === --- aspects.adb (revision 206804) +++ aspects.adb (working copy) @@ -310,23 +310,87 @@ --- procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id) is - begin - if Has_Aspects (From) then + procedure Relocate_Aspect (Asp : Node_Id); + -- Asp denotes an aspect specification of node From. Relocate the Asp to + -- the aspect specifications of node To (if any). - -- Merge the aspects of From into To. Make sure that From has no - -- aspects after the merge takes place. + - + -- Relocate_Aspect -- + - + procedure Relocate_Aspect (Asp : Node_Id) is + Asps : List_Id; + + begin if Has_Aspects (To) then -Append_List - (List => Aspect_Specifications (From), - To => Aspect_Specifications (To)); -Remove_Aspects (From); +Asps := Aspect_Specifications (To); - -- Otherwise simply move the aspects + -- Create a new aspect specification list for node To else -Move_Aspects (From => From, To => To); +Asps := New_List; +Set_Aspect_Specifications (To, Asps); +Set_Has_Aspects (To); end if; + + -- Remove the aspect from node From's aspect specifications and + -- append it to node To. + + Remove (Asp); + Append (Asp, Asps); + end Relocate_Aspect; + + -- Local variables + + Asp : Node_Id; + Asp_Id : Aspect_Id; + Next_Asp : Node_Id; + + -- Start of processing for Move_Or_Merge_Aspects + + begin + if Has_Aspects (From) then + Asp := First (Aspect_Specifications (From)); + while Present (Asp) loop + +-- Store the next aspect now as a potential relocation will alter +-- the contents of the list. + +Next_Asp := Next (Asp); + +-- When moving or merging aspects from a subprogram body stub that +-- also acts as a spec, relocate only those aspects that may apply +-- to a body [stub]. Note that a precondition must also be moved +-- to the proper body as the pre/post machinery expects it to be +-- there. + +if Nkind (From) = N_Subprogram_Body_Stub + and then No (Corresponding_Spec_Of_Stub (From)) +then + Asp_Id := Get_Aspect_Id (Asp); + + if Aspect_On_Body_Or_Stub_OK (Asp_Id) + or else Asp_Id = Aspect_Pre + or else Asp_Id = Aspect_Precondition + then + Relocate_Aspect (Asp); + end if; + +-- Default case - relocate the aspect to its new owner + +else + Relocate_Aspect (Asp); +end if; + +Asp := Next_Asp; + end loop; + + -- The relocations may have left node From's aspect specifications + -- list e
[Ada] New pragma Allow_Integer_Address
The new configuration pragma Allow_Integer_Address sets a mode in which expressions of an integer type may be used in constructs that normally require an expression of type System.Address. The effect is to introduce an implicit unchecked conversion from the integer type to type Address. This mode is set automatically in the relaxed semantic mode activated by debug flag -gnatd.M or when operating in codepeer mode. The following package compiles without errors: 1. pragma Allow_Integer_Address; 2. with System; use System; 3. package AddrAsInt is 4.X : Integer; 5.Y : Integer; 6.for X'Address use 16#1240#; 7.for Y use at 16#3230#; 8.m : Address := 16#4000#; 9.n : constant Address := 4000; 10.p : constant Address := Address (X + Y); 11.type R is new integer; 12.RR : R := 1000; 13.Z : Integer; 14.for Z'Address use RR; 15. end AddrAsInt; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Robert Dewar * gnat1drv.adb: Set Allow_Integer_Address in relaxed semantics mode. * gnat_rm.texi: Document pragma Allow_Integer_Address. * gnat_ugn.texi: Document pragma Allow_Integer_Address, -gnates. * opt.ads: New flag Allow_Integer_Address. * par-prag.adb: Dummy entry for pragma Allow_Integer_Address. * sem_ch5.adb: Minor reformatting. * sem_prag.adb: Implement pragma Allow_Integer_Address. * sem_res.adb (Resolve): Allow integer address value if switch set. * sem_util.adb: Minor reformatting. * snames.ads-tmpl: Add entry for pragma Allow_Integer_Address. * switch-c.adb: Recognize flag -gnates. * usage.adb: Document flag -gnates. Index: gnat_rm.texi === --- gnat_rm.texi(revision 206821) +++ gnat_rm.texi(working copy) @@ -104,6 +104,7 @@ * Pragma Ada_2005:: * Pragma Ada_12:: * Pragma Ada_2012:: +* Pragma Allow_Integer_Address:: * Pragma Annotate:: * Pragma Assert:: * Pragma Assert_And_Cut:: @@ -276,6 +277,7 @@ * Aspect Abstract_State:: * Aspect Ada_2005:: * Aspect Ada_2012:: +* Pragma Allow_Integer_Address:: * Aspect Compiler_Unit:: * Aspect Contract_Cases:: * Aspect Depends:: @@ -927,6 +929,7 @@ * Pragma Ada_2005:: * Pragma Ada_12:: * Pragma Ada_2012:: +* Pragma Allow_Integer_Address:: * Pragma Annotate:: * Pragma Assert:: * Pragma Assert_And_Cut:: @@ -1218,6 +1221,42 @@ This configuration pragma is a synonym for pragma Ada_12 and has the same syntax and effect. +@node Pragma Allow_Integer_Address +@unnumberedsec Pragma Allow_Integer_Address +@findex Allow_Integer_Address +@noindent +Syntax: +@smallexample @c ada +pragma Allow_Integer_Address; +@end smallexample + +@noindent +In most versions of GNAT, @code{System.Address} is a private type, which means +that integer values are not allowed. If the configuration pragma +@code{Allow_Integer_Address} is given, then integer expressions may +be used anywhere a value of type @code{System.Address} is required. +The effect is to introduce an implicit unchecked conversion from the +integer value to type @code{System.Address}. The following example +compiles without errors: + +@smallexample @c ada +pragma Allow_Integer_Address; +with System; use System; +package AddrAsInt is + X : Integer; + Y : Integer; + for X'Address use 16#1240#; + for Y use at 16#3230#; + m : Address := 16#4000#; + n : constant Address := 4000; + p : constant Address := Address (X + Y); + type R is new integer; + RR : R := 1000; + Z : Integer; + for Z'Address use RR; +end AddrAsInt; +@end smallexample + @node Pragma Annotate @unnumberedsec Pragma Annotate @findex Annotate Index: sem_ch5.adb === --- sem_ch5.adb (revision 206824) +++ sem_ch5.adb (working copy) @@ -1695,8 +1695,8 @@ Set_Ekind (Def_Id, E_Variable); - -- Provide a link between the iterator variable and the container, - -- for subequent use in cross-reference and modification information. + -- Provide a link between the iterator variable and the container, for + -- subsequent use in cross-reference and modification information. if Of_Present (N) then Set_Related_Expression (Def_Id, Iter_Name); Index: switch-c.adb === --- switch-c.adb(revision 206804) +++ switch-c.adb(working copy) @@ -660,6 +660,15 @@ when 'P' => Treat_Categorization_Errors_As_Warnings := True; + -- -gnates (allow integer expression for System.Address) + + -- Note: there is no VMS equivalent for this switch, since + -- in VMS, System.Address is an integer type in any case. + + when 's' => + Allow_Integer_A
[Ada] Enabling assertions in predefined units
Some configuration switches that usually do not apply to predefined units, such as enabling assertion checking, can be applied to such a unit when they are the main unit and the switch is provided in the compilation command. When such a unit is a package body, the switch setting must apply as well to its spec. The following must execute quietly: gcc -c -gnatg s-libm.ads gcc -c -gnatg -gnata s-libaux.adb gnatmake -q -gnatws missedpost missedpost --- with System.Libm.Aux; use System.Libm.Aux; with Ada.Assertions; use Ada.Assertions; procedure Missedpost is X: Float := 0.866; begin P (X); if abs X >= 0.5 then raise Program_Error; end if; exception when Assertion_Error => null; end Missedpost; --- package body System.Libm.Aux is procedure P (X : in out Float) is begin X := (0.5 + X) * 0.5; end P; end System.Libm.Aux; --- package System.Libm.Aux is pragma Assertion_Policy (Postcondition => Check); procedure P (X : in out Float) with Post => abs X <= 0.5; end System.Libm.Aux; --- package System.Libm is end System.Libm; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Ed Schonberg * sem.adb (Semantics): When saving/restoring configuration switches, the spec of a pre- defined unit that is the main unit must be treated as a predefined unit as well. Index: sem.adb === --- sem.adb (revision 206804) +++ sem.adb (working copy) @@ -1322,6 +1322,16 @@ -- If the main unit is generic, every compiled unit, including its -- context, is compiled with expansion disabled. + -- configuration flags have special settings when compiling a predefined + -- file as a main unit. This applies to its spec as well. + + Is_Main_Unit : constant Boolean := + Current_Sem_Unit = Main_Unit + or else + (Nkind (Unit (Cunit (Main_Unit))) = N_Package_Body + and then Library_Unit (Cunit (Main_Unit)) = + Cunit (Current_Sem_Unit)); + Ext_Main_Source_Unit : constant Boolean := In_Extended_Main_Source_Unit (Comp_Unit); -- Determine if unit is in extended main source unit @@ -1421,7 +1431,7 @@ Save_Opt_Config_Switches (Save_Config_Switches); Set_Opt_Config_Switches (Is_Internal_File_Name (Unit_File_Name (Current_Sem_Unit)), - Current_Sem_Unit = Main_Unit); + Is_Main_Unit); -- Save current non-partition-wide restrictions
[Ada] Refinements for pragma Allow_Integer_Address
The switch -gnates is no longer available, this mode must be set using the configuration pragma, or -gnatd.M or is set automatically in CodePeer mode. The pragma is now only allowed if Address is a private type (since otherwise it makes no sense), and finally an error is corrected which caused the following test to fail: Given the following gnat.adc file: pragma Extend_System (Aux_AAMP); where s-auxaam.ads contains the declarations: function "+" (Left : Address; Right : Integer) return Address; function "+" (Left : Integer; Right : Address) return Address; function "-" (Left : Address; Right : Integer) return Address; function "-" (Left : Integer; Right : Address) return Address; function "-" (Left : Address; Right : Address) return Integer; The following should compile silently with -gnatd.M 1. with System; use System; 2. package Sys is 3.Variable1 : Integer; 4.for Variable1 use at 16#43FFF0#; 5.Variable2 : System.Address; 6.Start_Address : constant System.Address := 16#1234#; 7.Max_Words : constant := 32; 8.Addr : System.Address := 9. System.Address (Start_Address + Max_Words); 10.App_Start : System.Address := Variable1'Address; 11.App_End : System.Address := Variable2'Address; 12.App_Block_Size : constant System.Address := 13. (App_End - App_Start + 1); 14. end Sys; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Robert Dewar * gnat_rm.texi: Document that Allow_Integer_Address is permitted only if System.Address is a private type. * opt.ads (Allow_Integer_Address): No longer set by -gnates. * sem_prag.adb (Analyze_Pragma, case Allow_Integer_Address): Allowed only if type System.Address is private, since otherwise it makes no sense. * sem_res.adb: Fix failure to properly Analyze unchecked conversions that were introduced by Allow_Integer_Address. * switch-c.adb: Remove -gnates switch. * usage.adb: Remove -gnates switch. * gnat_ugn.texi: Remove documentation of -gnates flag. Index: gnat_rm.texi === --- gnat_rm.texi(revision 206825) +++ gnat_rm.texi(working copy) @@ -1231,8 +1231,11 @@ @end smallexample @noindent -In most versions of GNAT, @code{System.Address} is a private type, which means -that integer values are not allowed. If the configuration pragma +This configuration pragma is allowed only +if type @code{System.Address} is a private type, +which is true in most versions of GNAT. which means that integer values, +in particular integer literals, are not allowed as address values. +If the configuration pragma @code{Allow_Integer_Address} is given, then integer expressions may be used anywhere a value of type @code{System.Address} is required. The effect is to introduce an implicit unchecked conversion from the Index: gnat_ugn.texi === --- gnat_ugn.texi (revision 206825) +++ gnat_ugn.texi (working copy) @@ -3821,13 +3821,6 @@ manner). This can be useful in some specialized circumstances such as the temporary use of special test software. -@ifclear vms -@item -gnates -@cindex @option{-gnates} (@command{gcc}) -Activates @code{Allow_Integer_Address} mode as though the corresponding -configuration pragma was present. -@end ifclear - @item -gnateS @cindex @option{-gnateS} (@command{gcc}) Synonym of @option{-fdump-scos}, kept for backwards compatibility. Index: opt.ads === --- opt.ads (revision 206825) +++ opt.ads (working copy) @@ -191,9 +191,8 @@ Allow_Integer_Address : Boolean := False; -- GNAT -- Allow use of integer expression in a context requiring System.Address. - -- Set by the use of configuration pragma Allow_Integer_Address, or the - -- compiler switch -gnates. Also set in relaxed semantics mode for use - -- by CodePeer. + -- Set by the use of configuration pragma Allow_Integer_Address Also set + -- in relaxed semantics mode for use by CodePeer or when -gnatd.M is used. All_Sources : Boolean := False; -- GNATBIND Index: sem_prag.adb === --- sem_prag.adb(revision 206825) +++ sem_prag.adb(working copy) @@ -9834,6 +9834,12 @@ when Pragma_Allow_Integer_Address => GNAT_Pragma; Check_Arg_Count (0); + +if not Is_Private_Type (RTE (RE_Address)) then + Error_Pragma + ("pragma% allowed only if Address is a private type"); +end if; + Opt.Allow_Integer_Address := True; -- Index: sem_res.adb
[Ada] 'use all type' syntax error
This patch detects a syntax error when "use all" is not followed by "type". The following test must get an error: gcc -c use_all_type_syntax.adb use_all_type_syntax.ads:3:12: "type" expected package Use_All_Type_Syntax is use all TYP Boolean; -- syntax error end Use_All_Type_Syntax; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Bob Duff * par-ch8.adb (P_Use_Type_Clause): Detect syntax error when "use all" is not followed by "type". Index: par-ch8.adb === --- par-ch8.adb (revision 206804) +++ par-ch8.adb (working copy) @@ -113,7 +113,12 @@ Error_Msg_Ada_2012_Feature ("|`USE ALL TYPE`", Token_Ptr); All_Present := True; Scan; -- past ALL - else + + if Token /= Tok_Type then +Error_Msg_SC ("TYPE expected"); + end if; + + else pragma Assert (Token = Tok_Type); All_Present := False; end if;
[Ada] Fully initialized types
This patch adds an enumeration type and a function to determine the default initialization kind of an arbitrary type. These facilities are intended for formal verification proofs. No applicable test. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * sem_util.adb (Default_Initialization): New routine. * sem_util.ads: Add new type Default_Initialization_Kind. (Default_Initialization): New routine. Index: sem_util.adb === --- sem_util.adb(revision 206825) +++ sem_util.adb(working copy) @@ -3863,6 +3863,138 @@ end if; end Deepest_Type_Access_Level; + + -- Default_Initialization -- + + + function Default_Initialization + (Typ : Entity_Id) return Default_Initialization_Kind + is + Comp : Entity_Id; + Init : Default_Initialization_Kind; + + FDI : Boolean := False; + NDI : Boolean := False; + -- Two flags used to designate whether a record type has at least one + -- fully default initialized component and/or one not fully default + -- initialized component. + + begin + -- Access types are always fully default initialized + + if Is_Access_Type (Typ) then + return Full_Default_Initialization; + + -- An array type subject to aspect/pragma Default_Component_Value is + -- fully default initialized. Otherwise its initialization status is + -- that of its component type. + + elsif Is_Array_Type (Typ) then + if Present (Default_Aspect_Component_Value (Base_Type (Typ))) then +return Full_Default_Initialization; + else +return Default_Initialization (Component_Type (Typ)); + end if; + + -- The initialization status of a private type depends on its full view + + elsif Is_Private_Type (Typ) and then Present (Full_View (Typ)) then + return Default_Initialization (Full_View (Typ)); + + -- Record and protected types offer several initialization options + -- depending on their components (if any). + + elsif Is_Record_Type (Typ) or else Is_Protected_Type (Typ) then + Comp := First_Component (Typ); + + -- Inspect all components + + if Present (Comp) then +while Present (Comp) loop + + -- Do not process internally generated components except for + -- _parent which represents the ancestor portion of a derived + -- type. + + if Comes_From_Source (Comp) + or else Chars (Comp) = Name_uParent + then + Init := Default_Initialization (Base_Type (Etype (Comp))); + + -- A component with mixed initialization renders the whole + -- record/protected type mixed. + + if Init = Mixed_Initialization then + return Mixed_Initialization; + + -- The component is fully default initialized when its type + -- is fully default initialized or when the component has an + -- initialization expression. Note that this has precedence + -- given that the component type may lack initialization. + + elsif Init = Full_Default_Initialization +or else Present (Expression (Parent (Comp))) + then + FDI := True; + + -- Components with no possible initialization are ignored + + elsif Init = No_Possible_Initialization then + null; + + -- The component has no full default initialization + + else + NDI := True; + end if; + end if; + + Next_Component (Comp); +end loop; + +-- Detect a mixed case of initialization + +if FDI and NDI then + return Mixed_Initialization; + +elsif FDI then + return Full_Default_Initialization; + +elsif NDI then + return No_Default_Initialization; + +-- The type either has no components or they are all internally +-- generated. + +else + return No_Possible_Initialization; +end if; + + -- The record type is null, there is nothing to initialize + + else +return No_Possible_Initialization; + end if; + + -- A scalar type subject to aspect/pragma Default_Value is fully default + -- initialized. + + elsif Is_Scalar_Type (Typ) +and then Present (Default_Aspect_Value (Base_Type (Typ))) + then + return Full_Default_Initialization; + + -- Task types are always fully default initialized + + elsif Is_Task_Type (Typ) then
[Ada] Better handling of exponentiation range check
This corrects the problem of failing to set the Do_Range_Check flag for the right operand of integer exponentiation when needed. It supercedes the special check previously made in checks to unconditionally set the flag in gnatprove mode. The flag is now properly set, with proper range analysis, in both gnatprove and ordinary -gnatc modes. The following test, when compiled with -gnatws and either -gnatc or -gnatd.F: 1. procedure ExpRange (B, X : Integer) is 2.Z1,Z2,Z3 : Integer; 3.G : Natural; 4. begin 5.Z1 := B ** X; -- Check needed 6.Z2 := B ** G; -- No check needed 7.Z3 := B ** 4; -- No check needed 8. end ExpRange; Generates a Do_Range_Check on line 5 for X, but no flag is set for line 6 or line 7. If -gnatdt is used to generate a log file, grepping the log file for Do_Range_Check will get a single hit on line 5. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Robert Dewar * checks.adb (Apply_Range_Check): Remove gnatprove special casing of exponentiation. * sem_res.adb (Resolve_Op_Expon): Apply range check to right operand for integer case to check range against Natural. Index: checks.adb === --- checks.adb (revision 206831) +++ checks.adb (working copy) @@ -2797,19 +2797,6 @@ return; end if; - -- Ensure that the exponent is a natural. The flag is set only in formal - -- verification mode as the expander takes care of this check and there - -- is no expansion phase in GNATprove_Mode. - - -- Doesn't seem right to do this unconditionally, we should check the - -- range of the exponent operand. If we do that, it seems like we should - -- then set the flag unconditionally and have the expander check the - -- flag to see whether to generate a check ??? - - if GNATprove_Mode and then Nkind (Expr) = N_Op_Expon then - Set_Do_Range_Check (Right_Opnd (Expr)); - end if; - Is_Unconstrained_Subscr_Ref := Is_Subscr_Ref and then not Is_Constrained (Arr_Typ); Index: sem_res.adb === --- sem_res.adb (revision 206832) +++ sem_res.adb (working copy) @@ -8393,6 +8393,12 @@ Resolve (Left_Opnd (N), B_Typ); Resolve (Right_Opnd (N), Standard_Integer); + -- For integer types, right argument must be in Natural range + + if Is_Integer_Type (Typ) then + Apply_Scalar_Range_Check (Right_Opnd (N), Standard_Natural); + end if; + Check_Unset_Reference (Left_Opnd (N)); Check_Unset_Reference (Right_Opnd (N));
[Ada] Uniform trees for certain aspects and corresponding source pragmas
This patch ensures that the sole argument of pragmas Abstract_State, Contract_Cases, Depends, Global, Initializes, Refined_Depends, Refined_Global and Refined_State is always an aggregate unless it is "null". The end result of this change is a uniform tree in both aspect specifications and pragmas. This change is intended for the formal verification tools. -- Source -- -- uniform_tree.adb procedure Uniform_Tree is G : Integer := 0; procedure Test_01 (X : out Integer) is pragma Global (In_Out => G); begin X := G; end Test_01; procedure Test_02 (X : out Integer) with Global => (In_Out => G) is begin X := G; end Test_02; begin null; end Uniform_Tree; -- Compilation and output -- $ gcc -c -gnatd.V -gnatdg uniform_tree.adb procedure uniform_tree is g : integer := 0; procedure uniform_tree__test_01 (x : out integer) is pragma global (( in_out => g)); begin x := g; return; end uniform_tree__test_01; procedure uniform_tree__test_02 (x : out integer) is pragma global (( in_out => g)); begin x := g; return; end uniform_tree__test_02 with global => ( in_out => g); begin null; return; end uniform_tree; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Hristian Kirtchev * sem_prag.adb (Analyze_Pragma): Ensure that the sole argument of pragmas Abstract_State, Contract_Cases, Depends, Global and Initializes in in aggregate form. (Analyze_Refined_Pragma): Ensure that the sole argument of pragmas Refined_Depends, Refined_Global and Refined_State is in aggregate form. (Ensure_Aggregate_Form): New routine. Index: sem_prag.adb === --- sem_prag.adb(revision 206835) +++ sem_prag.adb(working copy) @@ -1,4 +1,4 @@ -- +-- -- -- -- GNAT COMPILER COMPONENTS -- -- -- @@ -449,39 +449,38 @@ Subp_Id := Defining_Entity (Subp_Decl); All_Cases := Get_Pragma_Arg (First (Pragma_Argument_Associations (N))); - -- Multiple contract cases appear in aggregate form + -- Single and multiple contract cases must appear in aggregate form. If + -- this is not the case, then either the parser of the analysis of the + -- pragma failed to produce an aggregate. - if Nkind (All_Cases) = N_Aggregate then - if No (Component_Associations (All_Cases)) then -Error_Msg_N ("wrong syntax for aspect Contract_Cases", N); + pragma Assert (Nkind (All_Cases) = N_Aggregate); - -- Individual contract cases appear as component associations + if No (Component_Associations (All_Cases)) then + Error_Msg_N ("wrong syntax for aspect Contract_Cases", N); - else --- Ensure that the formal parameters are visible when analyzing --- all clauses. This falls out of the general rule of aspects --- pertaining to subprogram declarations. Skip the installation --- for subprogram bodies because the formals are already visible. + -- Individual contract cases appear as component associations -if not In_Open_Scopes (Subp_Id) then - Restore_Scope := True; - Push_Scope (Subp_Id); - Install_Formals (Subp_Id); -end if; + else + -- Ensure that the formal parameters are visible when analyzing all + -- clauses. This falls out of the general rule of aspects pertaining + -- to subprogram declarations. Skip the installation for subprogram + -- bodies because the formals are already visible. -CCase := First (Component_Associations (All_Cases)); -while Present (CCase) loop - Analyze_Contract_Case (CCase); - Next (CCase); -end loop; + if not In_Open_Scopes (Subp_Id) then +Restore_Scope := True; +Push_Scope (Subp_Id); +Install_Formals (Subp_Id); + end if; -if Restore_Scope then - End_Scope; -end if; + CCase := First (Component_Associations (All_Cases)); + while Present (CCase) loop +Analyze_Contract_Case (CCase); +Next (CCase); + end loop; + + if Restore_Scope then +End_Scope; end if; - - else - Error_Msg_N ("wrong syntax for aspect Contract_Cases", N);
Re: [patch] fix libstdc++/56267 - local iterator requirements
On 17 January 2014 15:11, Jonathan Wakely wrote: > The issue in PR 56267 is that unordered_xxx::local_iterator sometimes > inherits from the user-defined hash function (via _Hash_code_base, > which inherits from the hash function to use the EBO), and > local_iterator must be DefaultConstructible and Assignable, even when > the hash function isn't. > > My solution is to remove the inheritance from _Hash_code_base, and > instead construct/destroy the _Hash_code_base in a block of > uninitialized memory (via __gnu_cxx::__aligned_buffer). This would > mean we can't use the EBO and increase the size of local_iterator, and > past measurements have shown that the unordered containers' > performance is sensitive to such changes, so there's a partial > specialization that doesn't have the __aligned_buffer member for the > case where the _Hash_code_base is empty and needs no storage. > > François, do you have any comments on this? Can you see a better solution? > > While working on this I decided I didn't like everything in > _Local_iterator_base being public, so I added some accessors to the > only members that are needed by unrelated types. Tested x86_64-linux and committed to trunk. 2014-01-20 Jonathan Wakely PR libstdc++/56267 * include/bits/hashtable_policy.h (_Hash_code_base<... false>): Grant friendship to _Local_iterator_base<..., false>. (_Local_iterator_base): Give protected access to all existing members. (_Local_iterator_base::_M_curr()): New public accessor. (_Local_iterator_base::_M_get_bucket()): New public accessor. (_Local_iterator_base<..., false>::_M_init()): New function to manage the lifetime of the _Hash_code_base explicitly. (_Local_iterator_base<..., false>::_M_destroy()): Likewise. (_Local_iterator_base<..., false>): Define copy constructor and copy assignment operator that use new functions to manage _Hash_code_base. (operator==(const _Local_iterator_base&, const _Local_iterator_base&), operator==(const _Local_iterator_base&, const _Local_iterator_base&)): Use public API for _Local_iterator_base. * include/debug/safe_local_iterator.h (_Safe_local_iterator): Likewise. * include/debug/unordered_map (__debug::unordered_map::erase(), __debug::unordered_multimap::erase()): Likewise. * include/debug/unordered_set (__debug::unordered_set::erase(), __debug::unordered_multiset::erase()): Likewise. * testsuite/23_containers/unordered_set/56267-2.cc: New test.
[Ada] Free debug flags used for GNATprove mode
Debug flags used during initial development of GNATprove are now freed, at the exception of -gnatd.F, which stays as a pure debug flag to emulate the behavior of the frontend in GNATprove mode. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Yannick Moy * debug.adb Free debug flags -gnatd.D, -gnatd.G and -gnatd.V * * errout.adb (Compilation_Errors): Remove special handling in GNATprove mode. * gnat1drv.adb (Adjust_Global_Switches): Remove handling of the removed debug flags. * gnat_rm.texi: Initial documentation for Abstract_State, Depends, Global, Initial_Condition, Initializes and Refined_State pragmas and aspects. * opt.ads (Frame_Condition_Mode, Formal_Extensions, SPARK_Strict_Mode): Remove global flags. * sem_ch3.adb (Analyze_Object_Declaration): Check of no hidden state always performed now, on packages declaring a null state. (Signed_Integer_Type_Declaration): Remove ill-designed attempt at providing pedantic mode for bounds of integer types. * sem_ch4.adb (Analyze_Quantified_Expression): Warning on suspicious "some" quantified expression now issued under control of -gnatw.t, like the other warning on unused bound variable. * sem_prag.adb (Check_Precondition_Postcondition): Remove useless test on removed flag. (Analyze_Pragma): Remove tests for SPARK 2014 pragmas, not officially allowed by GNAT. Index: sem_ch3.adb === --- sem_ch3.adb (revision 206822) +++ sem_ch3.adb (working copy) @@ -3911,7 +3911,7 @@ -- Verify whether the object declaration introduces an illegal hidden -- state within a package subject to a null abstract state. - if Formal_Extensions and then Ekind (Id) = E_Variable then + if Ekind (Id) = E_Variable then Check_No_Hidden_State (Id); end if; end Analyze_Object_Declaration; @@ -20444,66 +20444,8 @@ Set_Ekind (T, E_Signed_Integer_Subtype); Set_Etype (T, Implicit_Base); - -- In formal verification mode, restrict the base type's range to the - -- minimum allowed by RM 3.5.4, namely the smallest symmetric range - -- around zero with a possible extra negative value that contains the - -- subtype range. Keep Size, RM_Size and First_Rep_Item info, which - -- should not be relied upon in formal verification. + Set_Scalar_Range (Implicit_Base, Scalar_Range (Base_Typ)); - if SPARK_Strict_Mode then - declare -Sym_Hi_Val : Uint; -Sym_Lo_Val : Uint; -Dloc : constant Source_Ptr := Sloc (Def); -Lbound : Node_Id; -Ubound : Node_Id; -Bounds : Node_Id; - - begin --- If the subtype range is empty, the smallest base type range --- is the symmetric range around zero containing Lo_Val and --- Hi_Val. - -if UI_Gt (Lo_Val, Hi_Val) then - Sym_Hi_Val := UI_Max (UI_Abs (Lo_Val), UI_Abs (Hi_Val)); - Sym_Lo_Val := UI_Negate (Sym_Hi_Val); - - -- Otherwise, if the subtype range is not empty and Hi_Val has - -- the largest absolute value, Hi_Val is non negative and the - -- smallest base type range is the symmetric range around zero - -- containing Hi_Val. - -elsif UI_Le (UI_Abs (Lo_Val), UI_Abs (Hi_Val)) then - Sym_Hi_Val := Hi_Val; - Sym_Lo_Val := UI_Negate (Hi_Val); - - -- Otherwise, the subtype range is not empty, Lo_Val has the - -- strictly largest absolute value, Lo_Val is negative and the - -- smallest base type range is the symmetric range around zero - -- with an extra negative value Lo_Val. - -else - Sym_Lo_Val := Lo_Val; - Sym_Hi_Val := UI_Sub (UI_Negate (Lo_Val), Uint_1); -end if; - -Lbound := Make_Integer_Literal (Dloc, Sym_Lo_Val); -Ubound := Make_Integer_Literal (Dloc, Sym_Hi_Val); -Set_Is_Static_Expression (Lbound); -Set_Is_Static_Expression (Ubound); -Analyze_And_Resolve (Lbound, Any_Integer); -Analyze_And_Resolve (Ubound, Any_Integer); - -Bounds := Make_Range (Dloc, Lbound, Ubound); -Set_Etype (Bounds, Base_Typ); - -Set_Scalar_Range (Implicit_Base, Bounds); - end; - - else - Set_Scalar_Range (Implicit_Base, Scalar_Range (Base_Typ)); - end if; - Set_Size_Info (T,(Implicit_Base)); Set_First_Rep_Item (T, First_Rep_Item (Implicit_Base)); Set_Scalar_Range (T, Def); Index: gnat_rm.texi === --- gnat_rm.tex
[Ada] Missing return statement is illegal in GNATprove mode
This patch makes the missing return statement illegal in GNATprove mode as required by official SPARK 2014 syntax/semantics. The following program is compiled with -gnatd.F 1. package Various is 2.subtype Index_Type is 3. Positive range 1 .. 10; 4.type Integer_Array is 5. array (Index_Type) of Integer; 6.function Search_For_Zero 7. (Values : Integer_Array) return Index_Type; 8. end Various; 1. package body Various is 2.function Search_For_Zero 3. (Values : Integer_Array) return Index_Type 4.is 5.begin 6. for J in Values'Range loop | >>> "return" statement missing following this statement 7. if Values(J) = 0 then 8. return J; 9. end if; 10. end loop; 11.end Search_For_Zero; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Robert Dewar * errout.ads, errout.adb: Implement >? >x? >X? sequences in error messages. * sem_ch6.adb (Check_Statement_Sequence): Missing return is an error in GNATprove mode. Index: errout.adb === --- errout.adb (revision 206837) +++ errout.adb (working copy) @@ -2713,7 +2713,8 @@ P : Natural; -- Current index; procedure Set_Msg_Insertion_Warning; - -- Deal with ? ?? ?x? ?X? insertion sequences + -- Deal with ? ?? ?x? ?X? insertion sequences (also < - -- If tagging of messages is enabled, and this is a warning, - -- then it is treated as being [enabled by default]. + -- Note: the prescan already set Is_Warning_Msg True if and + -- only if Error_Msg_Warn is set to True. If Error_Msg_Warn + -- is False, the call to Set_Msg_Insertion_Warning here does + -- no harm, since Warning_Msg_Char is ignored in that case. - if Error_Msg_Warn - and Warning_Doc_Switch - then - Warning_Msg_Char := '?'; - end if; + Set_Msg_Insertion_Warning; when '|' => null; -- already dealt with Index: errout.ads === --- errout.ads (revision 206809) +++ errout.ads (working copy) @@ -64,7 +64,6 @@ -- are active (see errout.ads for details). If this switch is False, then -- these sequences are ignored (i.e. simply equivalent to a single ?). The -- -gnatw.d switch sets this flag True, -gnatw.D sets this flag False. - -- Note: always ignored in VMS mode where we do not provide this feature. --- -- Suppression of Error Messages -- @@ -305,8 +304,10 @@ --Insertion character < (Less Than: conditional warning message) -- The character < appearing anywhere in a message is used for a -- conditional error message. If Error_Msg_Warn is True, then the - -- effect is the same as ? described above. If Error_Msg_Warn is - -- False, then there is no effect. + -- effect is the same as ? described above, and in particular
Re: Do not produce empty try-finally statements
> >struct A { char buf[64]; }; > >void foo (char *); > >void test () > >{ > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > > { A a; foo (a.buf); a.buf[6] = 1; a.buf[7] = 8; } > >} > >where with your patch we don't DSE the a.buf[6] and a.buf[7] stores > >anymore. I see now. > > > >If optimize_clobbers isn't performed at -O0, perhaps we should consider > >performing at at -O0 (just that and not the other EH optimizations)? > > Or, as clobbers are removed during rtl expansion make sure we remove empty eh > stuff there? Removing all the clutter that empty EH causes is quite a lot of work. In Jakub's testcase we need to output clobber on the non-EH path foo (&a.buf); a.buf[6] = 1; a.buf[7] = 8; a ={v} {CLOBBER}; So I guess we can not modify giplifier to output foo (&a.buf); a.buf[6] = 1; a.buf[7] = 8; a = {CLOBBER}; instead of try { foo (&a.buf); a.buf[6] = 1; a.buf[7] = 8; } finally { a = {CLOBBER}; } Whenever A is just CLOBBER because we care about dead store over the possible EH path? I suppose this may make sense to do so even when this try...finally is toplevel to aid possible inlining. The clobbers on EH are however currently removed by ehcleanup1 that is before we do any DSE and inlining.. Of course I would not like to have empty EH statemetns with all the unwind logic flying trhough the inliner's code estimate logic or I will have to teach it to anticipate their removal. Honza
[Ada] Test SPARK_Mode instead of GNATProve_Mode for warnings
This changes the handling of cases in which warnings are normally given for constructs that are bound to raise run time exceptions if executed. Previously we converted these to errors unconditionally in GNATProve mode, but that caused trouble with non-SPARK code, notably s-scaval from the run-time library. With this patch, we now properly handle the setting of SPARK_Mode in the front end, and these warnings are converted to errors only if we have SPARK_Mode (On), as shown by the following test program: 1. package SPMode is 2.pragma SPARK_Mode (ON); 3.X : Positive := 0; -- ERROR | >>> value not in range of type "Standard.Positive" >>> "Constraint_Error" would have been raised at run time 4.procedure P1; 5.pragma SPARK_Mode (ON); 6.procedure P2; 7.procedure P3; 8. private 9.pragma SPARK_Mode (OFF); 10.X1 : Positive := 0; -- WARNING | >>> warning: value not in range of type "Standard.Positive" >>> warning: "Constraint_Error" will be raised at run time 11. end; 1. package body SPMode is 2.pragma SPARK_Mode (off); 3.Y : Positive := 0; -- WARNING | >>> warning: value not in range of type "Standard.Positive" >>> warning: "Constraint_Error" will be raised at run time 4.procedure P1 is 5. P1P : Positive := 0; -- ERROR | >>> value not in range of type "Standard.Positive" >>> "Constraint_Error" would have been raised at run time 6.begin 7. null; 8.end; 9.procedure P2 is 10. pragma SPARK_Mode (ON); 11. P2P : Positive := 0; -- ERROR | >>> value not in range of type "Standard.Positive" >>> "Constraint_Error" would have been raised at run time 12.begin 13. null; 14.end; 15.procedure P3 is 16. P3P : Positive := 0; -- WARNING | >>> warning: value not in range of type "Standard.Positive" >>> warning: "Constraint_Error" will be raised at run time 17.begin 18. null; 19.end; 20. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-20 Robert Dewar * checks.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * exp_ch4.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * opt.adb (SPARK_Mode_Config): Handled like other config flags * opt.ads (SPARK_Mode_Type): Moved here from types (renamed from SPARK_Mode_Id) (SPARK_Mode_Type): Add pragma Ordered, remove SPARK_ from names (SPARK_Mode): New flag (SPARK_Mode_Config): New flag (Config_Switches_Type): Add SPARK_Mode field * sem.adb: Minor code reorganization (remove unnecessary with) * sem.ads (Scope_Stack_Entry): Add Save_SPARK_Mode field * sem_aggr.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_attr.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_ch3.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_ch4.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Reset SPARK_Mode from spec if needed * sem_ch7.adb (Analyze_Package_Body_Helper): Reset SPARK_Mode from spec if needed * sem_ch8.adb (Push_Scope): Save SPARK_Mode (Pop_Scope): Restore SPARK_Mode * sem_elab.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_prag.adb (Get_SPARK_Mode_From_Pragma): New function (Get_SPARK_Mode_Id): Removed (Get_SPARK_Mode_Type): New name of Get_SPARK_Mode_Id * sem_prag.ads (Get_SPARK_Mode_From_Pragma): New function * sem_res.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * sem_util.adb: Check SPARK_Mode instead of GNATProve_Mode for converting warnings on inevitable exceptions to errors. * types.ads (SPARK_Mode_Id): Moved to opt.ads and renamed SPARK_Mode_Type Index: sem_aggr.adb === --- sem_aggr.adb(revision 206841) +++ sem_aggr.adb(working copy) @@ -597,7 +597,7 @@ elsif Expr_Value (This_Low) /= Expr_Value (Aggr_Low (Dim)) then
Re: Do not produce empty try-finally statements
On Mon, Jan 20, 2014 at 05:07:18PM +0100, Jan Hubicka wrote: > So I guess we can not modify giplifier to output > foo (&a.buf); > a.buf[6] = 1; > a.buf[7] = 8; > a = {CLOBBER}; > > instead of > > try > { > foo (&a.buf); > a.buf[6] = 1; > a.buf[7] = 8; > } > finally > { > a = {CLOBBER}; > } > > Whenever A is just CLOBBER because we care about dead store over the possible > EH path? Yes. Say, this could be surrounded by some try/catch, if we do it the first way, a would be still considered live across the EH path to whatever catches it. The EH optimizations involving cleanups with only clobbers in them are that if at the end of the cleanup after only CLOBBER stmts you would rethrow the exception externally, then the clobber isn't needed and the whole cleanup can be removed. And, if it rethrows somewhere internally, we can move the clobber stmts to the landing pad of wherever it would be caught. Jakub
Re: Do not produce empty try-finally statements
> > Yes. Say, this could be surrounded by some try/catch, if we do it the first > way, a would be still considered live across the EH path to whatever catches > it. > > The EH optimizations involving cleanups with only clobbers in them are that > if at the end of the cleanup after only CLOBBER stmts you would rethrow the > exception > externally, then the clobber isn't needed and the whole cleanup can be > removed. And, if it rethrows somewhere internally, we can move the clobber > stmts to the landing pad of wherever it would be caught. OK, I still do not see how ehclanup1 can then safely remove them pre-inline given that the whole function body can be inlined into another containing the outer EH region. If this is valid, why we can not just eliminate EH in those outer clobber try..finally as part of ehlowering earlier? Honza > > Jakub
Re: [Patch][AArch64] vneg floating point testcase BE fixed
On 17/01/14 14:39, Richard Earnshaw wrote: On 17/01/14 14:22, Alex Velenko wrote: Hi, Here are some more improvements on changelog entry: gcc/testsuite/ 2013-01-16 Alex Velenko * gcc.target/aarch64/vneg_f.c (STORE_INST): New macro. (RUN_TEST): Use new macro. (INDEX64_32): Delete. (INDEX64_64): Likewise. (INDEX128_32): Likewise. (INDEX128_64): Likewise. (INDEX): Likewise. (test_vneg_f32): Use fixed RUN_TEST. (test_vneg_f64): Likewise. (test_vnegq_f32): Likewise. (test_vnegq_f64): Likewise. OK. R. Could someone, please, commit it, as I do not have commit rights Alex
[PATCH, committed] Fix for PR 58996
Hello Everyone, The attached patch will fix the issue pointed out in PR 58996. The main issue was that the runtime was not checking for the availability of pthread affinity before calling its functions. This patch should fix that. Here is the ChangeLog entry: 2014-01-20 Balaji V. Iyer PR other/58996 * configure.ac: Added a check for pthread affinity support. * runtime/os-unix.c: Likewise. * configure: Regenerate. Thanks, Balaji V. Iyer. diff --git a/libcilkrts/configure b/libcilkrts/configure index 91da0a8..63181d7 100644 --- a/libcilkrts/configure +++ b/libcilkrts/configure @@ -14420,6 +14420,38 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# Check for pthread_{,attr_}[sg]etaffinity_np. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _GNU_SOURCE + #include +int +main () +{ +cpu_set_t cpuset; + pthread_attr_t attr; + pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); + if (CPU_ISSET (0, &cpuset)) + CPU_SET (1, &cpuset); + else + CPU_ZERO (&cpuset); + pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); + pthread_attr_init (&attr); + pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); + pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +$as_echo "#define HAVE_PTHREAD_AFFINITY_NP 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext \ +conftest$ac_exeext conftest.$ac_ext + + # Must be last cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac index 30fac99..61b45b0 100644 --- a/libcilkrts/configure.ac +++ b/libcilkrts/configure.ac @@ -164,5 +164,25 @@ AC_SUBST(toolexeclibdir) AC_SUBST(lt_cv_dlopen_libs) +# Check for pthread_{,attr_}[sg]etaffinity_np. +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#define _GNU_SOURCE + #include ], + [cpu_set_t cpuset; + pthread_attr_t attr; + pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); + if (CPU_ISSET (0, &cpuset)) + CPU_SET (1, &cpuset); + else + CPU_ZERO (&cpuset); + pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); + pthread_attr_init (&attr); + pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); + pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])], + AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, +[ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.])) + + # Must be last AC_OUTPUT diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c index dbca21f..fafb91d 100644 --- a/libcilkrts/runtime/os-unix.c +++ b/libcilkrts/runtime/os-unix.c @@ -311,6 +311,10 @@ static pid_t linux_gettid(void) */ static int linux_get_affinity_count (int tid) { +#if !defined HAVE_PTHREAD_AFFINITY_NP + return 0; +#else + cpu_set_t process_mask; // Extract the thread affinity mask @@ -337,6 +341,7 @@ static int linux_get_affinity_count (int tid) } return available_procs; +#endif } #endif
Re: [AArch64] Define BE loader name.
On 6 January 2014 15:36, Marcus Shawcroft wrote: > Hi, > > This patch defines the AArch64 BE loader name. Corresponding patches for > glibc and binutils have been posted on the relevant lists. > > /Marcus > > >* config/aarch64/aarch64-linux.h (GLIBC_DYNAMIC_LINKER): Expand > loader >name using mbig-endian. >(LINUX_TARGET_LINK_SPEC): Pass linker -m flag. This patch has now been committed. The corresponding glibc patch was committed following this email https://sourceware.org/ml/libc-ports/2014-01/msg00036.html /Marcus
Re: [Patch AArch64] Implement Vector Permute Support
On 20/01/14 11:16, Richard Earnshaw wrote: On 20/01/14 11:15, Alex Velenko wrote: On 17/01/14 15:55, Richard Earnshaw wrote: On 16/01/14 14:43, Alex Velenko wrote: On 14/01/14 15:51, pins...@gmail.com wrote: On Jan 14, 2014, at 7:19 AM, Alex Velenko wrote: Hi, This patch turns off the vec_perm patterns for aarch64_be, this should resolve the issue highlighted here http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00321.html With this patch applied, the test case provided in that link compiles without an ICE. However, the Big-Endian port is still in development. This patch exposes another known but unrelated issue with Big-Endian Large-Int modes. The patch has been tested on aarch64-none-elf and aarch64_be-none-elf resulting in five further regression due to the broken implementation of Big-Endian Large-Int modes. Kind regards, Alex Velenko gcc/ 2014-01-14 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. gcc/testsuite/ 2014-01-14 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise. I think you want to use a function to check if the target is effectively big-endian instead. Internally at Cavium, our elf compiler has big-endian multi-lib. Thanks, Andrew Hi, Here is a vec-perm patch with changes proposed previously. Little and Big-Endian tested with no additional issues appearing. Kind regards, Alex gcc/ 2014-01-16 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. * config/aarch64/aarch64.c (aarch64_expand_vec_perm): Add comment. gcc/testsuite/ 2014-01-16 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise. The patch is missing the hunk for aarch64.c. Hi, It is a faulty changelog entry, not patch. Should be: gcc/ 2014-01-16 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. gcc/testsuite/ 2014-01-16 Alex Velenko * lib/target-supports.exp (check_effective_target_vect_perm): Exclude aarch64_be. (check_effective_target_vect_perm_byte): Likewise. (check_effective_target_vect_perm_short): Likewise. On that basis, OK. R. Can someone, please, commit this patch, as I do not have permissions? Kind regards, Alex
Re: [PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)
On Mon, Jan 20, 2014 at 1:12 PM, Uros Bizjak wrote: > On Mon, Jan 20, 2014 at 10:11 AM, Uros Bizjak wrote: > >>> As mentioned in the PR or even in the comment below, ix86_decompose_address >>> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even >>> when the operands aren't of a lea insn, but normal or zero extending mov. >>> >>> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for >>> trunk? >>> >>> 2014-01-20 Jakub Jelinek >>> >>> PR target/59880 >>> * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false >>> if operands[1] is a REG or ZERO_EXTEND of a REG. >>> >>> * gcc.target/i386/pr59880.c: New test. > >> This is OK for mainline, I will take care for a backport (together >> with 59379) to other release branches. > > There are some additional zero-extension insns (SUBREG and AND, all > conveniently detected in SImode_address_operand predicate) that should > be considered here. I am testing following patch: Tested on x86_64-pc-linux-gnu and committed to mainline with following ChangeLog: 2014-01-20 Uros Bizjak * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false for SImode_address_operand operands, having only a REG argument. > Index: config/i386/i386.c > === > --- config/i386/i386.c (revision 206792) > +++ config/i386/i386.c (working copy) > @@ -18160,13 +18160,12 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) > return false; > >/* The "at least two components" test below might not catch simple > - *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is > - non-NULL and parts.disp is const0_rtx as the only components in > - the address, e.g. if the register is %rbp or %r13. As this > - test is much cheaper and moves or zero extensions are the common > - case, do this check first. */ > + move or zero extension insns if parts.base is non-NULL and parts.disp > + is const0_rtx as the only components in the address, e.g. if the > + register is %rbp or %r13. As this test is much cheaper and moves or > + zero extensions are the common case, do this check first. */ >if (REG_P (operands[1]) > - || (GET_CODE (operands[1]) == ZERO_EXTEND > + || (SImode_address_operand (operands[1], VOIDmode) > && REG_P (XEXP (operands[1], 0 > return false; > Uros.
Re: [PATCH][RFC] Fix PR59860
On Mon, Jan 20, 2014 at 03:53:08PM +0100, Richard Biener wrote: > That works for me. Ok, here is what I've committed after bootstrap/regtest on x86_64-linux and i686-linux. 2014-01-20 Jakub Jelinek PR middle-end/59860 * tree.h (fold_builtin_strcat): New prototype. * builtins.c (fold_builtin_strcat): No longer static. Add len argument, if non-NULL, don't call c_strlen. Optimize directly into __builtin_memcpy instead of __builtin_strcpy. (fold_builtin_2): Adjust fold_builtin_strcat caller. * gimple-fold.c (gimple_fold_builtin): Handle BUILT_IN_STRCAT. --- gcc/tree.h.jj 2014-01-20 19:15:58.097104985 +0100 +++ gcc/tree.h 2014-01-20 19:16:29.690942814 +0100 @@ -4527,6 +4527,7 @@ extern tree fold_call_expr (location_t, extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree); extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree); extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree); +extern tree fold_builtin_strcat (location_t, tree, tree, tree); extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree, tree, bool, enum built_in_function); extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, bool, --- gcc/builtins.c.jj 2014-01-20 14:50:23.478809316 +0100 +++ gcc/builtins.c 2014-01-20 19:15:58.100104951 +0100 @@ -191,7 +191,6 @@ static tree fold_builtin_varargs (locati static tree fold_builtin_strpbrk (location_t, tree, tree, tree); static tree fold_builtin_strstr (location_t, tree, tree, tree); static tree fold_builtin_strrchr (location_t, tree, tree, tree); -static tree fold_builtin_strcat (location_t, tree, tree); static tree fold_builtin_strncat (location_t, tree, tree, tree); static tree fold_builtin_strspn (location_t, tree, tree); static tree fold_builtin_strcspn (location_t, tree, tree); @@ -10787,7 +10786,7 @@ fold_builtin_2 (location_t loc, tree fnd return fold_builtin_strstr (loc, arg0, arg1, type); case BUILT_IN_STRCAT: - return fold_builtin_strcat (loc, arg0, arg1); + return fold_builtin_strcat (loc, arg0, arg1, NULL_TREE); case BUILT_IN_STRSPN: return fold_builtin_strspn (loc, arg0, arg1); @@ -11736,8 +11735,9 @@ fold_builtin_strpbrk (location_t loc, tr COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call. */ -static tree -fold_builtin_strcat (location_t loc ATTRIBUTE_UNUSED, tree dst, tree src) +tree +fold_builtin_strcat (location_t loc ATTRIBUTE_UNUSED, tree dst, tree src, +tree len) { if (!validate_arg (dst, POINTER_TYPE) || !validate_arg (src, POINTER_TYPE)) @@ -11755,14 +11755,15 @@ fold_builtin_strcat (location_t loc ATTR /* See if we can store by pieces into (dst + strlen(dst)). */ tree newdst, call; tree strlen_fn = builtin_decl_implicit (BUILT_IN_STRLEN); - tree strcpy_fn = builtin_decl_implicit (BUILT_IN_STRCPY); + tree memcpy_fn = builtin_decl_implicit (BUILT_IN_MEMCPY); - if (!strlen_fn || !strcpy_fn) + if (!strlen_fn || !memcpy_fn) return NULL_TREE; /* If the length of the source string isn't computable don't -split strcat into strlen and strcpy. */ - tree len = c_strlen (src, 1); +split strcat into strlen and memcpy. */ + if (! len) + len = c_strlen (src, 1); if (! len || TREE_SIDE_EFFECTS (len)) return NULL_TREE; @@ -11776,7 +11777,11 @@ fold_builtin_strcat (location_t loc ATTR newdst = fold_build_pointer_plus_loc (loc, dst, newdst); newdst = builtin_save_expr (newdst); - call = build_call_expr_loc (loc, strcpy_fn, 2, newdst, src); + len = fold_convert_loc (loc, size_type_node, len); + len = size_binop_loc (loc, PLUS_EXPR, len, + build_int_cst (size_type_node, 1)); + + call = build_call_expr_loc (loc, memcpy_fn, 3, newdst, src, len); return build2 (COMPOUND_EXPR, TREE_TYPE (dst), call, dst); } return NULL_TREE; --- gcc/gimple-fold.c.jj2014-01-17 21:50:10.950966672 +0100 +++ gcc/gimple-fold.c 2014-01-20 19:15:58.101104941 +0100 @@ -921,6 +921,7 @@ gimple_fold_builtin (gimple stmt) break; case BUILT_IN_STRCPY: case BUILT_IN_STRNCPY: +case BUILT_IN_STRCAT: arg_idx = 1; type = 0; break; @@ -996,6 +997,13 @@ gimple_fold_builtin (gimple stmt) val[1]); break; +case BUILT_IN_STRCAT: + if (val[1] && is_gimple_val (val[1]) && nargs == 2) + result = fold_builtin_strcat (loc, gimple_call_arg (stmt, 0), + gimple_call_arg (stmt, 1), + val[1]); + break; + case BUILT_IN_FPUTS: i
Re: [Patch][AArch64] vneg floating point testcase BE fixed
On 20 January 2014 17:21, Alex Velenko wrote: > Could someone, please, commit it, as I do not have commit rights > > Alex I've committed this for you. /Marcus
Re: [Patch AArch64] Implement Vector Permute Support
On 20 January 2014 17:33, Alex Velenko wrote: > Can someone, please, commit this patch, as I do not have permissions? > Kind regards, > Alex Committed. /Marcus
Re: [build, libgcc] Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR target/59788)
On Mon, Jan 20, 2014 at 4:29 AM, Rainer Orth wrote: > > Given that there were no other comments, I'd like to install the patch > now. Ian, could you please install the ltmain.sh patch in libgo/config, > or should I do so myself? I'll do it. Thanks. Ian
[Patch, fortran] PR59414 [4.8/4.9 Regression] [OOP] ICE in in gfc_conv_expr_descriptor on ALLOCATE inside SELECT TYPE
Dear All, This is a straightforward patch that is completely described in the ChangeLog entry. I am surprised that this could be a 4.8 regression since, as far as I am aware, SELECT_TYPE was not capable of handling array selectors before... Nonetheless, it flagged it up for me :-) Bootstrapped and regtested on FC17/x86_64 - OK for trunk and, after a decent delay, 4.8? Cheers Paul PS I know of at least one other place where this manoeuvre had to be done. If I find a third, I will turn it into a function in class.c. It might be worth doing anyway? 2014-01-20 Paul Thomas PR fortran/59414 * trans-stmt.c (gfc_trans_allocate): Before the pointer assignment to transfer the source _vptr to a class allocate expression, the final class reference should be exposed. The tail that includes the _data and array references is stored. This reduced expression is transferred to 'lhs' and the _vptr added. Then the tail is restored to the allocate expression. 2014-01-20 Paul Thomas PR fortran/59414 * gfortran.dg/allocate_class_3.f90 : New test Index: gcc/fortran/trans-stmt.c === *** gcc/fortran/trans-stmt.c(revision 206747) --- gcc/fortran/trans-stmt.c(working copy) *** gfc_trans_allocate (gfc_code * code) *** 5102,5111 --- 5102,5150 { gfc_expr *lhs, *rhs; gfc_se lse; + gfc_ref *ref, *class_ref, *tail; + + /* Find the last class reference. */ + class_ref = NULL; + for (ref = e->ref; ref; ref = ref->next) + { + if (ref->type == REF_COMPONENT + && ref->u.c.component->ts.type == BT_CLASS) + class_ref = ref; + + if (ref->next == NULL) + break; + } + + /* Remove and store all subsequent references after the +CLASS reference. */ + if (class_ref) + { + tail = class_ref->next; + class_ref->next = NULL; + } + else + { + tail = e->ref; + e->ref = NULL; + } lhs = gfc_expr_to_initialize (e); gfc_add_vptr_component (lhs); + /* Remove the _vptr component and restore the original tail +references. */ + if (class_ref) + { + gfc_free_ref_list (class_ref->next); + class_ref->next = tail; + } + else + { + gfc_free_ref_list (e->ref); + e->ref = tail; + } + if (class_expr != NULL_TREE) { /* Polymorphic SOURCE: VPTR must be determined at run time. */ Index: gcc/testsuite/gfortran.dg/allocate_class_3.f90 === *** gcc/testsuite/gfortran.dg/allocate_class_3.f90 (revision 0) --- gcc/testsuite/gfortran.dg/allocate_class_3.f90 (working copy) *** *** 0 --- 1,107 + ! { dg-do run } + ! Tests the fix for PR59414, comment #3, in which the allocate + ! expressions were not correctly being stripped to provide the + ! vpointer as an lhs to the pointer assignment of the vptr from + ! the SOURCE expression. + ! + ! Contributed by Antony Lewis + ! + module ObjectLists + implicit none + + type :: t + integer :: i + end type + + type Object_array_pointer + class(t), pointer :: p(:) + end type + + contains + + subroutine AddArray1 (P, Pt) + class(t) :: P(:) + class(Object_array_pointer) :: Pt + + select type (Pt) + class is (Object_array_pointer) + if (associated (Pt%P)) deallocate (Pt%P) + allocate(Pt%P(1:SIZE(P)), source=P) + end select + end subroutine + + subroutine AddArray2 (P, Pt) + class(t) :: P(:) + class(Object_array_pointer) :: Pt + + select type (Pt) + type is (Object_array_pointer) + if (associated (Pt%P)) deallocate (Pt%P) + allocate(Pt%P(1:SIZE(P)), source=P) + end select + end subroutine + + subroutine AddArray3 (P, Pt) + class(t) :: P + class(Object_array_pointer) :: Pt + + select type (Pt) + class is (Object_array_pointer) + if (associated (Pt%P)) deallocate (Pt%P) + allocate(Pt%P(1:4), source=P) + end select + end subroutine + + subroutine AddArray4 (P, Pt) + type(t) :: P(:) + class(Object_array_pointer) :: Pt + + select type (Pt) + class is (Object_array_pointer) + if (associated (Pt%P)) deallocate (Pt%P) + allocate(Pt%P(1:SIZE(P)), source=P) + end select + end subroutine + end module + + use ObjectLists + type(Object_array_pointer), pointer :: Pt + class(t), pointer :: P(:) + + allocate (P(2), source = [t(1),t(2)]) + allocate (Pt, source = Object_array_pointer(NULL())) + call AddArray1 (P, Pt) + select type (x => Pt%p) + type is (t) + if (any (x%i .ne. [1,2
[PATCH] Fix PR59890, improve var-tracking compile-time
This improves var-tracking dataflow convergence by using post order on the inverted CFG - which is appropriate for forward dataflow problems. This haves compile-time spent in var-tracking for PR45364 (it also improves other testcases, but that one seems to be the best case). For this to pass bootstrap I had to fix PR59890, two latent bugs with the recently added local_get_addr_cache. Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk? Thanks, Richard. 2014-01-20 Richard Biener PR rtl-optimization/45364 PR rtl-optimization/59890 * var-tracking.c (local_get_addr_clear_given_value): Handle already cleared slot. (val_reset): Handle not allocated local_get_addr_cache. (vt_find_locations): Use post-order on the inverted CFG. Index: gcc/var-tracking.c === *** gcc/var-tracking.c (revision 206808) --- gcc/var-tracking.c (working copy) *** static bool *** 2481,2487 local_get_addr_clear_given_value (const void *v ATTRIBUTE_UNUSED, void **slot, void *x) { ! if (vt_get_canonicalize_base ((rtx)*slot) == x) *slot = NULL; return true; } --- 2481,2488 local_get_addr_clear_given_value (const void *v ATTRIBUTE_UNUSED, void **slot, void *x) { ! if (*slot != NULL ! && vt_get_canonicalize_base ((rtx)*slot) == x) *slot = NULL; return true; } *** val_reset (dataflow_set *set, decl_or_va *** 2501,2507 gcc_assert (var->n_var_parts == 1); ! if (var->onepart == ONEPART_VALUE) { rtx x = dv_as_value (dv); void **slot; --- 2502,2509 gcc_assert (var->n_var_parts == 1); ! if (var->onepart == ONEPART_VALUE ! && local_get_addr_cache != NULL) { rtx x = dv_as_value (dv); void **slot; *** vt_find_locations (void) *** 6934,6945 bool success = true; timevar_push (TV_VAR_TRACKING_DATAFLOW); ! /* Compute reverse completion order of depth first search of the CFG so that the data-flow runs faster. */ ! rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS); bb_order = XNEWVEC (int, last_basic_block_for_fn (cfun)); ! pre_and_rev_post_order_compute (NULL, rc_order, false); ! for (i = 0; i < n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS; i++) bb_order[rc_order[i]] = i; free (rc_order); --- 6936,6947 bool success = true; timevar_push (TV_VAR_TRACKING_DATAFLOW); ! /* Compute reverse top sord order of the inverted CFG so that the data-flow runs faster. */ ! rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); bb_order = XNEWVEC (int, last_basic_block_for_fn (cfun)); ! int num = inverted_post_order_compute (rc_order); ! for (i = 0; i < num; i++) bb_order[rc_order[i]] = i; free (rc_order);
Re: Commit: MSP430: Add -mcpu= option
nick clifton wrote:> >Is the following acceptable ? I even remembered to run it through the >validator... Nice. "command-line option", I think, and I suggest to use ... around the actual options. Gerald
Re: [PATCH] libgcc: use linker script for libgcc_s.so on xtensa
On Sun, Jan 19, 2014 at 1:21 AM, Baruch Siach wrote: > The xtensa port uses __xtensa_libgcc_window_spill in libgcc to implement > __builtin_frame_address. This symbol is local/hidden in libgcc. This is not a > problem when linking against static libgcc. But g++ defaults to > -shared-libgcc, thus breaking link against C++ shared libraries that are using > __builtin_frame_address as follows: This is OK for mainline. I assume your copyright assignment is on file? Thanks!
Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333
> +enum cgraph_inline_failed_flag_t > +{ > + CIF_FINAL_NORMAL = 0, > + CIF_FINAL_ERROR The difference is that some errors will never go away, while others are "temporary" and inliner may revisit them later and inline (such as when indirect call becomes direct). So perhaps CIF_FINAL/CIF_NORMAL? > +}; > + > /* Structure containing additional information about an indirect call. */ > > struct GTY(()) cgraph_indirect_call_info > @@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *); > enum availability cgraph_function_body_availability (struct cgraph_node *); > void cgraph_add_new_function (tree, bool); > const char* cgraph_inline_failed_string (cgraph_inline_failed_t); > +cgraph_inline_failed_flag_t cgraph_inline_failed_flag > (cgraph_inline_failed_t); When you made them enum rather than flags, lets call it cgraph_inline_failed_type OK with these changes, thanks! Honza > > void cgraph_set_nothrow_flag (struct cgraph_node *, bool); > void cgraph_set_const_flag (struct cgraph_node *, bool, bool); > diff --git a/gcc/cif-code.def b/gcc/cif-code.def > index f1df5a0..5591f9a 100644 > --- a/gcc/cif-code.def > +++ b/gcc/cif-code.def > @@ -28,84 +28,98 @@ along with GCC see the file COPYING3. If not see > which is a NULL pointer. */ > > /* Inlining successful. This must be the first code. */ > -DEFCIFCODE(OK , NULL) > +DEFCIFCODE(OK, CIF_FINAL_NORMAL, NULL) > > /* Inlining failed for an unspecified reason. */ > -DEFCIFCODE(UNSPECIFIED , "") > +DEFCIFCODE(UNSPECIFIED, CIF_FINAL_ERROR, "") > > /* Function has not be considered for inlining. This is the code for > functions that have not been rejected for inlining yet. */ > -DEFCIFCODE(FUNCTION_NOT_CONSIDERED, N_("function not considered for > inlining")) > +DEFCIFCODE(FUNCTION_NOT_CONSIDERED, CIF_FINAL_NORMAL, > +N_("function not considered for inlining")) > > /* Caller is compiled with optimizations disabled. */ > -DEFCIFCODE(FUNCTION_NOT_OPTIMIZED, N_("caller is not optimized")) > +DEFCIFCODE(FUNCTION_NOT_OPTIMIZED, CIF_FINAL_NORMAL, > +N_("caller is not optimized")) > > /* Inlining failed owing to unavailable function body. */ > -DEFCIFCODE(BODY_NOT_AVAILABLE, N_("function body not available")) > +DEFCIFCODE(BODY_NOT_AVAILABLE, CIF_FINAL_ERROR, > +N_("function body not available")) > > /* Extern inline function that has been redefined. */ > -DEFCIFCODE(REDEFINED_EXTERN_INLINE, > +DEFCIFCODE(REDEFINED_EXTERN_INLINE, CIF_FINAL_NORMAL, > N_("redefined extern inline functions are not considered for " > "inlining")) > > /* Function is not inlinable. */ > -DEFCIFCODE(FUNCTION_NOT_INLINABLE, N_("function not inlinable")) > +DEFCIFCODE(FUNCTION_NOT_INLINABLE, CIF_FINAL_ERROR, > +N_("function not inlinable")) > > /* Function is overwritable. */ > -DEFCIFCODE(OVERWRITABLE, N_("function body can be overwritten at link time")) > +DEFCIFCODE(OVERWRITABLE, CIF_FINAL_ERROR, > +N_("function body can be overwritten at link time")) > > /* Function is not an inlining candidate. */ > -DEFCIFCODE(FUNCTION_NOT_INLINE_CANDIDATE, N_("function not inline > candidate")) > +DEFCIFCODE(FUNCTION_NOT_INLINE_CANDIDATE, CIF_FINAL_NORMAL, > +N_("function not inline candidate")) > > /* Inlining failed because of various limit parameters. */ > -DEFCIFCODE(LARGE_FUNCTION_GROWTH_LIMIT, > +DEFCIFCODE(LARGE_FUNCTION_GROWTH_LIMIT, CIF_FINAL_NORMAL, > N_("--param large-function-growth limit reached")) > -DEFCIFCODE(LARGE_STACK_FRAME_GROWTH_LIMIT, > +DEFCIFCODE(LARGE_STACK_FRAME_GROWTH_LIMIT, CIF_FINAL_NORMAL, > N_("--param large-stack-frame-growth limit reached")) > -DEFCIFCODE(MAX_INLINE_INSNS_SINGLE_LIMIT, > +DEFCIFCODE(MAX_INLINE_INSNS_SINGLE_LIMIT, CIF_FINAL_NORMAL, > N_("--param max-inline-insns-single limit reached")) > -DEFCIFCODE(MAX_INLINE_INSNS_AUTO_LIMIT, > +DEFCIFCODE(MAX_INLINE_INSNS_AUTO_LIMIT, CIF_FINAL_NORMAL, > N_("--param max-inline-insns-auto limit reached")) > -DEFCIFCODE(INLINE_UNIT_GROWTH_LIMIT, > +DEFCIFCODE(INLINE_UNIT_GROWTH_LIMIT, CIF_FINAL_NORMAL, > N_("--param inline-unit-growth limit reached")) > > /* Recursive inlining. */ > -DEFCIFCODE(RECURSIVE_INLINING, N_("recursive inlining")) > +DEFCIFCODE(RECURSIVE_INLINING, CIF_FINAL_NORMAL, > +N_("recursive inlining")) > > /* Call is unlikely. */ > -DEFCIFCODE(UNLIKELY_CALL, N_("call is unlikely and code size would grow")) > +DEFCIFCODE(UNLIKELY_CALL, CIF_FINAL_NORMAL, > +N_("call is unlikely and code size would grow")) > > /* Function is not declared as inline. */ > -DEFCIFCODE(NOT_DECLARED_INLINED, > +DEFCIFCODE(NOT_DECLARED_INLINED, CIF_FINAL_NORMAL, > N_("function not declared inline and code size would grow")) > > /* Inlining suppressed due to size optimization. */ > -DEFCIFCODE(OPTIMIZING_FOR_SIZE, > +DEFCIFCODE(OPTIMIZING_FOR_SIZE, CIF_FINAL_NORMAL, > N_("optimizing for size and cod
Re: RFA: Fix assembler data directives emitted for variable length structures
> * output.h (output_constant): Update prototype and descriptive > comment. Please watch out for long lines (this one has 92 characters). It turns out that output_constant can be privatized, the last use outside varasm.c in the Java front-end was removed in the course of 4.8.x development. Tested on x86_64-suse-linux, applied on the mainline as obvious. 2014-01-20 Eric Botcazou * output.h (output_constant): Delete. * varasm.c (output_constant): Make private. -- Eric BotcazouIndex: varasm.c === --- varasm.c (revision 206803) +++ varasm.c (working copy) @@ -117,8 +117,8 @@ static int compare_constant (const tree, static tree copy_constant (tree); static void output_constant_def_contents (rtx); static void output_addressed_constants (tree); -static unsigned HOST_WIDE_INT array_size_for_constructor (tree); -static unsigned min_align (unsigned, unsigned); +static unsigned HOST_WIDE_INT output_constant (tree, unsigned HOST_WIDE_INT, + unsigned int); static void globalize_decl (tree); static bool decl_readonly_section_1 (enum section_category); #ifdef BSS_SECTION_ASM_OP @@ -4602,7 +4602,7 @@ static unsigned HOST_WIDE_INT ALIGN is the alignment of the data in bits. */ -unsigned HOST_WIDE_INT +static unsigned HOST_WIDE_INT output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align) { enum tree_code code; Index: output.h === --- output.h (revision 206803) +++ output.h (working copy) @@ -290,18 +290,6 @@ extern void output_object_blocks (void); extern void output_quoted_string (FILE *, const char *); -/* Output assembler code for constant EXP to FILE, with no label. - This includes the pseudo-op such as ".int" or ".byte", and a newline. - Assumes output_addressed_constants has been done on EXP already. - - Generate at least SIZE bytes of assembler data, padding at the end - with zeros if necessary. SIZE must always be specified. The returned - value is the actual number of bytes of assembler data generated, which - may be bigger than SIZE if the object contains a variable length field. - - ALIGN is the alignment in bits that may be assumed for the data. */ -extern unsigned HOST_WIDE_INT output_constant (tree, unsigned HOST_WIDE_INT, unsigned int); - /* When outputting delayed branch sequences, this rtx holds the sequence being output. It is null when no delayed branch sequence is being output, so it can be used as a test in the
Re: [PATCH] Fix PR59890, improve var-tracking compile-time
On Jan 20, 2014, Richard Biener wrote: > local_get_addr_clear_given_value (const void *v ATTRIBUTE_UNUSED, > void **slot, void *x) > { > ! if (*slot != NULL > ! && vt_get_canonicalize_base ((rtx)*slot) == x) > *slot = NULL; > return true; > } This part is ok > *** val_reset (dataflow_set *set, decl_or_va > *** 2501,2507 > gcc_assert (var->n_var_parts == 1); > ! if (var->onepart == ONEPART_VALUE) > { > rtx x = dv_as_value (dv); > void **slot; > --- 2502,2509 > gcc_assert (var->n_var_parts == 1); > ! if (var->onepart == ONEPART_VALUE > ! && local_get_addr_cache != NULL) > { > rtx x = dv_as_value (dv); > void **slot; But I think this one is wrong. You don't want to treat a one-part value as if it wasn't one. If we have to discard locs and equivalences for a one-part value that doesn't have any (because we don't even have a local_get_addr_cache yet), you can *probably* just return right away, because your job is already done. So I'd try: if (var->onepart == ONEPART_VALUE) { if (local_get_addr_cache == NULL) return; > ! /* Compute reverse top sord order of the inverted CFG >so that the data-flow runs faster. */ sord? > ! rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); > bb_order = XNEWVEC (int, last_basic_block_for_fn (cfun)); > ! int num = inverted_post_order_compute (rc_order); > ! for (i = 0; i < num; i++) > bb_order[rc_order[i]] = i; > free (rc_order); This looks reasonable to me, but I'm a bit concerned that changes in the iteration order could break assumptions present in the code. I can't think of anything specific, but I haven't completed swapping this code back in ;-) -- Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Toolchain Engineer
Re: [PATCH] libgcc: use linker script for libgcc_s.so on xtensa
Hi Sterling, Given that you are the maintainer on file and I think you have signed the copyright assignment, you should be able to just take it. AFAIK a copyright assignment is only required for large(r) patches. Thanks, -Chris On 1/20/14, 12:06 PM, Sterling Augustine wrote: On Sun, Jan 19, 2014 at 1:21 AM, Baruch Siach wrote: The xtensa port uses __xtensa_libgcc_window_spill in libgcc to implement __builtin_frame_address. This symbol is local/hidden in libgcc. This is not a problem when linking against static libgcc. But g++ defaults to -shared-libgcc, thus breaking link against C++ shared libraries that are using __builtin_frame_address as follows: This is OK for mainline. I assume your copyright assignment is on file? Thanks!
Re: [PATCH] Fix PR59890, improve var-tracking compile-time
On Mon, Jan 20, 2014 at 06:24:36PM -0200, Alexandre Oliva wrote: > > ! if (var->onepart == ONEPART_VALUE) > > { > > rtx x = dv_as_value (dv); > > void **slot; > > --- 2502,2509 > > > gcc_assert (var->n_var_parts == 1); > > > ! if (var->onepart == ONEPART_VALUE > > ! && local_get_addr_cache != NULL) > > { > > rtx x = dv_as_value (dv); > > void **slot; > > But I think this one is wrong. You don't want to treat a one-part value > as if it wasn't one. If we have to discard locs and equivalences for a > one-part value that doesn't have any (because we don't even have a > local_get_addr_cache yet), you can *probably* just return right away, > because your job is already done. So I'd try: > > if (var->onepart == ONEPART_VALUE) > { > if (local_get_addr_cache == NULL) > return; But when local_get_addr_cache is non-NULL, no matter if we find a slot there or don't, we still fall thru into the 3 loops etc. Jakub
Re: [PATCH] Don't combine across likely spilled hard reg setters (PR rtl-optimization/59477)
> I've just started to work on fixing this in LRA. But I am not going to > work on fixing this in reload. It would be just wasting enormous amount > of time. Yes, fixing it in LRA only would be sufficient for PR rtl-optimization/59477, since it's an x86-specific issue. Other architectures aren't as sensitive as x86 in this area, and the existing counter-measures in combine.c are usually sufficient for them. -- Eric Botcazou
[PATCH] add __attribute__ ((designated_init))
This adds __attribute__((designated_init)) and -Wdesignated-init, a feature from sparse. This is also PR c/59855. The name of the attribute and the option were chosen to be compatible with sparse. I added this warning to -Wall since it seemed like the kind of warning users would ordinarily want -- if they are not using the attribute, they won't ever see it anyhow. I wrote a new test case covering the same cases that the sparse test case covers. I also added tests for applying the attribute to non-struct types; note that in this case sparse issues a warning but gcc issues an error. I think an error is more appropriate. Built and regtested on x86-64 Fedora 20. It's been a while but I think I did it properly. Tom --- gcc/ChangeLog | 7 +++ gcc/c-family/ChangeLog | 7 +++ gcc/c-family/c-common.c | 17 +++ gcc/c-family/c.opt | 4 ++ gcc/c/ChangeLog | 9 gcc/c/c-typeck.c| 12 + gcc/doc/extend.texi | 11 + gcc/doc/invoke.texi | 10 +++- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.dg/Wdesignated-init.c | 82 + 10 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/Wdesignated-init.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 652d2c9..77e4d54 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-01-20 Tom Tromey + + PR c/59855 + * doc/invoke.texi (Warning Options): Document -Wdesignated-init. + * doc/extend.texi (Type Attributes): Document designated_init + attribute. + 2014-01-19 John David Anglin * config/pa/pa.c (pa_attr_length_millicode_call): Correct length of diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index fede01f..7593791 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2014-01-20 Tom Tromey + + PR c/59855 + * c.opt (Wdesignated-init): New option. + * c-common.c (c_common_attribute_table): Add "designated_init". + (handle_designated_init): New function. + 2014-01-15 Laurent Alfonsi PR c++/49718 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 35958ea..e0a0653 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -377,6 +377,7 @@ static tree handle_omp_declare_simd_attribute (tree *, tree, tree, int, bool *); static tree handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *); +static tree handle_designated_init (tree *, tree, tree, int, bool *); static void check_function_nonnull (tree, int, tree *); static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT); @@ -766,6 +767,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_omp_declare_simd_attribute, false }, { "omp declare target", 0, 0, true, false, false, handle_omp_declare_target_attribute, false }, + { "designated_init",0, 0, false, true, false, + handle_designated_init, false }, { NULL, 0, 0, false, false, false, NULL, false } }; @@ -9133,6 +9136,20 @@ handle_returns_nonnull_attribute (tree *node, tree, tree, int, return NULL_TREE; } +/* Handle a "designated_init" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_designated_init (tree *node, tree, tree, int, bool *no_add_attrs) +{ + if (TREE_CODE (*node) != RECORD_TYPE) +{ + error ("designated_init attribute is only valid on struct type"); + *no_add_attrs = true; +} + return NULL_TREE; +} + /* Check for valid arguments being passed to a function with FNTYPE. There are NARGS arguments in the array ARGARRAY. */ diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 38ae58e..29ac4d0 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -355,6 +355,10 @@ Wdeprecated C C++ ObjC ObjC++ Var(warn_deprecated) Init(1) Warning Warn if a deprecated compiler feature, class, method, or field is used +Wdesignated-init +C ObjC Var(warn_designated_init) Init(0) Warning LangEnabledBy(C ObjC,Wall) +Warn about positional initialization of structs requiring designated initializers + Wdiv-by-zero C ObjC C++ ObjC++ Var(warn_div_by_zero) Init(1) Warning Warn about compile-time integer division by zero diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4754bdf..c34fe93 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2014-01-20 Tom Tromey + + * c-typeck.c (struct constructor_stack) : New + field. + (really_start_incremental_init, push_init_level): Initialize + designator_depth. + (pop_init_level): Set global designator_depth. + (pr
Re: [testsuite] Require -ffat-lto-objects for scan-rtl-dump*
On Jan 19, 2014, at 9:13 AM, Richard Sandiford wrote: > We don't compile to RTL or machine instructions for lean LTO objects, > so the scan-assembler tests force -ffat-lto-objects to be used instead. > This patch extends that to scan-rtl-dump*. > > Tested on mips64-linux-gnu, where it fixes an UNRESOLVED on > gcc.target/mips/octeon2-pipe-1.c. OK to install? Ok.
[PATCH, i386]: Fix PR59685, ICE with -march=bdver1 -mavx512f
Hello! Just unhandled V16SFmode in one of the new avx512 patterns. 2014-01-20 Uros Bizjak PR target/59685 * config/i386/sse.md (*andnot3): Handle MODE_V16SF mode attribute in insn output. Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Uros. Index: sse.md === --- sse.md (revision 206844) +++ sse.md (working copy) @@ -8906,6 +8906,8 @@ tmp = "pandn"; break; + case MODE_V16SF: + gcc_assert (TARGET_AVX512F); case MODE_V8SF: gcc_assert (TARGET_AVX); case MODE_V4SF:
Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333
On Mon, Jan 20, 2014 at 12:09 PM, Jan Hubicka wrote: >> +enum cgraph_inline_failed_flag_t >> +{ >> + CIF_FINAL_NORMAL = 0, >> + CIF_FINAL_ERROR > > The difference is that some errors will never go away, while others are > "temporary" > and inliner may revisit them later and inline (such as when indirect call > becomes direct). > So perhaps CIF_FINAL/CIF_NORMAL? >> +}; >> + >> /* Structure containing additional information about an indirect call. */ >> >> struct GTY(()) cgraph_indirect_call_info >> @@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *); >> enum availability cgraph_function_body_availability (struct cgraph_node *); >> void cgraph_add_new_function (tree, bool); >> const char* cgraph_inline_failed_string (cgraph_inline_failed_t); >> +cgraph_inline_failed_flag_t cgraph_inline_failed_flag >> (cgraph_inline_failed_t); > > When you made them enum rather than flags, lets call it > cgraph_inline_failed_type > > OK with these changes, > thanks! > Honza This is the patch I checked in. Thanks. -- H.J. From aa4b937621ab22a176e04e5425c0577555f0578a Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 13 Jan 2014 11:54:36 -0800 Subject: [PATCH] Update error handling during early_inlining --- gcc/ChangeLog | 24 gcc/cgraph.c| 20 +- gcc/cgraph.h| 9 - gcc/cif-code.def| 66 - gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.target/i386/pr59789.c | 22 +++ gcc/tree-inline.c | 3 +- 7 files changed, 120 insertions(+), 29 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr59789.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7815479..1123b6d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2014-01-20 H.J. Lu + + PR middle-end/59789 + * cgraph.c (cgraph_inline_failed_string): Add type to DEFCIFCODE. + (cgraph_inline_failed_type): New function. + * cgraph.h (DEFCIFCODE): Add type. + (cgraph_inline_failed_type_t): New enum. + (cgraph_inline_failed_type): New prototype. + * cif-code.def: Add CIF_FINAL_NORMAL to OK, FUNCTION_NOT_CONSIDERED, + FUNCTION_NOT_OPTIMIZED, REDEFINED_EXTERN_INLINE, + FUNCTION_NOT_INLINE_CANDIDATE, LARGE_FUNCTION_GROWTH_LIMIT, + LARGE_STACK_FRAME_GROWTH_LIMIT, MAX_INLINE_INSNS_SINGLE_LIMIT, + MAX_INLINE_INSNS_AUTO_LIMIT, INLINE_UNIT_GROWTH_LIMIT, + RECURSIVE_INLINING, UNLIKELY_CALL, NOT_DECLARED_INLINED, + OPTIMIZING_FOR_SIZE, ORIGINALLY_INDIRECT_CALL, + INDIRECT_UNKNOWN_CALL, USES_COMDAT_LOCAL. + Add CIF_FINAL_ERROR to UNSPECIFIED, BODY_NOT_AVAILABLE, + FUNCTION_NOT_INLINABLE, OVERWRITABLE, MISMATCHED_ARGUMENTS, + EH_PERSONALITY, NON_CALL_EXCEPTIONS, TARGET_OPTION_MISMATCH, + OPTIMIZATION_MISMATCH. + * tree-inline.c (expand_call_inline): Emit errors during + early_inlining if cgraph_inline_failed_type returns + CIF_FINAL_ERROR. + 2014-01-20 Alex Velenko * config/aarch64/aarch64-simd.md (vec_perm): Add BE check. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 92b31b9..ae1f43c 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1877,7 +1877,7 @@ const char* cgraph_inline_failed_string (cgraph_inline_failed_t reason) { #undef DEFCIFCODE -#define DEFCIFCODE(code, string) string, +#define DEFCIFCODE(code, type, string) string, static const char *cif_string_table[CIF_N_REASONS] = { #include "cif-code.def" @@ -1889,6 +1889,24 @@ cgraph_inline_failed_string (cgraph_inline_failed_t reason) return cif_string_table[reason]; } +/* Return a type describing the failure REASON. */ + +cgraph_inline_failed_type_t +cgraph_inline_failed_type (cgraph_inline_failed_t reason) +{ +#undef DEFCIFCODE +#define DEFCIFCODE(code, type, string) type, + + static cgraph_inline_failed_type_t cif_type_table[CIF_N_REASONS] = { +#include "cif-code.def" + }; + + /* Signedness of an enum type is implementation defined, so cast it + to unsigned before testing. */ + gcc_assert ((unsigned) reason < CIF_N_REASONS); + return cif_type_table[reason]; +} + /* Names used to print out the availability enum. */ const char * const cgraph_availability_names[] = {"unset", "not_available", "overwritable", "available", "local"}; diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 7ce5401..c763516 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -518,13 +518,19 @@ struct varpool_node_set_iterator unsigned index; }; -#define DEFCIFCODE(code, string) CIF_ ## code, +#define DEFCIFCODE(code, type, string) CIF_ ## code, /* Reasons for inlining failures. */ enum cgraph_inline_failed_t { #include "cif-code.def" CIF_N_REASONS }; +enum cgraph_inline_failed_type_t +{ + CIF_FINAL_NORMAL = 0, + CIF_FINAL_ERROR +}; + /* Structure containing additional information about an indirect call. */ struct GTY(()) cgraph_indirect_call_info @@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *); enum availability cgraph_func
Re: [patch] fix libstdc++/56267 - local iterator requirements
On 01/20/2014 04:53 PM, Jonathan Wakely wrote: On 17 January 2014 15:11, Jonathan Wakely wrote: The issue in PR 56267 is that unordered_xxx::local_iterator sometimes inherits from the user-defined hash function (via _Hash_code_base, which inherits from the hash function to use the EBO), and local_iterator must be DefaultConstructible and Assignable, even when the hash function isn't. My solution is to remove the inheritance from _Hash_code_base, and instead construct/destroy the _Hash_code_base in a block of uninitialized memory (via __gnu_cxx::__aligned_buffer). This would mean we can't use the EBO and increase the size of local_iterator, and past measurements have shown that the unordered containers' performance is sensitive to such changes, so there's a partial specialization that doesn't have the __aligned_buffer member for the case where the _Hash_code_base is empty and needs no storage. François, do you have any comments on this? Can you see a better solution? While working on this I decided I didn't like everything in _Local_iterator_base being public, so I added some accessors to the only members that are needed by unrelated types. Tested x86_64-linux and committed to trunk. 2014-01-20 Jonathan Wakely PR libstdc++/56267 * include/bits/hashtable_policy.h (_Hash_code_base<... false>): Grant friendship to _Local_iterator_base<..., false>. (_Local_iterator_base): Give protected access to all existing members. (_Local_iterator_base::_M_curr()): New public accessor. (_Local_iterator_base::_M_get_bucket()): New public accessor. (_Local_iterator_base<..., false>::_M_init()): New function to manage the lifetime of the _Hash_code_base explicitly. (_Local_iterator_base<..., false>::_M_destroy()): Likewise. (_Local_iterator_base<..., false>): Define copy constructor and copy assignment operator that use new functions to manage _Hash_code_base. (operator==(const _Local_iterator_base&, const _Local_iterator_base&), operator==(const _Local_iterator_base&, const _Local_iterator_base&)): Use public API for _Local_iterator_base. * include/debug/safe_local_iterator.h (_Safe_local_iterator): Likewise. * include/debug/unordered_map (__debug::unordered_map::erase(), __debug::unordered_multimap::erase()): Likewise. * include/debug/unordered_set (__debug::unordered_set::erase(), __debug::unordered_multiset::erase()): Likewise. * testsuite/23_containers/unordered_set/56267-2.cc: New test. I considered that it was an acceptable constraint on the hash functor but if it is not Standard compliant then the solution is good and I cannot think about another one. With this new design couldn't we change the conditions that are used to decide when to cache the hash code. I haven't study it in detail but it looks like the default constructible constraint could be removed, no ? François
Re: [PATCH, i386]: Fix PR59685, ICE with -march=bdver1 -mavx512f
On Mon, Jan 20, 2014 at 09:49:16PM +0100, Uros Bizjak wrote: > Hello! > > Just unhandled V16SFmode in one of the new avx512 patterns. > > 2014-01-20 Uros Bizjak > > PR target/59685 > * config/i386/sse.md (*andnot3): Handle MODE_V16SF > mode attribute in insn output. > > Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Shouldn't the testcase be added too? > Index: sse.md > === > --- sse.md (revision 206844) > +++ sse.md (working copy) > @@ -8906,6 +8906,8 @@ >tmp = "pandn"; >break; > > + case MODE_V16SF: > + gcc_assert (TARGET_AVX512F); > case MODE_V8SF: >gcc_assert (TARGET_AVX); > case MODE_V4SF: Jakub
Re: [PATCH, i386]: Fix PR59685, ICE with -march=bdver1 -mavx512f
On Mon, Jan 20, 2014 at 10:14 PM, Jakub Jelinek wrote: >> Just unhandled V16SFmode in one of the new avx512 patterns. >> >> 2014-01-20 Uros Bizjak >> >> PR target/59685 >> * config/i386/sse.md (*andnot3): Handle MODE_V16SF >> mode attribute in insn output. >> >> Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. > > Shouldn't the testcase be added too? The solution is trivial in such way that it has no chance to regress. Uros.
Re: [PATCH] remove some old code from ansidecl.h
> "Tom" == Tom Tromey writes: Tom> This patch removes the last uses of PARAMS from include, and the last Tom> uses of the obsolete VA_* wrapper macros from libiberty. Then, it Tom> removes many obsolete macro definitions from ansidecl.h. Ping. Tom
Re: [PATCH, i386]: Fix PR59685, ICE with -march=bdver1 -mavx512f
On Mon, Jan 20, 2014 at 10:17:35PM +0100, Uros Bizjak wrote: > On Mon, Jan 20, 2014 at 10:14 PM, Jakub Jelinek wrote: > > >> Just unhandled V16SFmode in one of the new avx512 patterns. > >> > >> 2014-01-20 Uros Bizjak > >> > >> PR target/59685 > >> * config/i386/sse.md (*andnot3): Handle MODE_V16SF > >> mode attribute in insn output. > >> > >> Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. > > > > Shouldn't the testcase be added too? > > The solution is trivial in such way that it has no chance to regress. I e.g. wonder why the insn is there also for V[248]DFmode, when it would ICE for those modes for -mavx2 or later (unless single packed modes are optimal). Jakub
Re: Allow passing arrays in registers on AArch64
Richard Earnshaw writes: > On 17/01/14 23:56, Michael Hudson-Doyle wrote: >> Ian Lance Taylor writes: >> >>> On Fri, Jan 17, 2014 at 11:32 AM, Michael Hudson-Doyle >>> wrote: On 18 Jan 2014 07:50, "Yufeng Zhang" wrote: > > Also can you please try to add some new test(s)? It may not be that > straightforward to add non-C/C++ tests, but give it a try. Can you give some hints? Like at least where in the tree such a test would go? I don't know this code at all. >>> >>> There is already a test in libgo, of course. >>> >>> I think it would be pretty hard to write a test that doesn't something >>> like what libgo does. The problem is that GCC is entirely consistent >>> with and without your patch. You could add a Go test that passes an >>> array in gcc/testsuite/go.go-torture/execute/ easily enough, but it >>> would be quite hard to add a test that doesn't pass whether or not >>> your patch is applied. >> >> I think it would have to be a code generation test, i.e. that compiling >> something like >> >> func second(e [2]int64) int64 { >> return e[1] >> } >> >> does not access memory or something along those lines. I'll have a look >> next week. >> >> Cheers, >> mwh >> > > Michael, > > Can you have a look at how the tests in gcc.target/aarch64/aapcs64 work; > it ought to be possible to write a test (though not in C) to catch this. Yeah, I had found those tests. It would be much easier if I could write this in C :-) > The tests work by calling a wrapper function written in assembler -- > that wrapper stores out all the registers used for parameter passing and > then calls back into the test's validator with the register dump > available. Code can then check that values are passed in the places > expected. This gives the compiler the separation between caller and > callee that's needed to test this feature. Right, that much makes sense. I'm not sure I completely understand all the preprocessor trickery involved but the output of it seems clear enough. > My preferred languages for these tests would be (in approximate order) > c, c++, fortran, java, ada, go. That order is based on which languages > are tested most by users. Well of course it cannot be done in C or C++. A commenter on the PR said that while fortran does allow passing arrays by value, it's all handled in the frontend. No idea about Java. Ada has arrays by value but I don't know it even slightly. So it's the last one on your list but here's a diff that adds hack at a test in Go: diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S index 86ce7be..365cd91 100644 --- a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S @@ -1,9 +1,12 @@ .global dumpregs .global myfunc + .global main.myfunc .type dumpregs,%function .type myfunc,%function + .type main.myfunc,%function dumpregs: myfunc: +main.myfunc: mov x16, sp mov x17, sp sub sp, sp, 352 // 336 for registers and 16 for old sp and lr diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.go b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.go new file mode 100644 index 000..b5e90e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.go @@ -0,0 +1,9 @@ +package main + +func myfunc(e [2]int64) + +func main() { + myfunc([2]int64{40, 50}) +} + + diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.sh b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.sh new file mode 100755 index 000..0b3202d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array.sh @@ -0,0 +1,11 @@ +#!/bin/sh +GCC=${GCC:-gcc} +AARCH64HOST=${AARCH64HOST:-localhost} + +set -x + +${GCC}go -g -c test_array.go -o test_array.o +${GCC} -g -c abitest.S -o abitest.o +${GCC} -g -c test_array_c.c -o test_array_c.o +${GCC}go -g abitest.o test_array.o test_array_c.o -o test_array +scp ./test_array ${AARCH64HOST}: && ssh ${AARCH64HOST} ./test_array diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array_c.c b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array_c.c new file mode 100644 index 000..981d12d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/test_array_c.c @@ -0,0 +1,19 @@ +int which_kind_of_test = 0; + +#include "abitest-common.h" + +void +testfunc (char *stack) +{ + { +long __x = 40; +if (memcmp (&__x, stack + X0, sizeof (long)) != 0) + abort (); + } + { +long __x = 50; +if (memcmp (&__x, stack + X1, sizeof (long)) != 0) + abort (); + } + return; +} Obviously it's not integrated into the test framework even slightly but on the good side, it fails without my fix and passes with it... Are you able to do the integration part or provide some hints for me? Cheers, mwh
Re: [PATCH] remove some old code from ansidecl.h
Sorry, did a review, checked the repos, forgot to say OK :-P Ok. intl worried me a bit, but they have duplicates of the macros you're removing.
Re: Allow passing arrays in registers on AArch64
> "Michael" == Michael Hudson-Doyle writes: >> My preferred languages for these tests would be (in approximate order) >> c, c++, fortran, java, ada, go. That order is based on which languages >> are tested most by users. Michael> Well of course it cannot be done in C or C++. A commenter on the PR Michael> said that while fortran does allow passing arrays by value, it's all Michael> handled in the frontend. No idea about Java. You cannot pass arrays by value in Java. In Java an array is a subclass of Object; in gcc internals terms it is just a pointer. Tom
Re: [PATCH] remove some old code from ansidecl.h
> "DJ" == DJ Delorie writes: DJ> Sorry, did a review, checked the repos, forgot to say OK :-P :) DJ> Ok. Thanks. DJ> intl worried me a bit, but they have duplicates of the macros you're DJ> removing. FWIW, in binutils-gdb.git, readline in the same position. Tom
Re: [PATCH, i386]: Fix PR59685, ICE with -march=bdver1 -mavx512f
On Mon, Jan 20, 2014 at 10:37 PM, Jakub Jelinek wrote: >> >> Just unhandled V16SFmode in one of the new avx512 patterns. >> >> >> >> 2014-01-20 Uros Bizjak >> >> >> >> PR target/59685 >> >> * config/i386/sse.md (*andnot3): Handle MODE_V16SF >> >> mode attribute in insn output. >> >> >> >> Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. >> > >> > Shouldn't the testcase be added too? >> >> The solution is trivial in such way that it has no chance to regress. > > I e.g. wonder why the insn is there also for V[248]DFmode, when it would > ICE for those modes for -mavx2 or later (unless single packed modes are > optimal). VI mode iterator does not include vector float modes. Uros.
RE: [PATCH] fix for PR 59825
> -Original Message- > From: Jakub Jelinek [mailto:ja...@redhat.com] > Sent: Wednesday, January 15, 2014 5:55 PM > To: Iyer, Balaji V > Cc: gcc-patches@gcc.gnu.org > Subject: Re: [PATCH] fix for PR 59825 > > On Wed, Jan 15, 2014 at 10:37:04PM +, Iyer, Balaji V wrote: > > Hello Everyone, > > > Attached, please find a patch that will fix PR 59825. The main issue > > was array notations occurring in COMPOUND_EXPR. This patch should fix > > that and fix the rank_mismatch2.c test-case ICE. > > > --- a/gcc/c/c-array-notation.c > > +++ b/gcc/c/c-array-notation.c > > @@ -1289,6 +1289,15 @@ expand_array_notation_exprs (tree t) > > A[x:y]; > > Replace those with just void zero node. */ > >t = void_zero_node; > > + return t; > > +case COMPOUND_EXPR: > > + if (contains_array_notation_expr (t)) > > + if (TREE_CODE (TREE_OPERAND (t, 0)) == SAVE_EXPR) > > + { > > + t = expand_array_notation_exprs (TREE_OPERAND (t, 1)); > > + return t; > > + } > > + /* Else fall through. */ > > default: > >for (int ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (t)); ii++) > > if (contains_array_notation_expr (TREE_OPERAND (t, ii))) > > Why doesn't the default case handle it? Furthermore, you are removing the > COMPOUND_EXPR and the SAVE_EXPR from the first operand of the > COMPOUND_EXPR, that reverts the effects of the fix if there are array > notations anywhere. > > And last comment to the expand_array_notation_exprs, especially the C++ > one, wouldn't it be better to rewrite them as walk_tree/cp_walk_tree > callbacks, so that it really handles all expressions, not just a small subset > of > them? > E.g. in C++ you just don't look at all about OMP_PARALLEL etc., so I'd expect > you ICE if array notation is found inside of #pragma omp parallel body. Hi Jakub, Attached, please find a fixed patch where I rewrote the expand_array_notation_exprs using walk_trees. In this implementation, I am also not reverting the effects of compound or save exprs. Is this OK for trunk? Here are the Changelog entries: +2014-01-20 Balaji V. Iyer + + PR c/59825 + * c-array-notation.c (expand_array_notation_exprs): Rewrote this + function to use walk_tree and moved a lot of its functionality to + expand_array_notations. + (expand_array_notations): New function. + Thanks, Balaji V. Iyer. > > Jakub diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4754bdf..685ff27 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2014-01-20 Balaji V. Iyer + + PR c/59825 + * c-array-notation.c (expand_array_notation_exprs): Rewrote this + function to use walk_tree and moved a lot of its functionality to + expand_array_notations. + (expand_array_notations): New function. + 2014-01-15 Jakub Jelinek PR c/58943 diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c old mode 100644 new mode 100755 index 5526ee9..6099bd7 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -1218,22 +1218,22 @@ fix_return_expr (tree expr) return new_mod_list; } -/* Walks through tree node T and find all the call-statements that do not return - anything and fix up any array notations they may carry. The return value - is the same type as T but with all array notations replaced with appropriate - STATEMENT_LISTS. */ +/* Callback for walk_tree. Expands all array notations in *TP. *WALK_SUBTREES + is set to 1 unless *TP contains no array notation expressions. Parameter + D is unused. */ -tree -expand_array_notation_exprs (tree t) +static tree +expand_array_notations (tree *tp, int *walk_subtrees, void *d ATTRIBUTE_UNUSED) { - if (!contains_array_notation_expr (t)) -return t; + if (!contains_array_notation_expr (*tp)) +{ + *walk_subtrees = 0; + return NULL_TREE; +} + *walk_subtrees = 1; - switch (TREE_CODE (t)) + switch (TREE_CODE (*tp)) { -case BIND_EXPR: - t = expand_array_notation_exprs (BIND_EXPR_BODY (t)); - return t; case TRUTH_ORIF_EXPR: case TRUTH_ANDIF_EXPR: case TRUTH_OR_EXPR: @@ -1241,61 +1241,63 @@ expand_array_notation_exprs (tree t) case TRUTH_XOR_EXPR: case TRUTH_NOT_EXPR: case COND_EXPR: - t = fix_conditional_array_notations (t); - - /* After the expansion if they are still a COND_EXPR, we go into its -subtrees. */ - if (TREE_CODE (t) == COND_EXPR) - { - if (COND_EXPR_THEN (t)) - COND_EXPR_THEN (t) = - expand_array_notation_exprs (COND_EXPR_THEN (t)); - if (COND_EXPR_ELSE (t)) - COND_EXPR_ELSE (t) = - expand_array_notation_exprs (COND_EXPR_ELSE (t)); - } - return t; -case STATEMENT_LIST: - { - tree_stmt_iterator ii_tsi; - for (ii_tsi = tsi_start (t); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi)) - *tsi_stmt_ptr (ii_tsi) = -
[Patch] Fix regex `nosubs` correctly
The semantic of `nosubs` should simply be that `let all parentheses not be a subexpression and do not capture it`. Tested with -m64 and -m32 respectively. Thank you! -- Regards, Tim Shen commit 6972b7eb795adb462182ec96684cc94b7bb8a338 Author: tim Date: Mon Jan 20 17:33:44 2014 -0500 2014-01-19 Tim Shen * include/bits/regex.tcc: Remove incorrect `nosubs` handling. * include/bits/regex_scanner.tcc: Handle `nosubs` correctly. * testsuite/28_regex/constants/syntax_option_type.cc: Add a test case. diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc index 1ceac60..73f55df 100644 --- a/libstdc++-v3/include/bits/regex.tcc +++ b/libstdc++-v3/include/bits/regex.tcc @@ -126,8 +126,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __suf.second = __e; __suf.matched = (__suf.first != __suf.second); } - if (__re.flags() & regex_constants::nosubs) - __res.resize(3); } return __ret; } diff --git a/libstdc++-v3/include/bits/regex_scanner.tcc b/libstdc++-v3/include/bits/regex_scanner.tcc index d954d07..5332d2e 100644 --- a/libstdc++-v3/include/bits/regex_scanner.tcc +++ b/libstdc++-v3/include/bits/regex_scanner.tcc @@ -139,6 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else __throw_regex_error(regex_constants::error_paren); } + else if (_M_flags & regex_constants::nosubs) + _M_token = _S_token_subexpr_no_group_begin; else _M_token = _S_token_subexpr_begin; } diff --git a/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc b/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc index 22559f5..2423775 100644 --- a/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc +++ b/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc @@ -1,5 +1,4 @@ // { dg-options "-std=c++0x" } -// { dg-do compile } // // 2009-06-17 Stephen M. Webb // @@ -23,6 +22,7 @@ // 28.5.1 #include +#include void test01() @@ -82,10 +82,21 @@ test04_constexpr() constexpr auto a3 __attribute__((unused)) = ~grep; } +void +test05() +{ + using namespace std; + using namespace regex_constants; + regex re("((a)(s))", nosubs | ECMAScript); + VERIFY(re.mark_count() == 0); +} + int main() { test01(); test02(); test03(); + test04_constexpr(); + test05(); return 0; }
[libgfortran] Some minor fix-ups committed
I have committed for Dominiq some followup minor cleanup. Index: io/write_float.def === --- io/write_float.def (revision 206864) +++ io/write_float.def (working copy) @@ -373,7 +373,7 @@ updown: rchar = '0'; - if (ft != FMT_F && nbefore == 0 && w > 0 && d == 0 && p == 0) + if (ft != FMT_F && w > 0 && d == 0 && p == 0) nbefore = 1; /* Scan for trailing zeros to see if we really need to round it. */ for(i = nbefore + nafter; i < ndigits; i++) @@ -389,7 +389,7 @@ /* Handle the case Fw.0 and value < 1.0 */ { ndigits = 0; - if (nzero_real == d && digits[0] >= rchar) + if (digits[0] >= rchar) { /* We rounded to zero but shouldn't have */ nbefore = 1; Remove some test code: SendingChangeLog Sendingio/write_float.def Transmitting file data .. Committed revision 206865. Some more test cases: SendingChangeLog Sendinggfortran.dg/round_3.f08 Transmitting file data .. Committed revision 206866. Regards, Jerry
[rl78] verify clobbers
Minor tweak to make sure we don't try to take the REGNO of a MEM. Committed. * config/rl78/rl78.c (rl78_propogate_register_origins): Verify that CLOBBERs are REGs before propogating their values. Index: config/rl78/rl78.c === --- config/rl78/rl78.c (revision 206866) +++ config/rl78/rl78.c (working copy) @@ -3423,13 +3423,14 @@ rl78_propogate_register_origins (void) pat = PATTERN (insn); if (GET_CODE (pat) == PARALLEL) { rtx clobber = XVECEXP (pat, 0, 1); pat = XVECEXP (pat, 0, 0); - if (GET_CODE (clobber) == CLOBBER) + if (GET_CODE (clobber) == CLOBBER + && GET_CODE (XEXP (clobber, 0)) == REG) { int cr = REGNO (XEXP (clobber, 0)); int mb = GET_MODE_SIZE (GET_MODE (XEXP (clobber, 0))); if (dump_file) fprintf (dump_file, "reset origins of %d regs at %d\n", mb, cr); for (i = 0; i < mb; i++) @@ -3566,13 +3567,14 @@ rl78_propogate_register_origins (void) origins[i] = i; age[i] = 0; } } } } - else if (GET_CODE (pat) == CLOBBER) + else if (GET_CODE (pat) == CLOBBER + && GET_CODE (XEXP (pat, 0)) == REG) { if (REG_P (XEXP (pat, 0))) { unsigned int reg = REGNO (XEXP (pat, 0)); origins[reg] = reg;
Re: [PATCH] libgcc: use linker script for libgcc_s.so on xtensa
Hi Sterling, On Mon, Jan 20, 2014 at 12:06:59PM -0800, Sterling Augustine wrote: > On Sun, Jan 19, 2014 at 1:21 AM, Baruch Siach wrote: > > The xtensa port uses __xtensa_libgcc_window_spill in libgcc to implement > > __builtin_frame_address. This symbol is local/hidden in libgcc. This is not > > a > > problem when linking against static libgcc. But g++ defaults to > > -shared-libgcc, thus breaking link against C++ shared libraries that are > > using > > __builtin_frame_address as follows: > > This is OK for mainline. Thanks. This is needed for the 4.7 and 4.8 branches as well. > I assume your copyright assignment is on file? According to https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html, only "legally significant" contributions of more than 15 lines of code "or so" require copyright assignment. baruch -- http://baruch.siach.name/blog/ ~. .~ Tk Open Systems =}ooO--U--Ooo{= - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
Re: [PATCH] libgcc: use linker script for libgcc_s.so on xtensa
On Mon, Jan 20, 2014 at 9:46 PM, Baruch Siach wrote: > Hi Sterling, >> This is OK for mainline. > > Thanks. This is needed for the 4.7 and 4.8 branches as well. > >> I assume your copyright assignment is on file? > > According to > https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html, only > "legally significant" contributions of more than 15 lines of code "or so" > require copyright assignment. Yes, I understand the policy reasonably well. While this particular one is not legally significant, only you know if you intend to submit more significant patches. And therefore if you should get started on the legal side of the equation.
Re: [PATCH] libgcc: use linker script for libgcc_s.so on xtensa
Hi Sterling, On Mon, Jan 20, 2014 at 09:53:36PM -0800, Sterling Augustine wrote: > On Mon, Jan 20, 2014 at 9:46 PM, Baruch Siach wrote: > > According to > > https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html, only > > "legally significant" contributions of more than 15 lines of code "or so" > > require copyright assignment. > > Yes, I understand the policy reasonably well. While this particular > one is not legally significant, only you know if you intend to submit > more significant patches. And therefore if you should get started on > the legal side of the equation. Thanks for the head up. Though I'd really like to make more significant contributions to gcc (and the xtensa port could use some), chances for this actually materializing look slim at the moment. But anyway, I'll keep that in mind going forward. Thanks, baruch -- http://baruch.siach.name/blog/ ~. .~ Tk Open Systems =}ooO--U--Ooo{= - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
Re: [PATCH][RFC] Fix PR59860
On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > Ok, the following simpler patch also fixes the issue and causes > no testsuite fallout - we restrict the folding in builtins.c to > the case with known src strlen. I've noticed this caused FAIL of strlenopt-4.c which had special regexps for s390* vs. other targets because of the HAVE_movstr case. Fixed thusly, committed as obvious to trunk/4.8: 2014-01-21 Jakub Jelinek PR middle-end/59860 * gcc.dg/strlenopt-4.c: Expect the same counts on s390*-* as on all other targets. --- gcc/testsuite/gcc.dg/strlenopt-4.c.jj 2011-10-26 14:19:07.0 +0200 +++ gcc/testsuite/gcc.dg/strlenopt-4.c 2014-01-21 08:17:03.746157021 +0100 @@ -66,16 +66,10 @@ main () return 0; } -/* For targets providing a movstr pattern strcat is already decomposed - into strlen + strcpy by fold_builtin_strcat. */ - -/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" { target { ! s390*-*-* } } } } */ -/* { dg-final { scan-tree-dump-times "strlen \\(" 6 "strlen" { target s390*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" } } */ /* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */ -/* { dg-final { scan-tree-dump-times "strcpy \\(" 3 "strlen" { target { ! s390*-*-* } } } } */ -/* { dg-final { scan-tree-dump-times "strcpy \\(" 6 "strlen" { target s390*-*-* } } } */ -/* { dg-final { scan-tree-dump-times "strcat \\(" 3 "strlen" { target { ! s390*-*-* } } } } */ -/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" { target s390*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 3 "strlen" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 3 "strlen" } } */ /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */ /* { dg-final { cleanup-tree-dump "strlen" } } */ Jakub