Re: [patch, avr] extend part-clobbered check to AVR_TINY architecture
Sorry for delay. (I was at vacation in Kazakhstan without internet.) 2015-05-08 8:32 GMT+03:00 Sivanupandi, Pitchumani : > Ping! > >> -Original Message- >> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- >> ow...@gcc.gnu.org] On Behalf Of Sivanupandi, Pitchumani >> Sent: Tuesday, April 21, 2015 8:21 PM >> To: Georg-Johann Lay; Denis Chertykov >> Cc: GCC Patches >> Subject: [patch, avr] extend part-clobbered check to AVR_TINY architecture >> >> Hi, >> >> When tried backporting AVR_TINY architecture support to 4.9, build failed in >> libgcc for AVR_TINY. >> Failure was due to ICE same as: >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53065 >> >> Fix provided for that bug checks for if the mode crosses the callee saved >> register. >> Below patch updates that check as the AVR_TINY has different set of callee >> saved registers (r18 and r19). >> >> This patch is against trunk. >> >> NOTE: ICE is re-produciable only with 4.9 + tiny patch and --with-dwarf2 >> enabled. >> >> Is this ok for trunk? >> >> diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index >> 68d5ddc..2f441e5 100644 >> --- a/gcc/config/avr/avr.c >> +++ b/gcc/config/avr/avr.c >> @@ -11333,9 +11333,10 @@ avr_hard_regno_call_part_clobbered (unsigned >> regno, machine_mode mode) >> return 0; >> >>/* Return true if any of the following boundaries is crossed: >> - 17/18, 27/28 and 29/30. */ >> + 17/18 or 19/20 (if AVR_TINY), 27/28 and 29/30. */ >> >> - return ((regno < 18 && regno + GET_MODE_SIZE (mode) > 18) >> + return ((regno <= LAST_CALLEE_SAVED_REG && >> + regno + GET_MODE_SIZE (mode) > (LAST_CALLEE_SAVED_REG + 1)) >>|| (regno < REG_Y && regno + GET_MODE_SIZE (mode) > REG_Y) >>|| (regno < REG_Z && regno + GET_MODE_SIZE (mode) > REG_Z)); } >> I think it's ok. Denis.
[patch] conditional lim
[subj corrected] Hi, Andy Thanks for your clarification. Then I'll try to implement some chain of debug statements to make the value computed in the branch available inside the loop. Or may be you have better ideas? Waiting for further comments regarding the whole patch from you, Richard and other developers. Thanks, Evgeniya On Sat, May 9, 2015 at 4:41 PM, Andi Kleen wrote: > Evgeniya Maenkova writes: >> >> So, in my opinion it’s ok to generate additional phi node for debug >> case. But I’m not a compiler expert and maybe there is some >> requirement that debug and non-debug versions should differ only by >> debug statements, I don’t know. > > gcc has such a requirement. > > Otherwise you cannot debug code that was originally not compiled > with debugging. > > -Andi > > -- > a...@linux.intel.com -- Speaking for myself only -- Thanks, Evgeniya perfstories.wordpress.com
Re: [Patch, Fortran, 66035, v1] [5/6 Regression] gfortran ICE segfault
Le 08/05/2015 15:29, Andre Vehreschild a écrit : > Hi all, > > please find attached a patch for 66035. An ICE occurred when in a structure > constructor an allocatable component of type class was initialized with an > existing class object. This was caused by > > - the size of the memory to allocate for the component was miscalculated, > - the vptr was not set correctly, and > - when the class object to be used for init was allocatable already, it was > copied wasting some memory instead of a view_convert inserted. > > All of the above are fixed by the attached patch. > > Bootstraps and regtests ok on x86_64-linux-gnu/f21 for trunk and gcc-5-trunk. > > Ok for trunk and gcc-5-trunk? > > Regards, > Andre > > > pr66035_1.patch > > diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c > index cf607d0..402d9b9 100644 > --- a/gcc/fortran/trans-expr.c > +++ b/gcc/fortran/trans-expr.c > @@ -6881,6 +6881,30 @@ alloc_scalar_allocatable_for_subcomponent_assignment > (stmtblock_t *block, > TREE_TYPE (tmp), tmp, > fold_convert (TREE_TYPE (tmp), size)); > } > + else if (cm->ts.type == BT_CLASS) > +{ > + gcc_assert (expr2->ts.type == BT_CLASS || expr2->ts.type == > BT_DERIVED); > + if (expr2->ts.type == BT_DERIVED) > + { > + tmp = gfc_get_symbol_decl (gfc_find_vtab (&expr2->ts)); > + tmp = gfc_build_addr_expr (NULL_TREE, tmp); > + size = fold_convert (size_type_node, gfc_vptr_size_get (tmp)); > + } Use TYPE_SIZE_UNIT of the rhs in this case, in the same way as in the else branch further below. > + else > + { > + gfc_expr *e2vtab; > + gfc_se se; > + e2vtab = gfc_find_and_cut_at_last_class_ref (expr2); > + gfc_add_vptr_component (e2vtab); > + gfc_add_size_component (e2vtab); > + gfc_init_se (&se, NULL); > + gfc_conv_expr (&se, e2vtab); > + gfc_add_block_to_block (block, &se.pre); > + size = fold_convert (size_type_node, se.expr); > + gfc_free_expr (e2vtab); > + } > + size_in_bytes = size; > +} >else > { >/* Otherwise use the length in bytes of the rhs. */ > @@ -7008,7 +7032,9 @@ gfc_trans_subcomponent_assign (tree dest, gfc_component > * cm, gfc_expr * expr, >gfc_add_expr_to_block (&block, tmp); > } >else if (init && (cm->attr.allocatable > -|| (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable))) > +|| (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable > +&& (expr->ts.type != BT_CLASS > +|| CLASS_DATA (expr)->attr.allocatable maybe: || !CLASS_DATA (expr)->attr.allocatable (with a '!')? Mikael
[PATCH] D demangle: Check identifier length before using strncmp
Noticed this when I was in the middle of testing out some tightening up of parsing checks. Currently when the pointer to the mangled string has reached the end of the buffer, or no longer satisfies any constraints in an abrupt fashion, the parsing logic just exits early in all parsing routines before finally returning success at the top level. This will be followed up with a patch to address this shortly, but until then. This addresses a subtle logic error. --- libiberty/ChangeLog 2015-05-10 Iain Buclaw * d-demangle.c (dlang_identifier): Check encoded length of identifier to verify strncmp matches entire string. * testsuite/d-demangle-expected: Fix wrong test for postblit symbols. --- diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index bb481c0..0d0f9b0 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -622,65 +622,82 @@ dlang_identifier (string *decl, const char *mangled) return NULL; } - if (strncmp (mangled, "__ctor", i) == 0) + switch (i) { - /* Constructor symbol for a class/struct. */ - string_append (decl, "this"); - mangled += i; - return mangled; - } - else if (strncmp (mangled, "__dtor", i) == 0) - { - /* Destructor symbol for a class/struct. */ - string_append (decl, "~this"); - mangled += i; - return mangled; - } - else if (strncmp (mangled, "__postblit", i) == 0) - { - /* Postblit symbol for a struct. */ - string_append (decl, "this(this)"); - mangled += i; - return mangled; - } - else if (strncmp (mangled, "__initZ", i+1) == 0) - { - /* The static initialiser for a given symbol. */ - string_append (decl, "init$"); - mangled += i + 1; - return mangled; - } - else if (strncmp (mangled, "__ClassZ", i+1) == 0) - { - /* The classinfo symbol for a given class. */ - string_prepend (decl, "ClassInfo for "); - string_setlength (decl, string_length (decl) - 1); - mangled += i + 1; - return mangled; - } - else if (strncmp (mangled, "__vtblZ", i+1) == 0) - { - /* The vtable symbol for a given class. */ - string_prepend (decl, "vtable for "); - string_setlength (decl, string_length (decl) - 1); - mangled += i + 1; - return mangled; - } - else if (strncmp (mangled, "__InterfaceZ", i+1) == 0) - { - /* The interface symbol for a given class. */ - string_prepend (decl, "Interface for "); - string_setlength (decl, string_length (decl) - 1); - mangled += i + 1; - return mangled; - } - else if (strncmp (mangled, "__ModuleInfoZ", i+1) == 0) - { - /* The ModuleInfo symbol for a given module. */ - string_prepend (decl, "ModuleInfo for "); - string_setlength (decl, string_length (decl) - 1); - mangled += i + 1; - return mangled; + case 6: + if (strncmp (mangled, "__ctor", i) == 0) + { + /* Constructor symbol for a class/struct. */ + string_append (decl, "this"); + mangled += i; + return mangled; + } + else if (strncmp (mangled, "__dtor", i) == 0) + { + /* Destructor symbol for a class/struct. */ + string_append (decl, "~this"); + mangled += i; + return mangled; + } + else if (strncmp (mangled, "__initZ", i+1) == 0) + { + /* The static initialiser for a given symbol. */ + string_append (decl, "init$"); + mangled += i; + return mangled; + } + else if (strncmp (mangled, "__vtblZ", i+1) == 0) + { + /* The vtable symbol for a given class. */ + string_prepend (decl, "vtable for "); + string_setlength (decl, string_length (decl) - 1); + mangled += i; + return mangled; + } + break; + + case 7: + if (strncmp (mangled, "__ClassZ", i+1) == 0) + { + /* The classinfo symbol for a given class. */ + string_prepend (decl, "ClassInfo for "); + string_setlength (decl, string_length (decl) - 1); + mangled += i; + return mangled; + } + break; + + case 10: + if (strncmp (mangled, "__postblitMFZ", i+3) == 0) + { + /* Postblit symbol for a struct. */ + string_append (decl, "this(this)"); + mangled += i + 3; + return mangled; + } + break; + + case 11: + if (strncmp (mangled, "__InterfaceZ", i+1) == 0) + { + /* The interface symbol for a given class. */ + string_prepend (decl, "Interface for "); + string_setlength (decl, string_length (decl) - 1); + mangled += i; + return mangled; + } + break; + + case 12: + if (strncmp (mangled, "__ModuleInfoZ", i+1) == 0) + { + /* The ModuleInfo symbol for a given module. */ + string_prepend (decl, "ModuleInfo for "); + string_setlength (decl, string_length (decl) - 1); + mangled += i; + return mangled; + } + break; } string_appendn (decl, mangled, i); diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 2aeacb8..330a830 100644 --- a/libiberty/testsuite/d-d
Re: [patch, Fortran] Fix PR 66041
Hello, Le 10/05/2015 00:31, Thomas Koenig a écrit : > Am 09.05.2015 um 13:59 schrieb Mikael Morin: >>> + /* We have to get rid of the shape, if thre is one. Do >>> +so by freeing it and calling gfc_resolve to rebuild it, >>> +if necessary. */ >>> + >>> + if (lbound_e->shape) >>> + gfc_free_shape (&(lbound_e->shape), lbound_e->rank); >>> + >> >>> + lbound_e->rank = ar->dimen; >> ar->dimen is not what you think it is. >> It is 3 for array(1, 1, :), while the rank is 1. > >> gfc_resolve_expr should set the rank for you, so just remove this line. > > It doesn't (for whatever reason), so I kept on setting it. It seems to work here. In fact ar->dimen is the correct setting here, as the array is full. But it will be overwritten (by the same value) in gfc_resolve_expr. Anyway, it doesn't matter. > >>> + >>> + gfc_resolve_expr (lbound_e); >>> + lbound = get_array_inq_function (GFC_ISYM_LBOUND, >>> + lbound_e, i + 1); >> free lbound_e? > > It will be part of the lbound expression, or be simplified away. get_array_inq_function makes a copy, so a _copy_ of lbound_e is in lbound. >>> @@ -2639,6 +2665,8 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, >>> i_index ++; >>> } >>> } >>> + gfc_free_expr (e_in); >>> + >> This side effect is asking for trouble. >> Instead of this, remove the copies made in the callers. >> This is independant from the rest, so it can be made later as a follow-up. > > Done (all in once). > e_in is a copy of ei and is used unmodified as input for the copy to lbound_e, so it can be removed completely. OK with that change. Thanks. Mikael
[PATCH] D demangle: Add support for Nj and Nk symbols in mangled string
The next version of D introduces two new mangle conventions. - Nj to represent methods whose 'this' parameter is also the function return value - Nk to represent a 'ref' parameter that is also the function return value This patch introduces support for these two symbols. --- libiberty/ChangeLog: 2015-05-10 Iain Buclaw * d-demangle.c (dlang_attributes): Handle Nj and ignore Nk symbol in mangled string. Return NULL if have encountered an unknown attribute. (dlang_function_args): Handle Nk symbol in mangled string. * testsuite/d-demangle-expected: Add coverage tests for functions with return parameters and return attributes. --- diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index bb481c0..048218b 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -254,8 +254,10 @@ dlang_attributes (string *decl, const char *mangled) continue; case 'g': case 'h': + case 'k': /* inout parameter is represented as 'Ng'. vector parameter is represented as 'Nh'. + return paramenter is represented as 'Nk'. If we see this, then we know we're really in the parameter list. Rewind and break. */ mangled--; @@ -264,6 +266,13 @@ dlang_attributes (string *decl, const char *mangled) mangled++; string_append (decl, "@nogc "); continue; + case 'j': /* return */ + mangled++; + string_append (decl, "return "); + continue; + + default: /* unknown attribute */ + return NULL; } break; } @@ -353,6 +362,12 @@ dlang_function_args (string *decl, const char *mangled) string_append (decl, "scope "); } + if (mangled[0] == 'N' && mangled[1] == 'k') /* return(T) */ + { + mangled += 2; + string_append (decl, "return "); + } + switch (*mangled) { case 'J': /* out(T) */ diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 2aeacb8..5c4cd75 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -314,6 +314,14 @@ _D8demangle4testFMaZv demangle.test(scope char) # --format=dlang +_D8demangle4testFNjaZv +demangle.test(char) +# +--format=dlang +_D8demangle4testFNkaZv +demangle.test(return char) +# +--format=dlang _D8demangle4testFaXv demangle.test(char...) # @@ -434,6 +442,22 @@ _D8demangle4testFDFNdNfNaZaZv demangle.test(char() @property @safe pure delegate) # --format=dlang +_D8demangle4testFNjDFZaZv +demangle.test(char() delegate) +# +--format=dlang +_D8demangle4testFNkDFZaZv +demangle.test(return char() delegate) +# +--format=dlang +_D8demangle4testFDFNjZaZv +demangle.test(char() return delegate) +# +--format=dlang +_D8demangle4testFNjNkDFNjZaZv +demangle.test(return char() return delegate) +# +--format=dlang _D8demangle4testFFNaZaZv demangle.test(char() pure function) # @@ -474,6 +498,22 @@ _D8demangle4testFFNdNfNaZaZv demangle.test(char() @property @safe pure function) # --format=dlang +_D8demangle4testFNjFZaZv +demangle.test(char() function) +# +--format=dlang +_D8demangle4testFNkFZaZv +demangle.test(return char() function) +# +--format=dlang +_D8demangle4testFFNjZaZv +demangle.test(char() return function) +# +--format=dlang +_D8demangle4testFNjNkFNjZaZv +demangle.test(return char() return function) +# +--format=dlang _D8demangle4test6__initZ demangle.test.init$ #
Re: [Patch, Fortran] Simplify lbound
Le 03/05/2015 22:38, Thomas Koenig a écrit : > Hi Mikael, > > Looks good. > > In general, it is better to restrict changes to existing test cases to > the necessary minimum that they still pass, and add new code to new > test cases. This makes regressions easier to track. > > So, OK with that change. > Here is what I have committed. Mikael Index: testsuite/gfortran.dg/bound_simplification_5.f90 === --- testsuite/gfortran.dg/bound_simplification_5.f90 (révision 0) +++ testsuite/gfortran.dg/bound_simplification_5.f90 (révision 222979) @@ -0,0 +1,75 @@ +! { dg-do run } +! { dg-additional-options "-fcoarray=single -fdump-tree-original" } +! +! Check that {L,U}{,CO}BOUND intrinsics are properly simplified. +! + implicit none + + type :: t +integer :: c + end type t + + type(t) :: d(3:8) = t(7) + type(t) :: e[5:9,-1:*] + type(t) :: h(3), j(4), k(0) + + !Test full arrays vs subarrays + if (lbound(d, 1) /= 3) call abort + if (lbound(d(3:5), 1) /= 1) call abort + if (lbound(d%c,1) /= 1) call abort + if (ubound(d, 1) /= 8) call abort + if (ubound(d(3:5), 1) /= 3) call abort + if (ubound(d%c,1) /= 6) call abort + + if (lcobound(e, 1) /= 5) call abort + if (lcobound(e%c, 1) /= 5) call abort + if (lcobound(e, 2) /= -1) call abort + if (lcobound(e%c, 2) /= -1) call abort + if (ucobound(e, 1) /= 9) call abort + if (ucobound(e%c, 1) /= 9) call abort + ! no simplification for ucobound(e{,%c}, dim=2) + + if (any(lbound(d ) /= [3])) call abort + if (any(lbound(d(3:5)) /= [1])) call abort + if (any(lbound(d%c ) /= [1])) call abort + if (any(ubound(d ) /= [8])) call abort + if (any(ubound(d(3:5)) /= [3])) call abort + if (any(ubound(d%c ) /= [6])) call abort + + if (any(lcobound(e ) /= [5, -1])) call abort + if (any(lcobound(e%c) /= [5, -1])) call abort + ! no simplification for ucobound(e{,%c}) + + call test_empty_arrays(h, j, k) + +contains + subroutine test_empty_arrays(a, c, d) +type(t) :: a(:), c(-3:0), d(3:1) +type(t) :: f(4:2), g(0:6) + +if (lbound(a, 1) /= 1) call abort +if (lbound(c, 1) /= -3) call abort +if (lbound(d, 1) /= 1) call abort +if (lbound(f, 1) /= 1) call abort +if (lbound(g, 1) /= 0) call abort + +if (ubound(c, 1) /= 0) call abort +if (ubound(d, 1) /= 0) call abort +if (ubound(f, 1) /= 0) call abort +if (ubound(g, 1) /= 6) call abort + +if (any(lbound(a) /= [ 1])) call abort +if (any(lbound(c) /= [-3])) call abort +if (any(lbound(d) /= [ 1])) call abort +if (any(lbound(f) /= [ 1])) call abort +if (any(lbound(g) /= [ 0])) call abort + +if (any(ubound(c) /= [0])) call abort +if (any(ubound(d) /= [0])) call abort +if (any(ubound(f) /= [0])) call abort +if (any(ubound(g) /= [6])) call abort + + end subroutine +end +! { dg-final { scan-tree-dump-not "abort" "original" } } +! { dg-final { cleanup-tree-dump "original" } } Index: testsuite/ChangeLog === --- testsuite/ChangeLog (révision 222978) +++ testsuite/ChangeLog (révision 222979) @@ -1,3 +1,7 @@ +2015-05-10 Mikael Morin + + * gfortran.dg/bound_simplification_5.f90: New. + 2015-05-09 Jason Merrill * lib/target-supports.exp (cxx_default): New global. Index: fortran/ChangeLog === --- fortran/ChangeLog (révision 222978) +++ fortran/ChangeLog (révision 222979) @@ -1,3 +1,11 @@ +2015-05-10 Mikael Morin + + * simplify.c (simplify_bound_dim): Don't check for emptyness + in the case of cobound simplification. Factor lower/upper + bound differenciation before the actual simplification. + (simplify_bound): Remove assumed shape specific simplification. + Don't give up early for the lbound of an assumed shape. + 2015-05-09 Mikael Morin PR fortran/65894 Index: fortran/simplify.c === --- fortran/simplify.c (révision 222978) +++ fortran/simplify.c (révision 222979) @@ -3340,29 +3340,43 @@ /* Then, we need to know the extent of the given dimension. */ if (coarray || (ref->u.ar.type == AR_FULL && !ref->next)) { + gfc_expr *declared_bound; + int empty_bound; + bool constant_lbound, constant_ubound; + l = as->lower[d-1]; u = as->upper[d-1]; - if (l->expr_type != EXPR_CONSTANT || u == NULL - || u->expr_type != EXPR_CONSTANT) + gcc_assert (l != NULL); + + constant_lbound = l->expr_type == EXPR_CONSTANT; + constant_ubound = u && u->expr_type == EXPR_CONSTANT; + + empty_bound = upper ? 0 : 1; + declared_bound = upper ? u : l; + + if ((!upper && !constant_lbound) + || (upper && !constant_ubound)) goto returnNull; - if (mpz_cmp (l->value.integer, u->value.integer) > 0) + if (!coarray) { - /* Zero extent. */ - if (upper) -
Extend type verifier to check various uses of TYPE_BINFO and TYPE_VALUES_RAR
Hi, this patch does the heavy lifting to check all overriders of TYPE_VALUES_RAW and TYPE_BINFO. The only bug noticed is that Java builds BINFOs that are not associated with the type. I will fix that incrementally (I am back from China trip so will now push out individual fixes as I canbe around to deal with possible fallout). I also noticed that TYPE_FIELDS and TYPE_VALUES documentation is out of date, will send that separately. This is not complete checking - the more interesting part is to check that the values are sane acorss type variants. Bootstrapped/regtested ppc64-linux, comitted. Honza * tree.c (verify_type): Verify TYPE_BINFO and TYPE_VALUES_RAW. Index: tree.c === --- tree.c (revision 222968) +++ tree.c (working copy) @@ -12623,7 +12623,7 @@ verify_type (const_tree t) { /* FIXME: The following check should pass: useless_type_conversion_p (const_cast (t), TREE_TYPE (TYPE_MIN_VALUE (t)) -bud does not for C sizetypes in LTO. */ +but does not for C sizetypes in LTO. */ } else if (TYPE_MINVAL (t)) { @@ -12669,7 +12669,7 @@ verify_type (const_tree t) { /* FIXME: The following check should pass: useless_type_conversion_p (const_cast (t), TREE_TYPE (TYPE_MAX_VALUE (t)) -bud does not for C sizetypes in LTO. */ +but does not for C sizetypes in LTO. */ } else if (TREE_CODE (t) == ARRAY_TYPE) { @@ -12688,6 +12688,166 @@ verify_type (const_tree t) error_found = true; } + /* Check various uses of TYPE_BINFO. */ + if (RECORD_OR_UNION_TYPE_P (t)) +{ + if (!TYPE_BINFO (t)) + ; + else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO) + { + error ("TYPE_BINFO is not TREE_BINFO"); + debug_tree (TYPE_BINFO (t)); + error_found = true; + } + /* FIXME: Java builds invalid empty binfos that do not have + TREE_TYPE set. */ + else if (TREE_TYPE (TYPE_BINFO (t)) != TYPE_MAIN_VARIANT (t) && 0) + { + error ("TYPE_BINFO type is not TYPE_MAIN_VARIANT"); + debug_tree (TREE_TYPE (TYPE_BINFO (t))); + error_found = true; + } +} + else if (TYPE_LANG_SLOT_1 (t) && in_lto_p) +{ + error ("TYPE_LANG_SLOT_1 (binfo) field is non-NULL"); + debug_tree (TYPE_LANG_SLOT_1 (t)); + error_found = true; +} + + /* Check various uses of TYPE_VALUES_RAW. */ + if (TREE_CODE (t) == ENUMERAL_TYPE) +for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l)) + { + tree value = TREE_VALUE (l); + tree name = TREE_PURPOSE (l); + + /* C FE porduce INTEGER_CST of INTEGER_TYPE, while C++ FE uses + CONST_DECL of ENUMERAL TYPE. */ + if (TREE_CODE (value) != INTEGER_CST && TREE_CODE (value) != CONST_DECL) + { + error ("Enum value is not CONST_DECL or INTEGER_CST"); + debug_tree (value); + debug_tree (name); + error_found = true; + } + if (TREE_CODE (TREE_TYPE (value)) != INTEGER_TYPE + && !useless_type_conversion_p (const_cast (t), TREE_TYPE (value))) + { + error ("Enum value type is not INTEGER_TYPE nor convertible to the enum"); + debug_tree (value); + debug_tree (name); + error_found = true; + } + if (TREE_CODE (name) != IDENTIFIER_NODE) + { + error ("Enum value name is not IDENTIFIER_NODE"); + debug_tree (value); + debug_tree (name); + error_found = true; + } + } + else if (TREE_CODE (t) == ARRAY_TYPE) +{ + if (TYPE_DOMAIN (t) && TREE_CODE (TYPE_DOMAIN (t)) != INTEGER_TYPE) + { + error ("Array TYPE_DOMAIN is not integer type"); + debug_tree (TYPE_DOMAIN (t)); + error_found = true; + } +} + else if (RECORD_OR_UNION_TYPE_P (t)) +for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld)) + { + /* TODO: verify properties of decls. */ + if (TREE_CODE (fld) == FIELD_DECL) + ; + else if (TREE_CODE (fld) == TYPE_DECL) + ; + else if (TREE_CODE (fld) == CONST_DECL) + ; + else if (TREE_CODE (fld) == VAR_DECL) + ; + else if (TREE_CODE (fld) == TEMPLATE_DECL) + ; + else if (TREE_CODE (fld) == USING_DECL) + ; + else + { + error ("Wrong tree in TYPE_FIELDS list"); + debug_tree (fld); + error_found = true; + } + } + else if (TREE_CODE (t) == INTEGER_TYPE + || TREE_CODE (t) == BOOLEAN_TYPE + || TREE_CODE (t) == OFFSET_TYPE + || TREE_CODE (t) == REFERENCE_TYPE + || TREE_CODE (t) == NULLPTR_TYPE + || TREE_CODE (t) == POINTER_TYPE) +{ + if (TYPE_CACHED_VALUES_P (t) != (TYPE_CACHED_VALUES (t) != NULL)) + { + error ("TYPE_CACHED
Re: [RFC][PATCH][X86_64] Eliminate PLT stubs for specified external functions via -fno-plt=
On Sat, May 9, 2015 at 9:34 AM, H.J. Lu wrote: > On Mon, May 4, 2015 at 7:45 AM, Michael Matz wrote: >> Hi, >> >> On Thu, 30 Apr 2015, Sriraman Tallam wrote: >> >>> We noticed that one of our benchmarks sped-up by ~1% when we eliminated >>> PLT stubs for some of the hot external library functions like memcmp, >>> pow. The win was from better icache and itlb performance. The main >>> reason was that the PLT stubs had no spatial locality with the >>> call-sites. I have started looking at ways to tell the compiler to >>> eliminate PLT stubs (in-effect inline them) for specified external >>> functions, for x86_64. I have a proposal and a patch and I would like to >>> hear what you think. >>> >>> This comes with caveats. This cannot be generally done for all >>> functions marked extern as it is impossible for the compiler to say if a >>> function is "truly extern" (defined in a shared library). If a function >>> is not truly extern(ends up defined in the final executable), then >>> calling it indirectly is a performance penalty as it could have been a >>> direct call. >> >> This can be fixed by Alans idea. >> >>> Further, the newly created GOT entries are fixed up at >>> start-up and do not get lazily bound. >> >> And this can be fixed by some enhancements in the linker and dynamic >> linker. The idea is to still generate a PLT stub and make its GOT entry >> point to it initially (like a normal got.plt slot). Then the first >> indirect call will use the address of PLT entry (starting lazy resolution) >> and update the GOT slot with the real address, so further indirect calls >> will directly go to the function. >> >> This requires a new asm marker (and hence new reloc) as normally if >> there's a GOT slot it's filled by the real symbols address, unlike if >> there's only a got.plt slot. E.g. a >> >> call *foo@GOTPLT(%rip) >> >> would generate a GOT slot (and fill its address into above call insn), but >> generate a JUMP_SLOT reloc in the final executable, not a GLOB_DAT one. >> > > I added the "relax" prefix support to x86 assembler on users/hjl/relax > branch > > at > > https://sourceware.org/git/?p=binutils-gdb.git;a=summary > > [hjl@gnu-tools-1 relax-3]$ cat r.S > .text > relax jmp foo > relax call foo > relax jmp foo@plt > relax call foo@plt > [hjl@gnu-tools-1 relax-3]$ ./as -o r.o r.S > [hjl@gnu-tools-1 relax-3]$ ./objdump -drw r.o > > r.o: file format elf64-x86-64 > > > Disassembly of section .text: > > <.text>: >0: 66 e9 00 00 00 00 data16 jmpq 0x6 2: R_X86_64_RELAX_PC32 foo-0x4 >6: 66 e8 00 00 00 00 data16 callq 0xc 8: R_X86_64_RELAX_PC32 foo-0x4 >c: 66 e9 00 00 00 00 data16 jmpq 0x12 e: R_X86_64_RELAX_PLT32foo-0x4 > 12: 66 e8 00 00 00 00 data16 callq 0x18 14: R_X86_64_RELAX_PLT32foo-0x4 > [hjl@gnu-tools-1 relax-3]$ > > Right now, the relax relocations are treated as PC32/PLT32 relocations. > I am working on linker support. > I implemented the linker support for x86-64: : 0: 48 83 ec 08 sub$0x8,%rsp 4: e8 00 00 00 00 callq 9 5: R_X86_64_PC32 plt-0x4 9: e8 00 00 00 00 callq e a: R_X86_64_PLT32 plt-0x4 e: e8 00 00 00 00 callq 13 f: R_X86_64_PC32 bar-0x4 13: 66 e8 00 00 00 00 data16 callq 19 15: R_X86_64_RELAX_PC32 bar-0x4 19: 66 e8 00 00 00 00 data16 callq 1f 1b: R_X86_64_RELAX_PLT32 bar-0x4 1f: 66 e8 00 00 00 00 data16 callq 25 21: R_X86_64_RELAX_PC32 foo-0x4 25: 66 e8 00 00 00 00 data16 callq 2b 27: R_X86_64_RELAX_PLT32 foo-0x4 2b: 31 c0 xor%eax,%eax 2d: 48 83 c4 08 add$0x8,%rsp 31: c3 retq 00400460 : 400460: 48 83 ec 08 sub$0x8,%rsp 400464: e8 d7 ff ff ff callq 400440 400469: e8 d2 ff ff ff callq 400440 40046e: e8 ad ff ff ff callq 400420 400473: ff 15 ff 03 20 00 callq *0x2003ff(%rip)# 600878 <_DYNAMIC+0xf8> 400479: ff 15 f9 03 20 00 callq *0x2003f9(%rip)# 600878 <_DYNAMIC+0xf8> 40047f: 66 e8 f3 00 00 00 data16 callq 400578 400485: 66 e8 ed 00 00 00 data16 callq 400578 40048b: 31 c0 xor%eax,%eax 40048d: 48 83 c4 08 add$0x8,%rsp 400491: c3 retq Sriraman, can you give it a try? -- H.J.
Re: [PATCH 2/4 v2] libcpp: Replace macro usage with C++ constructs)
> On 05/05/2015 12:21 PM, David Malcolm wrote: > >On Mon, 2015-05-04 at 13:15 -0600, Jeff Law wrote: > >On 05/01/2015 06:56 PM, David Malcolm wrote: > >>> > >>>[I didn't mark the inline functions as "static"; should they be?] > Just a follow-up on this. I got burned by the ODR issues around > implicit extern inlines earlier this week. Basically I had two > distinct implementations for an inline function with the same name. > They obviously appeared in different "header files". > > When optimizng, this was fine as they'd actually get inlined and all > was good. Things blew up when the optimizer was off. We got two > functions with the same name, but different implementations. The > linker blindly chose one for me, and in one context it was the wrong > one. > > This led to bootstrap comparison failures. > > So, just be careful :-) Martin actually tried using ICF to warn about such cases at LTO time (if the two COMDAT function bodies does not seem to have same implementation, complain about it). One showstopper here is that early inliner may divere easily (if you provide inline implementation of called function in one unit), but perhaps we could output warnings at least in cases we know that both optimization flags and inline decisions match. (this can be checked during the compare by looking at DECL_INITIAL block structure) In GCC I would really love us to switch to non-static inline and just chase out ODR violations if they exists (hopefully it is not that common). This makes code reuse more explicit to IPA and hopefully will lead to smaller binaries. Honza
[PATCH 0/6] Getting rid of some zero_ext* patterns
This series teaches combine to behave a bit better, and then takes advantage of that in the rs6000 backend. I'll test the combine patches on x86_64-linux before committing, and will wait a bit for comments anyway. Segher gcc/combine.c | 146 +++- gcc/config/rs6000/rs6000.c |4 +- gcc/config/rs6000/rs6000.md | 1606 --- 3 files changed, 281 insertions(+), 1475 deletions(-) -- 1.8.1.4
[PATCH 1/6] combine: undo_to_marker
This generalises undo_all to allow undoing only the last some SUBSTs. This is used by the next patch, but is more generally useful. Comments? Segher 2015-05-10 Segher Boessenkool * combine.c (get_undo_marker): New function. (undo_to_marker): New function, largely factored out from ... (undo_all): ... this. Adjust. --- gcc/combine.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index b806959..1e4d65e 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -4643,15 +4643,25 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, return newi2pat ? i2 : i3; } -/* Undo all the modifications recorded in undobuf. */ +/* Get a marker for undoing to the current state. */ + +static void * +get_undo_marker (void) +{ + return undobuf.undos; +} + +/* Undo the modifications up to the marker. */ static void -undo_all (void) +undo_to_marker (void *marker) { struct undo *undo, *next; - for (undo = undobuf.undos; undo; undo = next) + for (undo = undobuf.undos; undo != marker; undo = next) { + gcc_assert (undo); + next = undo->next; switch (undo->kind) { @@ -4675,7 +4685,15 @@ undo_all (void) undobuf.frees = undo; } - undobuf.undos = 0; + undobuf.undos = (struct undo *) marker; +} + +/* Undo all the modifications recorded in undobuf. */ + +static void +undo_all (void) +{ + undo_to_marker (0); } /* We've committed to accepting the changes we made. Move all -- 1.8.1.4
[PATCH 2/6] combine: If recog fails, try again with zero_ext{ract,end} simplified
Combine has its own ideas of what is "canonical" RTL, forcing all backends to have special patterns in their machine description for the "more simplified" patterns combine often creates, even though the backend already has patterns for a more general form. Backends that do not implement those patterns get less well optimised code. This patch lifts that burden for two cases: combine often converts an AND (with, say, 0xff) to a ZERO_EXTEND of a SUBREG; and an LSHIFTRT followed by an AND to a ZERO_EXTRACT. This is perfectly helpful for e.g. MEMs, but not nice if you have instructions to do more generic masking (like PowerPC rlwinm, and similar on some other archs). With this patch, if recog_for_combine fails, and there are any ZERO_EXT* in the pattern to be matched, it tries again with those expressed as AND etc. If that also fails it rolls back the changes, because it might still match after e.g. splitting, and we want to try the ZERO_EXT* for that as well. Tested on powerpc-linux, before and after removing many patterns from the machine description, and checked that the only changes in the bootstrapped compiler are new and removed functions. I'll also test on x86_64-linux before committing. Segher 2015-05-10 Segher Boessenkool * combine.c (recog_for_combine_1): New function, factored out from recog_for_combine. (change_zero_ext): New function. (recog_for_combine): If recog fails, try again with the pattern modified by change_zero_ext; if that still fails, restore the pattern. --- gcc/combine.c | 120 +++--- 1 file changed, 107 insertions(+), 13 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index 1e4d65e..896d9d2 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -10849,21 +10849,11 @@ simplify_shift_const (rtx x, enum rtx_code code, machine_mode result_mode, } -/* Like recog, but we receive the address of a pointer to a new pattern. - We try to match the rtx that the pointer points to. - If that fails, we may try to modify or replace the pattern, - storing the replacement into the same pointer object. - - Modifications include deletion or addition of CLOBBERs. - - PNOTES is a pointer to a location where any REG_UNUSED notes added for - the CLOBBERs are placed. - - The value is the final insn code from the pattern ultimately matched, - or -1. */ +/* A subroutine of recog_for_combine. See there for arguments and + return value. */ static int -recog_for_combine (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) +recog_for_combine_1 (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) { rtx pat = *pnewpat; rtx pat_without_clobbers; @@ -11010,6 +11000,110 @@ recog_for_combine (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) return insn_code_number; } + +/* Change every ZERO_EXTRACT and ZERO_EXTEND of a SUBREG that can be + expressed as an AND and maybe an LSHIFTRT, to that formulation. + Return whether anything was so changed. */ + +static bool +change_zero_ext (rtx *src) +{ + bool changed = false; + + subrtx_ptr_iterator::array_type array; + FOR_EACH_SUBRTX_PTR (iter, array, src, NONCONST) +{ + rtx x = **iter; + machine_mode mode = GET_MODE (x); + int size; + + if (GET_CODE (x) == ZERO_EXTRACT + && CONST_INT_P (XEXP (x, 1)) + && CONST_INT_P (XEXP (x, 2)) + && GET_MODE (XEXP (x, 0)) == mode) + { + size = INTVAL (XEXP (x, 1)); + + int start = INTVAL (XEXP (x, 2)); + if (BITS_BIG_ENDIAN) + start = GET_MODE_PRECISION (mode) - size - start; + + x = gen_rtx_LSHIFTRT (mode, XEXP (x, 0), GEN_INT (start)); + } + else if (GET_CODE (x) == ZERO_EXTEND + && GET_CODE (XEXP (x, 0)) == SUBREG + && GET_MODE (SUBREG_REG (XEXP (x, 0))) == mode + && subreg_lowpart_p (XEXP (x, 0))) + { + size = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); + x = SUBREG_REG (XEXP (x, 0)); + } + else + continue; + + unsigned HOST_WIDE_INT mask = 1; + mask <<= size; + mask--; + + x = gen_rtx_AND (mode, x, GEN_INT (mask)); + + SUBST (**iter, x); + changed = true; +} + + return changed; +} + +/* Like recog, but we receive the address of a pointer to a new pattern. + We try to match the rtx that the pointer points to. + If that fails, we may try to modify or replace the pattern, + storing the replacement into the same pointer object. + + Modifications include deletion or addition of CLOBBERs. If the + instruction will still not match, we change ZERO_EXTEND and ZERO_EXTRACT + to the equivalent AND and perhaps LSHIFTRT patterns, and try with that + (and undo if that fails). + + PNOTES is a pointer to a location where any REG_UNUSED notes added for + the CLOBBERs are placed. + + The value is the final insn code from the pattern ultimately matched, + or -1. */ +
[PATCH 3/6] rs6000: Don't use zero_extract in the bswap:HI splitter
The next patch removes the zero_extract insn this splits to. Write it as (and (lshiftrt ... instead. Okay for trunk? Segher 2015-05-10 Segher Boessenkool * config/rs6000/rs6000.md (define_split for bswaphi): Don't use zero_extract. --- gcc/config/rs6000/rs6000.md | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index acf890c..4bd16ee 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -2184,17 +2184,15 @@ (define_insn "bswaphi2_internal" [(set_attr "length" "4,4,12") (set_attr "type" "load,store,*")]) -;; We are always BITS_BIG_ENDIAN, so the (const_int 16) below is -;; correct for -mlittle as well as -mbig. (define_split [(set (match_operand:HI 0 "gpc_reg_operand" "") (bswap:HI (match_operand:HI 1 "gpc_reg_operand" ""))) (clobber (match_operand:SI 2 "gpc_reg_operand" ""))] "reload_completed" [(set (match_dup 3) - (zero_extract:SI (match_dup 4) -(const_int 8) -(const_int 16))) + (and:SI (lshiftrt:SI (match_dup 4) +(const_int 8)) + (const_int 255))) (set (match_dup 2) (and:SI (ashift:SI (match_dup 4) (const_int 8)) -- 1.8.1.4
[PATCH 4/6] rs6000: Delete some now-superfluous zero_ext{end,ract} patterns
After the change to combine, we no longer need all the special-case patterns. Tested on powerpc64-linux, as usual. As mentioned with the combine patch, there are no differences to generated code in cc1. This does not delete DImode lshiftrt patterns, because those do not exist (yet). Is this okay for trunk? Segher [ Save the planet! Delete 11% of your machine descriptions! ] 2015-05-10 Segher Boessenkool * config/rs6000/rs6000.md (extzv): FAIL for SImode. (extzvsi_internal, *extzvsi_internal1, *extzvsi_internal2, *rotlsi3_internal7le, *rotlsi3_internal7be, *rotlsi3_internal8le, *rotlsi3_internal8be, *rotlsi3_internal9le, *rotlsi3_internal9be, *rotlsi3_internal10le, *rotlsi3_internal10be, *rotlsi3_internal11le, *rotlsi3_internal11be, *rotlsi3_internal12le, *rotlsi3_internal12be, *lshiftrt_internal1le, *lshiftrt_internal1be, *lshiftrt_internal2le, *lshiftrt_internal2be, *lshiftrt_internal3le, *lshiftrt_internal3be, *lshiftrt_internal4le, *lshiftrt_internal4be, *lshiftrt_internal5le, *lshiftrt_internal5be, *lshiftrt_internal5le, *lshiftrt_internal5be, *rotldi3_internal7le, *rotldi3_internal7be, *rotldi3_internal8le, *rotldi3_internal8be, *rotldi3_internal9le, *rotldi3_internal9be, *rotldi3_internal10le, *rotldi3_internal10be, *rotldi3_internal11le, *rotldi3_internal11be, *rotldi3_internal12le, *rotldi3_internal12be, *rotldi3_internal13le, *rotldi3_internal13be, *rotldi3_internal14le, *rotldi3_internal14be, *rotldi3_internal15le, *rotldi3_internal15be, and 30 corresponding splitters): Delete. --- gcc/config/rs6000/rs6000.md | 1285 +-- 1 file changed, 6 insertions(+), 1279 deletions(-) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 4bd16ee..d3b1a7a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -3604,141 +3604,11 @@ (define_expand "extzv" emit_insn (gen_extzvdi_internal (operands[0], operands[1], operands[2], operands[3])); else -emit_insn (gen_extzvsi_internal (operands[0], operands[1], operands[2], -operands[3])); +FAIL; + DONE; }") -(define_insn "extzvsi_internal" - [(set (match_operand:SI 0 "gpc_reg_operand" "=r") - (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r") -(match_operand:SI 2 "const_int_operand" "i") -(match_operand:SI 3 "const_int_operand" "i")))] - "" - "* -{ - int start = INTVAL (operands[3]) & 31; - int size = INTVAL (operands[2]) & 31; - - if (start + size >= 32) -operands[3] = const0_rtx; - else -operands[3] = GEN_INT (start + size); - return \"rlwinm %0,%1,%3,%s2,31\"; -}" - [(set_attr "type" "shift")]) - -(define_insn "*extzvsi_internal1" - [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y") - (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") -(match_operand:SI 2 "const_int_operand" "i,i") -(match_operand:SI 3 "const_int_operand" "i,i")) - (const_int 0))) - (clobber (match_scratch:SI 4 "=r,r"))] - "" - "* -{ - int start = INTVAL (operands[3]) & 31; - int size = INTVAL (operands[2]) & 31; - - /* Force split for non-cc0 compare. */ - if (which_alternative == 1) - return \"#\"; - - /* If the bit-field being tested fits in the upper or lower half of a - word, it is possible to use andiu. or andil. to test it. This is - useful because the condition register set-use delay is smaller for - andi[ul]. than for rlinm. This doesn't work when the starting bit - position is 0 because the LT and GT bits may be set wrong. */ - - if ((start > 0 && start + size <= 16) || start >= 16) -{ - operands[3] = GEN_INT (((1 << (16 - (start & 15))) - - (1 << (16 - (start & 15) - size; - if (start < 16) - return \"andis. %4,%1,%3\"; - else - return \"andi. %4,%1,%3\"; -} - - if (start + size >= 32) -operands[3] = const0_rtx; - else -operands[3] = GEN_INT (start + size); - return \"rlwinm. %4,%1,%3,%s2,31\"; -}" - [(set_attr "type" "shift") - (set_attr "dot" "yes") - (set_attr "length" "4,8")]) - -(define_split - [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "") - (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "") -(match_operand:SI 2 "const_int_operand" "") -(match_operand:SI 3 "const_int_operand" "")) - (const_int 0))) - (clobber (match_scratch:SI 4 ""))] - "reload_completed" - [(set (match_dup 4) - (zero_extract:SI (match_dup 1) (match_dup 2) -(match_dup 3))) - (set (match_dup 0) - (compare:CC (match_dup 4) - (const_int 0
[PATCH 5/6] rs6000: Don't use gen_rlwinm
The next patch will rename the "rlwinm" pattern (as well as the other patterns that implement rlwinm, now unnamed). The only place that uses gen_rlwinm (an expander) is better off expanding the separate operations separately. Do so. Okay for trunk? Segher 2015-05-10 Segher Boessenkool * config/rs6000/rs6000.md (rs6000_adjust_atomic_subword): Use gen_ashlsi3 and gen_andsi3 instead of gen_rlwinm. --- gcc/config/rs6000/rs6000.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 7c59ac8..e5b8edd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -20577,7 +20577,9 @@ rs6000_adjust_atomic_subword (rtx orig_mem, rtx *pshift, rtx *pmask) /* Shift amount for subword relative to aligned word. */ shift = gen_reg_rtx (SImode); addr = gen_lowpart (SImode, addr); - emit_insn (gen_rlwinm (shift, addr, GEN_INT (3), GEN_INT (shift_mask))); + rtx tmp = gen_reg_rtx (SImode); + emit_insn (gen_ashlsi3 (tmp, addr, GEN_INT (3))); + emit_insn (gen_andsi3 (shift, tmp, GEN_INT (shift_mask))); if (BYTES_BIG_ENDIAN) shift = expand_simple_binop (SImode, XOR, shift, GEN_INT (shift_mask), shift, 1, OPTAB_LIB_WIDEN); -- 1.8.1.4
[PATCH 6/6] rs6000: Clean up the various rlwinm patterns
Some cleanups: * Give every define_insn a name; * Add missing conditions for some of the dot forms; * Use define_insn_and_split to reduce duplication; * Renumber operands so 0,1,2,3 are the actual operands of the machine instruction, in order; * Reformat some patterns. Is this okay for trunk? Segher 2015-05-10 Segher Boessenkool * config/rs6000/rs6000.md (*rotlsi3_internal4, *rotlsi3_internal5, *rotlsi3_internal6, rlwinm, 5 unnamed define_insns, and 6 define_splits): Delete. (*rotlsi3_mask, *rotlsi3_mask_dot, *rotlsi3_mask_dot2, *ashlsi3_imm_mask, *ashlsi3_imm_mask_dot, *ashlsi3_imm_mask_dot2, *lshrsi3_imm_mask, *lshrsi3_imm_mask_dot, *lshrsi3_imm_mask_dot2): New. --- gcc/config/rs6000/rs6000.md | 243 +++- 1 file changed, 105 insertions(+), 138 deletions(-) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index d3b1a7a..1fcd69e 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -3745,7 +3745,7 @@ (define_insn_and_split "*rotl3_dot2" (set_attr "length" "4,8")]) -(define_insn "*rotlsi3_internal4" +(define_insn "*rotlsi3_mask" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "reg_or_cint_operand" "rn")) @@ -3755,75 +3755,62 @@ (define_insn "*rotlsi3_internal4" [(set_attr "type" "shift") (set_attr "maybe_var_shift" "yes")]) -(define_insn "*rotlsi3_internal5" - [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y") - (compare:CC (and:SI -(rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") - (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) -(match_operand:SI 3 "mask_operand" "n,n")) - (const_int 0))) - (clobber (match_scratch:SI 4 "=r,r"))] - "" +(define_insn_and_split "*rotlsi3_mask_dot" + [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y") + (compare:CC +(and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") + (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) +(match_operand:SI 3 "mask_operand" "n,n")) +(const_int 0))) + (clobber (match_scratch:SI 0 "=r,r"))] + "rs6000_gen_cell_microcode + && (TARGET_32BIT || UINTVAL (operands[3]) <= 0x7fff)" "@ - rlw%I2nm. %4,%1,%h2,%m3,%M3 + rlw%I2nm. %0,%1,%h2,%m3,%M3 #" + "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)" + [(set (match_dup 0) + (and:SI (rotate:SI (match_dup 1) + (match_dup 2)) + (match_dup 3))) + (set (match_dup 4) + (compare:CC (match_dup 0) + (const_int 0)))] + "" [(set_attr "type" "shift") (set_attr "maybe_var_shift" "yes") (set_attr "dot" "yes") (set_attr "length" "4,8")]) -(define_split - [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "") - (compare:CC (and:SI -(rotate:SI (match_operand:SI 1 "gpc_reg_operand" "") - (match_operand:SI 2 "reg_or_cint_operand" "")) -(match_operand:SI 3 "mask_operand" "")) - (const_int 0))) - (clobber (match_scratch:SI 4 ""))] - "reload_completed" - [(set (match_dup 4) - (and:SI (rotate:SI (match_dup 1) - (match_dup 2)) -(match_dup 3))) - (set (match_dup 0) - (compare:CC (match_dup 4) - (const_int 0)))] - "") - -(define_insn "*rotlsi3_internal6" +(define_insn_and_split "*rotlsi3_mask_dot2" [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y") - (compare:CC (and:SI -(rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") - (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) -(match_operand:SI 3 "mask_operand" "n,n")) - (const_int 0))) + (compare:CC +(and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") + (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) +(match_operand:SI 3 "mask_operand" "n,n")) +(const_int 0))) (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") - (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))] - "" + (and:SI (rotate:SI (match_dup 1) + (match_dup 2)) + (match_dup 3)))] + "rs6000_gen_cell_microcode + && (TARGET_32BIT || UINTVAL (operands[3]) <= 0x7fff)" "@ rlw%I2nm. %0,%1,%h2,%m3,%M3 #" - [(set_attr "type" "shift") - (set_attr "maybe_var_shift" "yes") - (set_attr "dot" "yes") - (set_attr "length" "4,8")]) - -(define_split - [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "") - (compare:CC (and:SI -(rotate:SI (match_operan
Re: [PATCH i386] PR65753: allow PIC tail calls via function pointers
> In the i386 backend, tailcalls are incorrectly disallowed in PIC mode for > calls via function pointers on the basis that indirect calls, like direct > calls, would go via PLT and thus require %ebx to point to GOT -- but that is > not true. Quoting Rich Felker who reported the bug, > > "For PLT slots in the non-PIE main executable, %ebx is not required at all. > PLT slots in PIE or shared libraries need %ebx, but a function pointer can > never evaluate to such a PLT slot; it always evaluates to the nominal > address > of the function which is the same in all DSOs and therefore fundamentally > cannot depend on the address of the GOT in the calling DSO" > > As far as I can see it's simply a mistake that was there from day 1 (comment 4 > in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65753 points to original > patch). > > Bootstrapped and regtested on 32-bit x86, OK for trunk? > (the comment before the condition will need to be adjusted too, i.e. > s/optimize any indirect call, or a direct call/optimize any direct call/ ) > > PR target/65753 > * config/i386/i386.c (ix86_function_ok_for_sibcall): Allow PIC sibcalls > via function pointers. > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index 3263656..f29e053 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -5448,13 +5448,13 @@ ix86_function_ok_for_sibcall (tree decl, tree exp) >/* If we are generating position-independent code, we cannot sibcall > optimize any indirect call, or a direct call to a global function, > as the PLT requires %ebx be live. (Darwin does not have a PLT.) */ >if (!TARGET_MACHO >&& !TARGET_64BIT >&& flag_pic > - && (!decl || !targetm.binds_local_p (decl))) > + && (decl && !targetm.binds_local_p (decl))) You probably need to update comment here. I wonder what happens when we optimize indirect call to direct call to global function at RTL level? I suppose we are safe here, because at RTL level we explicitly represent if we refer to PLT entry or the functionaddress itself and we never optimize one to the other? Patch is OK if you make sure that this works and update the comment. Honza > return false; > >/* If we need to align the outgoing stack, then sibcalling would > unalign the stack, which may break the called function. */ >if (ix86_minimum_incoming_stack_boundary (true) >< PREFERRED_STACK_BOUNDARY)
Re: [PATCH i386] Move CLOBBERED_REGS earlier in register class list
> On 32-bit x86, register class CLOBBERED_REGS is a proper subset of > LEGACY_REGS, which causes IRA not to consider it separately for register > allocation, even when it has lower cost than other classes. This patch is > useful to fix code generation problem that appears with no-PLT PIC tailcalls. > > Was there a specific reason for CLOBBERED_REGS class to be listed as late as > it is? On 32-bit this class contains only EAX, ECX, EDX. Uros moved CLOBBERED_REGS late in https://gcc.gnu.org/ml/gcc-patches/2012-08/msg00796.html which contains a rationale, too. I am adding Uros and Vladimir to CC just in case they missed the email :) Honza > > OK? > * config/i386/i386.h (enum reg_class): Move CLOBBERED_REGS before > Q_REGS. > (REG_CLASS_NAMES): Ditto. > (REG_CLASS_CONTENTS): Ditto. >
Re: [PATCH i386] Extend sibcall peepholes to allow source in %eax
> On i386, peepholes that transform memory load and register-indirect jump into > memory-indirect jump are overly restrictive in that they don't allow combining > when the jump target is loaded into %eax, and the called function returns a > value (also in %eax, so it's not dead after the call). Fix this by checking > for same source and output register operands separately. > > OK? > * config/i386/i386.md (sibcall_value_memory): Extend peepholes to > allow memory address in %eax. > (sibcall_value_pop_memory): Likewise. Why do we need the check for liveness after all? There is SIBLING_CALL_P (peep2_next_insn (1)) so we know that the function terminates by the call and there are no other uses of the value. Don't we however need to check that operands[0] is not used by the call_insn as parameter of the call? I.e. something like void test(void (*callback ())) { callback(callback); } I think instead of peep2_reg_dead_p we want to check that the parameter is not in CALL_INSN_FUNCTION_USAGE of the sibcall.. Honza > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > index 729db75..7f81bcc 100644 > --- a/gcc/config/i386/i386.md > +++ b/gcc/config/i386/i386.md > @@ -11872,13 +11872,14 @@ >[(set (match_operand:W 0 "register_operand") > (match_operand:W 1 "memory_operand")) > (set (match_operand 2) > (call (mem:QI (match_dup 0)) >(match_operand 3)))] >"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1)) > - && peep2_reg_dead_p (2, operands[0])" > + && (REGNO (operands[2]) == REGNO (operands[0]) > + || peep2_reg_dead_p (2, operands[0]))" >[(parallel [(set (match_dup 2) > (call (mem:QI (match_dup 1)) >(match_dup 3))) > (unspec [(const_int 0)] UNSPEC_PEEPSIB)])]) > > (define_peephole2 > @@ -11886,13 +11887,14 @@ > (match_operand:W 1 "memory_operand")) > (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE) > (set (match_operand 2) > (call (mem:QI (match_dup 0)) > (match_operand 3)))] >"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2)) > - && peep2_reg_dead_p (3, operands[0])" > + && (REGNO (operands[2]) == REGNO (operands[0]) > + || peep2_reg_dead_p (3, operands[0]))" >[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE) > (parallel [(set (match_dup 2) > (call (mem:QI (match_dup 1)) >(match_dup 3))) > (unspec [(const_int 0)] UNSPEC_PEEPSIB)])]) > > @@ -11951,13 +11953,14 @@ > (call (mem:QI (match_dup 0)) >(match_operand 3))) > (set (reg:SI SP_REG) > (plus:SI (reg:SI SP_REG) > (match_operand:SI 4 "immediate_operand")))])] >"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (1)) > - && peep2_reg_dead_p (2, operands[0])" > + && (REGNO (operands[2]) == REGNO (operands[0]) > + || peep2_reg_dead_p (2, operands[0]))" >[(parallel [(set (match_dup 2) > (call (mem:QI (match_dup 1)) >(match_dup 3))) > (set (reg:SI SP_REG) > (plus:SI (reg:SI SP_REG) > (match_dup 4))) > @@ -11971,13 +11974,14 @@ > (call (mem:QI (match_dup 0)) >(match_operand 3))) > (set (reg:SI SP_REG) > (plus:SI (reg:SI SP_REG) > (match_operand:SI 4 "immediate_operand")))])] >"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (2)) > - && peep2_reg_dead_p (3, operands[0])" > + && (REGNO (operands[2]) == REGNO (operands[0]) > + || peep2_reg_dead_p (3, operands[0]))" >[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE) > (parallel [(set (match_dup 2) > (call (mem:QI (match_dup 1)) >(match_dup 3))) > (set (reg:SI SP_REG) > (plus:SI (reg:SI SP_REG)
Re: [PATCH] Expand PIC calls without PLT with -fno-plt
> This patch introduces option -fno-plt that allows to expand calls that would > go via PLT to load the address of the function immediately at call site (which > introduces a GOT load). Cover letter explains the motivation for this patch. > > New option documentation for invoke.texi is missing from the patch; if this is > accepted I'll be happy to send a v2 with documentation added. > > * calls.c (prepare_call_address): Transform PLT call to GOT lookup and > indirect call by forcing address into a pseudo with -fno-plt. > * common.opt (flag_plt): New option. > > diff --git a/gcc/common.opt b/gcc/common.opt > index b49ac46..cd8b256 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1773,12 +1773,16 @@ Common Report Var(flag_pic,1) Negative(fpie) > Generate position-independent code if possible (small mode) > > fpie > Common Report Var(flag_pie,1) Negative(fPIC) > Generate position-independent code for executables if possible (small mode) > > +fplt > +Common Report Var(flag_plt) Init(1) > +Use PLT for PIC calls (-fno-plt: load the address from GOT at call site) > + This won't play well with LTO since fplt will become another global flag while it affects codegen. I still did not catch up with the other thread and Hj's work on doing this transparently in linker, but if this is getting in, please add Optimization to fplt, so the PLT usage can be decided with per function granuality. Honza
Re: [PATCH] Expand PIC calls without PLT with -fno-plt
> On Mon, May 04, 2015 at 11:42:20AM -0600, Jeff Law wrote: > > On 05/04/2015 11:39 AM, Jakub Jelinek wrote: > > >On Mon, May 04, 2015 at 11:34:05AM -0600, Jeff Law wrote: > > >>On 05/04/2015 10:37 AM, Alexander Monakov wrote: > > >>>This patch introduces option -fno-plt that allows to expand calls that > > >>>would > > >>>go via PLT to load the address of the function immediately at call site > > >>>(which > > >>>introduces a GOT load). Cover letter explains the motivation for this > > >>>patch. > > >>> > > >>>New option documentation for invoke.texi is missing from the patch; if > > >>>this is > > >>>accepted I'll be happy to send a v2 with documentation added. > > >>> > > >>> * calls.c (prepare_call_address): Transform PLT call to GOT lookup and > > >>> indirect call by forcing address into a pseudo with -fno-plt. > > >>> * common.opt (flag_plt): New option. > > >>OK once you cobble together the invoke.texi changes. > > > > > >Isn't what Michael/Alan suggested better? I mean as/ld/compiler changes to > > >inline the plt slot's first part, then lazy binding will work fine. > > I must have missed Alan/Michael's message. > > > > ISTM the win here is that by going through the GOT, you can CSE the > > GOT reference and possibly get some more register allocation > > freedom. Is that still the case with Alan/Michael's approach? > > There are many advantages to 'going through the GOT'. CSE'ing the > reference is just one. The biggest (IMO) is that you can avoid the bad > PLT ABI that most targets have, where making a call to a PLT slot > requires the GOT address to be pre-loaded into a fixed, call-saved > register. This precludes sibcalls and forces many functions which > otherwise would not need their own stack frames to create one for > saving the old value of the GOT register. See my blog entry on the > topic here: http://ewontfix.com/18/ One common pattern I noticed while looking at codegen for speculative devirtualization is that in case we do not inline the virtual call we end up with if (ptr = &foo) foo() which leads to both GOT lookup to figure out address of foo and call across PLT. It would be nice to handle this gratefully. Note that one of improvements I want to do to devirt machinery is to change the code seuqence to: if (vptr == &expected_vtable) foo () else vptr[token](); To saven the vtable lookup. But this is not possible in all cases - it happens that there are multiple predicted vtables all agreeeing on the partiuclar slot. Honza > > Anyone who really wants lazy binding can use -fplt (which is > presumably still the default; I didn't check) but lazy binding should > largely be considered deprecated anyway since effective use of relro > protection requires -z now too, in which case you're paying all the > costs (which are considerable!) for lazy binding support even though > you won't get it. > > Rich
[C frontend] Fix construction of TYPE_STUB_DECL
Hi, TREE_PUBLIC of TYPE_DECL is defined to say if the type is public: /* In a VAR_DECL, FUNCTION_DECL, NAMESPACE_DECL or TYPE_DECL, nonzero means name is to be accessible from outside this translation unit. In an IDENTIFIER_NODE, nonzero means an external declaration accessible from outside this translation unit was previously seen for this name in an inner scope. */ #define TREE_PUBLIC(NODE) ((NODE)->base.public_flag) This is properly honored by C++ FE but other FEs are bit random, which in turn confuses type_in_anonymous_namespace_p predicate that leads to flase poistives on type mismatch warnings. I used to be able to get around by checking only C++ types at LTO time, but with type checking in lto-symtab I can not, because I do want to compare type compatibility cross translation units and cross languages and we have no reliable way to say what type originated as C++ and what did not. This fixed TYPE_STUB_DECl construction in C frontend. I will check other FEs separately. I can also add way to recognize C++ types, but I think it is good idea to make type representation consistent across FEs. Bootstrapped/regtested x86_64-linux, OK? Honza * c-decl.c (pushtag): Declare type as public. Index: c/c-decl.c === --- c/c-decl.c (revision 222981) +++ c/c-decl.c (working copy) @@ -1563,6 +1563,7 @@ pushtag (location_t loc, tree name, tree TYPE_STUB_DECL (type) = pushdecl (build_decl (loc, TYPE_DECL, NULL_TREE, type)); + TREE_PUBLIC (TYPE_STUB_DECL (type)) = 1; /* An approximation for now, so we can tell this is a function-scope tag. This will be updated in pop_scope. */
Re: [PATCH i386] Move CLOBBERED_REGS earlier in register class list
On Sun, May 10, 2015 at 6:44 PM, Jan Hubicka wrote: >> On 32-bit x86, register class CLOBBERED_REGS is a proper subset of >> LEGACY_REGS, which causes IRA not to consider it separately for register >> allocation, even when it has lower cost than other classes. This patch is >> useful to fix code generation problem that appears with no-PLT PIC tailcalls. >> >> Was there a specific reason for CLOBBERED_REGS class to be listed as late as >> it is? On 32-bit this class contains only EAX, ECX, EDX. > > Uros moved CLOBBERED_REGS late in > https://gcc.gnu.org/ml/gcc-patches/2012-08/msg00796.html > which contains a rationale, too. > > I am adding Uros and Vladimir to CC just in case they missed the email :) > Honza Uh, I don't remember that far, but from the context of the referred patch, it looks like a "cleanup" of some sort. My atch matched 32bit to 64bit, but could be also in the opposite way. Let's try the patch and see what breaks. Uros.
Re: [PATCH 6/6] rs6000: Clean up the various rlwinm patterns
On Sun, 10 May 2015, Segher Boessenkool wrote: > * Give every define_insn a name; > * Add missing conditions for some of the dot forms; > * Use define_insn_and_split to reduce duplication; > * Renumber operands so 0,1,2,3 are the actual operands of the machine > instruction, in order; > * Reformat some patterns. [...] > 2015-05-10 Segher Boessenkool > > * config/rs6000/rs6000.md (*rotlsi3_internal4, *rotlsi3_internal5, > *rotlsi3_internal6, rlwinm, 5 unnamed define_insns, and 6 > define_splits): Delete. > (*rotlsi3_mask, *rotlsi3_mask_dot, *rotlsi3_mask_dot2, > *ashlsi3_imm_mask, *ashlsi3_imm_mask_dot, *ashlsi3_imm_mask_dot2, > *lshrsi3_imm_mask, *lshrsi3_imm_mask_dot, *lshrsi3_imm_mask_dot2): > New. [...] > diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md > index d3b1a7a..1fcd69e 100644 > --- a/gcc/config/rs6000/rs6000.md > +++ b/gcc/config/rs6000/rs6000.md [...] > @@ -3894,7 +3881,7 @@ (define_insn_and_split "*ashl3_dot2" > (set_attr "length" "4,8")]) > > > -(define_insn "rlwinm" > +(define_insn "*ashlsi3_imm_mask" >[(set (match_operand:SI 0 "gpc_reg_operand" "=r") > (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r") > (match_operand:SI 2 "const_int_operand" "i")) This clearly renames rather than removing the `rlwinm' pattern, please correctly reflect that in ChangeLog. Some other, unnamed patterns are given names rather than deleted as well, just as you've noted at the top. And none of the other changes are mentioned in your ChangeLog entry. Would you be able to split this change up further by any chance? Perhaps into the very steps you listed at the top so that each individual change addresses a single issue only. That would avoid problems with ChangeLog and make the review easier. Thanks, Maciej
Re: [PATCH i386] Move CLOBBERED_REGS earlier in register class list
On Sun, May 10, 2015 at 7:51 PM, Uros Bizjak wrote: > On Sun, May 10, 2015 at 6:44 PM, Jan Hubicka wrote: >>> On 32-bit x86, register class CLOBBERED_REGS is a proper subset of >>> LEGACY_REGS, which causes IRA not to consider it separately for register >>> allocation, even when it has lower cost than other classes. This patch is >>> useful to fix code generation problem that appears with no-PLT PIC >>> tailcalls. >>> >>> Was there a specific reason for CLOBBERED_REGS class to be listed as late as >>> it is? On 32-bit this class contains only EAX, ECX, EDX. >> >> Uros moved CLOBBERED_REGS late in >> https://gcc.gnu.org/ml/gcc-patches/2012-08/msg00796.html >> which contains a rationale, too. >> >> I am adding Uros and Vladimir to CC just in case they missed the email :) >> Honza > > Uh, I don't remember that far, but from the context of the referred > patch, it looks like a "cleanup" of some sort. My atch matched 32bit > to 64bit, but could be also in the opposite way. Let's try the patch > and see what breaks. Ah, the reason was that 64bit targets have many more call-clobbered registers. So, I tried to position CLOBBERED_REGS according to the ascending number of registers in the register set. Maybe the most clean solution is to split the class to CLOBBERED_REGS_32 and CLOBBERED_REGS_64 classes and set the register constraint in constraints.md depending on TARGET_64BIT. Uros.
New Swedish PO file for 'gcc' (version 5.1.0)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'gcc' has been submitted by the Swedish team of translators. The file is available at: http://translationproject.org/latest/gcc/sv.po (This file, 'gcc-5.1.0.sv.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/gcc/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/gcc.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator.
[PATCH] Added myself to "Write After Approval" section
Subj. -- Regards, Mikhail Maltsev diff --git a/ChangeLog b/ChangeLog index d4b60dd..b9bfc76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-05-10 Mikhail Maltsev + + * MAINTAINERS (Write After Approval): Add myself. + 2015-05-03 Matthias Klose * configure.ac: Match $host configured with triplets. diff --git a/MAINTAINERS b/MAINTAINERS index 19c8927..7dc4c8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -480,6 +480,7 @@ Christophe Lyon Luis Machado Ziga Mahkovec David Malcolm +Mikhail Maltsev Simon Martin Ranjit Mathew Michael Matz
Re: [patch, Fortran] Fix PR 66041
Hi Mikael, thanks for the review. Here is what I committed. Regards Thomas 2015-05-10 Thomas Koenig PR fortran/66041 * frontend-passes.c (scalarized_expr): Set correct dimension and shape for the expression to be passed to lbound. Remove trailing references after array refrence. (inline_matmul_assign): Remove gfc_copy_expr from calls to scalarized_expr(). 2015-05-10 Thomas Koenig PR fortran/66041 * gfortran.dg/inline_matmul_7.f90: New test. * gfortran.dg/inline_matmul_8.f90: New test. * gfortran.dg/inline_matmul_9.f90: New test. Index: frontend-passes.c === --- frontend-passes.c (Revision 222864) +++ frontend-passes.c (Arbeitskopie) @@ -2607,18 +2607,55 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, } else { + gfc_expr *lbound_e; + gfc_ref *ref; + + lbound_e = gfc_copy_expr (e_in); + + for (ref = lbound_e->ref; ref; ref = ref->next) + if (ref->type == REF_ARRAY + && (ref->u.ar.type == AR_FULL + || ref->u.ar.type == AR_SECTION)) + break; + + if (ref->next) + { + gfc_free_ref_list (ref->next); + ref->next = NULL; + } + if (!was_fullref) { /* Look at full individual sections, like a(:). The first index is the lbound of a full ref. */ - + int j; gfc_array_ref *ar; - ar = gfc_find_array_ref (e_in); + ar = &ref->u.ar; ar->type = AR_FULL; + for (j = 0; j < ar->dimen; j++) + { + gfc_free_expr (ar->start[j]); + ar->start[j] = NULL; + gfc_free_expr (ar->end[j]); + ar->end[j] = NULL; + gfc_free_expr (ar->stride[j]); + ar->stride[j] = NULL; + } + + /* We have to get rid of the shape, if there is one. Do + so by freeing it and calling gfc_resolve to rebuild + it, if necessary. */ + + if (lbound_e->shape) + gfc_free_shape (&(lbound_e->shape), lbound_e->rank); + + lbound_e->rank = ar->dimen; + gfc_resolve_expr (lbound_e); } - lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, - i_index + 1); + lbound = get_array_inq_function (GFC_ISYM_LBOUND, lbound_e, + i + 1); + gfc_free_expr (lbound_e); } ar->dimen_type[i] = DIMEN_ELEMENT; @@ -2639,6 +2676,7 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, i_index ++; } } + return e; } @@ -2929,15 +2967,15 @@ inline_matmul_assign (gfc_code **c, int *walk_subt list[0] = var_3; list[1] = var_1; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 2); + cscalar = scalarized_expr (co->expr1, list, 2); list[0] = var_3; list[1] = var_2; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 2); + ascalar = scalarized_expr (matrix_a, list, 2); list[0] = var_2; list[1] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 2); + bscalar = scalarized_expr (matrix_b, list, 2); break; @@ -2955,14 +2993,14 @@ inline_matmul_assign (gfc_code **c, int *walk_subt var_2 = do_2->ext.iterator->var; list[0] = var_2; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 1); + cscalar = scalarized_expr (co->expr1, list, 1); list[0] = var_2; list[1] = var_1; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 2); + ascalar = scalarized_expr (matrix_a, list, 2); list[0] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 1); + bscalar = scalarized_expr (matrix_b, list, 1); break; @@ -2980,14 +3018,14 @@ inline_matmul_assign (gfc_code **c, int *walk_subt var_2 = do_2->ext.iterator->var; list[0] = var_1; - cscalar = scalarized_expr (gfc_copy_expr (co->expr1), list, 1); + cscalar = scalarized_expr (co->expr1, list, 1); list[0] = var_2; - ascalar = scalarized_expr (gfc_copy_expr (matrix_a), list, 1); + ascalar = scalarized_expr (matrix_a, list, 1); list[0] = var_2; list[1] = var_1; - bscalar = scalarized_expr (gfc_copy_expr (matrix_b), list, 2); + bscalar = scalarized_expr (matrix_b, list, 2); break; ! { dg-do run } ! { dg-options "-ffrontend-optimize -fdump-tree-original" } program main implicit none real(kind=8), ALLOCATABLE :: a(:,:), b(:,:), v1(:), v2(:) real(kind=8), dimension(3,3) :: v1res, v2res integer :: n, i data v1res/ 442.d0, -492.d0, 586.d0, & -4834.d0, 5694.d0, -7066.d0, & 13042.d0, -15450.d0, 19306.d0 / data v2res/ 5522.d0, -6310.d0, 7754.d0, & -7794.d0, 8982.d0, -11034.d0, & 10490.d0, -12160.d0, 14954.d0 / n = 3 ALLOCATE(a(N,N),b(N,N),v1(N), v2(N)) a = reshape([((-1)**i*(-i-5)*(i+3)+5,i=1,n**2)], shape(a)) b = reshape([((-1)**i*(-i-1)*
Fix type_verifier ICE with non-NULL TREE_PURPOSE in TYPE_ARG_TYPES
Hi, in my tree I run the type chekcer from dwarf2out and tree streamer and it reports non-NULL TREE_PURPOSE in TYPE_ARG_TYPES during bootstrap. This is because C++ FE uses it to store the initial value. This patch updates verifier to permit this case and free_lang_data_in_type to clear it. I am going to commit this as obvious (The checks will trigger often on LTO builds even in mainline) I also added documentation. I think dwarf2out may be interested to output this so one don't need to specify the value from debugger. Bootstrapped/regtested x86_64-linux Honza * tree.c (free_lang_data_in_type): Free TREE_PURPOSE of TYPE_ARG_TYPES list. (verify_type): Permit non-NULL TREE_PURPOSE in non-LTO builds. * tree.def (FUNCTION_TYPE): Document TREE_PURPOSE in TYPE_ARG_TYPES Index: tree.c === --- tree.c (revision 222981) +++ tree.c (working copy) @@ -5041,6 +5041,8 @@ free_lang_data_in_type (tree type) TREE_VALUE (p) = build_qualified_type (arg_type, quals); free_lang_data_in_type (TREE_VALUE (p)); } + /* C++ FE uses TREE_PURPOSE to store initial values. */ + TREE_PURPOSE (p) = NULL; } } @@ -12817,7 +12831,8 @@ verify_type (const_tree t) else if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE) for (tree l = TYPE_ARG_TYPES (t); l; l = TREE_CHAIN (l)) { - if (TREE_PURPOSE (l)) + /* C++ FE uses TREE_PURPOSE to store initial values. */ + if (TREE_PURPOSE (l) && in_lto_p) { error ("TREE_PURPOSE is non-NULL in TYPE_ARG_TYPES list"); debug_tree (l); Index: tree.def === --- tree.def(revision 222981) +++ tree.def(working copy) @@ -245,6 +245,8 @@ DEFTREECODE (POINTER_BOUNDS_TYPE, "point TREE_TYPE type of value returned. TYPE_ARG_TYPES list of types of arguments expected. this list is made of TREE_LIST nodes. + In this list TREE_PURPOSE can be used to indicate the default + value of parameter (used by C++ frontend). Types of "Procedures" in languages where they are different from functions have code FUNCTION_TYPE also, but then TREE_TYPE is zero or void type. */ DEFTREECODE (FUNCTION_TYPE, "function_type", tcc_type, 0)
Re: [PATCH 6/6] rs6000: Clean up the various rlwinm patterns
On Sun, May 10, 2015 at 07:02:33PM +0100, Maciej W. Rozycki wrote: > > -(define_insn "rlwinm" > > +(define_insn "*ashlsi3_imm_mask" > >[(set (match_operand:SI 0 "gpc_reg_operand" "=r") > > (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r") > >(match_operand:SI 2 "const_int_operand" "i")) > > This clearly renames rather than removing the `rlwinm' pattern, please > correctly reflect that in ChangeLog. Some other, unnamed patterns are > given names rather than deleted as well, just as you've noted at the top. > And none of the other changes are mentioned in your ChangeLog entry. The changelog says it deletes the patterns with the old names. Which it does. And it adds the ones with the new names. Which it does. No one said changelogs are useful ;-) > Would you be able to split this change up further by any chance? I could, but it would be a lot of extra work. First, I haven't done those steps in order (they aren't "steps" at all): I take one pattern, and fix it up, then the next, etc. But much worse: if you do tiny pattern changes like you suggest, I can guarantee you the patches _will_ mis-apply. All of the time :-( [ Sometimes two patterns even have the same name, and sometimes even 100% identical contents. Exciting! ] > Perhaps into the very steps you listed at the top so that each individual > change addresses a single issue only. That would avoid problems with > ChangeLog and make the review easier. This isn't the first patch like this, I've cleaned up most other PowerPC integer patterns already. It's enough work already. Often the changes cannot be separated, and even if they can you then need them in the fixed order you made for them, etc. For this small patch I could probably do a better changelog though. Segher
Re: [Patch, Fortran] Simplify lbound
On Sun, May 10, 2015 at 6:58 AM, Mikael Morin wrote: > Le 03/05/2015 22:38, Thomas Koenig a écrit : >> Hi Mikael, >> >> Looks good. >> >> In general, it is better to restrict changes to existing test cases to >> the necessary minimum that they still pass, and add new code to new >> test cases. This makes regressions easier to track. >> >> So, OK with that change. >> > Here is what I have committed. > It caused: /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:39: Error: Variable 'c1' cannot appear in the expression at (1)^M /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:42: Error: Variable 'c2' cannot appear in the expression at (1)^M /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:15: Error: Variable 'a1' cannot appear in the expression at (1)^M /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:18: Error: Variable 'a2' cannot appear in the expression at (1)^M /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:27: Error: Variable 'b1' cannot appear in the expression at (1)^M /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:30: Error: Variable 'b2' cannot appear in the expression at (1)^M FAIL: gfortran.dg/inline_matmul_3.f90 -O (test for excess errors) -- H.J.
[PATCH] Fix typo
OK to commit? 2015-05-10 Paulo Matos * configure.ac: Fix typo. * configure: Regenerate. diff --git a/configure b/configure index a3f66ba..8ee279f 100755 --- a/configure +++ b/configure @@ -7423,7 +7423,7 @@ fi # multilib is not explicitly enabled. case "$target:$have_compiler:$host:$target:$enable_multilib" in x86_64-*linux*:yes:$build:$build:) -# Make sure we have a developement environment that handles 32-bit +# Make sure we have a development environment that handles 32-bit dev64=no echo "int main () { return 0; }" > conftest.c ${CC} -m32 -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c @@ -7434,7 +7434,7 @@ case "$target:$have_compiler:$host:$target: $enable_multilib" in fi rm -f conftest* if test x${dev64} != xyes ; then - as_fn_error "I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib." "$LINENO" 5 + as_fn_error "I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib." "$LINENO" 5 fi ;; esac diff --git a/configure.ac b/configure.ac index 987dfab..4081fb9 100644 --- a/configure.ac +++ b/configure.ac @@ -3063,7 +3063,7 @@ fi # multilib is not explicitly enabled. case "$target:$have_compiler:$host:$target:$enable_multilib" in x86_64-*linux*:yes:$build:$build:) -# Make sure we have a developement environment that handles 32-bit +# Make sure we have a development environment that handles 32-bit dev64=no echo "int main () { return 0; }" > conftest.c ${CC} -m32 -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c @@ -3074,7 +3074,7 @@ case "$target:$have_compiler:$host:$target: $enable_multilib" in fi rm -f conftest* if test x${dev64} != xyes ; then - AC_MSG_ERROR([I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.]) + AC_MSG_ERROR([I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.]) fi ;; esac
Fix some of ODR type comparsion warnings
Hi, this patch fixes few issues in ipa-deivrt ODR warnings I noticed while looking on Firefox builds with the new code to compare types of declarations in lto-symtab.c. It may make sense to backport the fix for arugment counting to GCC 5, the parameter indexes comes off by one for method types because of the implicit THIS pointer parameter. Bootstrapped/regtested x86_64-linux, comitted. Honza * ipa-devirt.c (warn_types_mismatch): Do not ICE when warning about mismatch between C and C++ type; compoare correctly ARG_TYPES for non-prototypes and output correctly parameter index for METHOD_TYPE. (odr_types_equivalent_p): Fix wording of warning about attributes; it is OK to match prototype and non-prototype. Index: ipa-devirt.c === --- ipa-devirt.c(revision 222981) +++ ipa-devirt.c(working copy) @@ -1028,7 +1040,9 @@ warn_types_mismatch (tree t1, tree t2) t1 = t2; t2 = tmp; } - if (TYPE_NAME (t1) && TYPE_NAME (t2)) + if (TYPE_NAME (t1) && TYPE_NAME (t2) + && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL + && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL) { inform (DECL_SOURCE_LOCATION (TYPE_NAME (t1)), "type %qT defined in anonymous namespace can not match " @@ -1079,7 +1093,7 @@ warn_types_mismatch (tree t1, tree t2) else if (TREE_CODE (t1) == METHOD_TYPE || TREE_CODE (t1) == FUNCTION_TYPE) { - tree parms1, parms2; + tree parms1 = NULL, parms2 = NULL; int count = 1; if (!odr_subtypes_equivalent_p (TREE_TYPE (t1), TREE_TYPE (t2), @@ -1089,21 +1103,27 @@ warn_types_mismatch (tree t1, tree t2) warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2)); return; } - for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2); - parms1 && parms2; - parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2), - count++) - { - if (!odr_subtypes_equivalent_p - (TREE_VALUE (parms1), TREE_VALUE (parms2), &visited)) - { - inform (UNKNOWN_LOCATION, - "type mismatch in parameter %i", count); - warn_types_mismatch (TREE_VALUE (parms1), - TREE_VALUE (parms2)); - return; - } - } + if (prototype_p (t1) && prototype_p (t2)) + for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2); +parms1 && parms2; +parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2), +count++) + { + if (!odr_subtypes_equivalent_p + (TREE_VALUE (parms1), TREE_VALUE (parms2), &visited)) + { + if (count == 1 && TREE_CODE (t1) == METHOD_TYPE) + inform (UNKNOWN_LOCATION, + "implicit this pointer type mismatch"); + else + inform (UNKNOWN_LOCATION, + "type mismatch in parameter %i", + count - (TREE_CODE (t1) == METHOD_TYPE)); + warn_types_mismatch (TREE_VALUE (parms1), +TREE_VALUE (parms2)); + return; + } + } if (parms1 || parms2) { inform (UNKNOWN_LOCATION, @@ -1180,7 +1200,7 @@ odr_types_equivalent_p (tree t1, tree t2 if (comp_type_attributes (t1, t2) != 1) { warn_odr (t1, t2, NULL, NULL, warn, warned, - G_("a type with attributes " + G_("a type with different attributes " "is defined in another translation unit")); return false; } @@ -1348,7 +1368,8 @@ odr_types_equivalent_p (tree t1, tree t2 return false; } - if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2)) + if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2) + || !prototype_p (t1) || !prototype_p (t2)) return true; else {
[PATCH] Add myself to MAINTAINERS
Somehow I never added myself to the MAINTAINERS file. Apologies for that. OK to commit? 2015-05-10 Paulo Matos * MAINTAINERS: Add myself as commit after approval. diff --git a/MAINTAINERS b/MAINTAINERS index 7dc4c8f..c5d6c99 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -483,6 +483,7 @@ David Malcolm Mikhail Maltsev Simon Martin Ranjit Mathew +Paulo Matos Michael Matz Greg McGary Roland McGrath
Re: [Patch, Fortran] Simplify lbound
Am 10.05.2015 um 22:43 schrieb H.J. Lu: >> Here is what I have committed. >> > > It caused: > > /export/gnu/import/git/sources/gcc/gcc/testsuite/gfortran.dg/inline_matmul_3.f90:38:39: > Error: Variable 'c1' cannot appear in the expression at (1)^M I know that error message, I got it when developing the inline matmul patches with the same test cases. I had a fix for this error message in one of my matmul patches, but it was removed in the review process because it could no longer be reproduced. So, here is the fix again. I think it is close to obvious (since it fixes the problem and can obviously do no harm), but anyway: OK for trunk? Regards Thomas 2015-05-10 Thomas Koenig PR fortran/66041 PR fortran/37131 * gfortran.h (gfc_array_spec): Add field resolved. * array.c (gfc_resolve_array_spec): Resolve array spec only once. Index: array.c === --- array.c (Revision 222984) +++ array.c (Arbeitskopie) @@ -338,6 +338,9 @@ gfc_resolve_array_spec (gfc_array_spec *as, int ch if (as == NULL) return true; + if (as->resolved) +return true; + for (i = 0; i < as->rank + as->corank; i++) { e = as->lower[i]; @@ -364,6 +367,8 @@ gfc_resolve_array_spec (gfc_array_spec *as, int ch } } + as->resolved = true; + return true; } Index: gfortran.h === --- gfortran.h (Revision 222984) +++ gfortran.h (Arbeitskopie) @@ -1002,6 +1002,8 @@ typedef struct bool cp_was_assumed; /* AS_ASSUMED_SIZE cp arrays are converted to AS_EXPLICIT, but we want to remember that we did this. */ + + bool resolved; } gfc_array_spec;
Fwd: [PING 2][PATCH] libgcc: Add CFI directives to the soft floating point support code for ARM
Hi Ramana! Sorry to bother, but I looked at the repository and didn't see this committed. As I don't have write access could you please commit this for me? Thanks a lot! On Tue, Apr 28, 2015 at 2:07 PM, Martin Galvan wrote: > Thanks a lot. I don't have write access to the repository, could you > commit this for me? > > On Tue, Apr 28, 2015 at 1:21 PM, Ramana Radhakrishnan > wrote: >> On Tue, Apr 28, 2015 at 4:19 PM, Martin Galvan >> wrote: >>> This patch adds CFI directives to the soft floating point support code for >>> ARM. >>> >>> Previously, if we tried to do a backtrace from that code in a debug session >>> we'd >>> get something like this: >>> >>> (gdb) bt >>> #0 __nedf2 () at >>> ../../../../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1082 >>> #1 0x0db6 in __aeabi_cdcmple () at >>> ../../../../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1158 >>> #2 0xf5c28f5c in ?? () >>> Backtrace stopped: previous frame identical to this frame (corrupt stack?) >>> >>> Now we'll get something like this: >>> >>> (gdb) bt >>> #0 __nedf2 () at >>> ../../../../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1156 >>> #1 0x0db6 in __aeabi_cdcmple () at >>> ../../../../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1263 >>> #2 0x0dc8 in __aeabi_dcmpeq () at >>> ../../../../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1285 >>> #3 0x0504 in main () >>> >>> I have a company-wide copyright assignment. I don't have commit access, >>> though, so it would be great if anyone could commit this for me. >>> >>> Thanks a lot! >>> >> >> this is OK , thanks. Sorry about the delay in reviewing this. >> >> Ramana -- Martin Galvan Software Engineer Taller Technologies Argentina San Lorenzo 47, 3rd Floor, Office 5 Córdoba, Argentina Phone: 54 351 4217888 / +54 351 4218211
[PATCH] Fix memory leak in C++ pretty printer
In gcc/cp/error.c we initialize the C++ pretty printer object twice: first during statics initialization and later in a placement-new in init_error(). This double-initialization causes a memory leak of about 7kb according to valgrind. I don't see a reason to initialize the object a second time so I elected to remove init_error(). Does the patch look OK after testing? gcc/cp/ChangeLog: * cp-tree.h (init_error): Remove declaration. * error.c (scratch_pretty_printer): Rename to ... (actual_pretty_printer): ... this. (cxx_pp): Constify and update accordingly. (init_error): Remove definition. * lex.c (cxx_init): Do not call init_error. --- gcc/cp/cp-tree.h | 1 - gcc/cp/error.c | 14 ++ gcc/cp/lex.c | 1 - 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4136d98..c51f88f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5505,7 +5505,6 @@ extern tree vtv_finish_verification_constructor_init_function (tree); extern bool cp_omp_mappable_type (tree); /* in error.c */ -extern void init_error (void); extern const char *type_as_string (tree, int); extern const char *type_as_string_translate(tree, int); extern const char *decl_as_string (tree, int); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index ce43f86..0d98a3c 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -54,8 +54,8 @@ along with GCC; see the file COPYING3. If not see tree -> string functions that are occasionally called from the debugger or by the front-end for things like __PRETTY_FUNCTION__. */ -static cxx_pretty_printer scratch_pretty_printer; -static cxx_pretty_printer * cxx_pp = &scratch_pretty_printer; +static cxx_pretty_printer actual_pretty_printer; +static cxx_pretty_printer * const cxx_pp = &actual_pretty_printer; /* Translate if being used for diagnostics, but not for dump files or __PRETTY_FUNCTION. */ @@ -140,16 +140,6 @@ cxx_initialize_diagnostics (diagnostic_context *context) diagnostic_format_decoder (context) = cp_printer; } -/* Initialize the global cxx_pp that is used as the memory store for - the string representation of C++ AST. See the description of - cxx_pp above. */ - -void -init_error (void) -{ - new (cxx_pp) cxx_pretty_printer (); -} - /* Dump a scope, if deemed necessary. */ static void diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 0fced4f..bde15bc 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -259,7 +259,6 @@ cxx_init (void) init_cp_semantics (); init_operators (); init_method (); - init_error (); current_function_decl = NULL; -- 2.4.0.rc2.31.g7c597ef
Fix construction of gcov_fn_info
Hi, as discussed while back, gcov_fn_info_type is built incorrectly. We produce a variant that is COMPLETE_TYPE_P but has no fields. THis triggers ICE with verify_type patch I am about to send. Bootstrapped/regtested x86_64-linux, comitted. Patch by Richard Biener * coverage.c (coverage_obj_init): Delay building of type variant until the type is finished. Index: coverage.c === --- coverage.c (revision 222984) +++ coverage.c (working copy) @@ -1141,9 +1141,10 @@ coverage_obj_init (void) /* Build the info and fn_info types. These are mutually recursive. */ gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE); gcov_fn_info_type = lang_hooks.types.make_type (RECORD_TYPE); + build_fn_info_type (gcov_fn_info_type, n_counters, gcov_info_type); + gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE); gcov_fn_info_ptr_type = build_pointer_type (build_qualified_type (gcov_fn_info_type, TYPE_QUAL_CONST)); - build_fn_info_type (gcov_fn_info_type, n_counters, gcov_info_type); build_info_type (gcov_info_type, gcov_fn_info_ptr_type); /* Build the gcov info var, this is referred to in its own
More checks for verify_type_variant
Hi, this patch completes checking of type_non_common. THere is nothing too interesting except for the FIXME about Fortran. gfc_nonrestricted_types does deep type copying producing a type variant for arrays and structures, but it builds distinct type variant for pointers. This leads to fact that we can have a structure whose fields are not variants of the main variant. I think we could fix it in a same way as objective C does similar copying in objc_get_protocol_qualified_node which simply calls build_type_variant on the pointer and then rewrites TREE_TYPE of the pointer instead of going through build_pointer_type... Bootstrapped/regtested x86_64-linux and ppc64-linux, will commit it shortly. Honza * tree.c (verify_type_variant): Check TYPE_VALUES_RAW and TYPE_PRECISION Index: tree.c === --- tree.c (revision 222984) +++ tree.c (working copy) @@ -12577,6 +12577,98 @@ verify_type_variant (const_tree t, tree debug_tree (TYPE_BINFO (t)); return false; } + + /* Check various uses of TYPE_VALUES_RAW. */ + if (TREE_CODE (t) == ENUMERAL_TYPE + && TYPE_VALUES (t) != TYPE_VALUES (tv)) +{ + error ("type variant has different TYPE_VALUES"); + debug_tree (tv); + error ("type variant's TYPE_VALUES"); + debug_tree (TYPE_VALUES (tv)); + error ("type's TYPE_VALUES"); + debug_tree (TYPE_VALUES (t)); + return false; +} + else if (TREE_CODE (t) == ARRAY_TYPE + && TYPE_DOMAIN (t) != TYPE_DOMAIN (tv)) +{ + error ("type variant has different TYPE_DOMAIN"); + debug_tree (tv); + error ("type variant's TYPE_DOMAIN"); + debug_tree (TYPE_DOMAIN (tv)); + error ("type's TYPE_DOMAIN"); + debug_tree (TYPE_DOMAIN (t)); + return false; +} + /* Permit incomplete variants of complete type. While FEs may complete + all variants, this does not happen for C++ templates in all cases. */ + else if (RECORD_OR_UNION_TYPE_P (t) + && COMPLETE_TYPE_P (t) + && TYPE_FIELDS (t) != TYPE_FIELDS (tv)) +{ + tree f1, f2; + + /* Fortran builds qualified variants as new records with items of +qualified type. Verify that they looks same. */ + for (f1 = TYPE_FIELDS (t), f2 = TYPE_FIELDS (tv); + f1 && f2; + f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2)) + if (TREE_CODE (f1) != FIELD_DECL || TREE_CODE (f2) != FIELD_DECL + || (TYPE_MAIN_VARIANT (TREE_TYPE (f1)) +!= TYPE_MAIN_VARIANT (TREE_TYPE (f2)) + /* FIXME: gfc_nonrestricted_type builds all types as variants + with exception of pointer types. It deeply copies the type + which means that we may end up with a variant type + referring non-variant pointer. We may change it to + produce types as variants, too, like + objc_get_protocol_qualified_type does. */ + && !POINTER_TYPE_P (TREE_TYPE (f1))) + || DECL_FIELD_OFFSET (f1) != DECL_FIELD_OFFSET (f2) + || DECL_FIELD_BIT_OFFSET (f1) != DECL_FIELD_BIT_OFFSET (f2)) + break; + if (f1 || f2) + { + error ("type variant has different TYPE_FIELDS"); + debug_tree (tv); + error ("first mismatch is field"); + debug_tree (f1); + error ("and field"); + debug_tree (f2); + return false; + } +} + else if ((TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE) + && TYPE_ARG_TYPES (t) != TYPE_ARG_TYPES (tv)) +{ + error ("type variant has different TYPE_ARG_TYPES"); + debug_tree (tv); + return false; +} + /* For C++ the qualified variant of array type is really an array type + of qualified TREE_TYPE. + objc builds variants of pointer where pointer to type is a variant, too + in objc_get_protocol_qualified_type. */ + if (TREE_TYPE (t) != TREE_TYPE (tv) + && ((TREE_CODE (t) != ARRAY_TYPE + && !POINTER_TYPE_P (t)) + || TYPE_MAIN_VARIANT (TREE_TYPE (t)) +!= TYPE_MAIN_VARIANT (TREE_TYPE (tv +{ + error ("type variant has different TREE_TYPE"); + debug_tree (tv); + error ("type variant's TREE_TYPE"); + debug_tree (TREE_TYPE (tv)); + error ("type's TREE_TYPE"); + debug_tree (TREE_TYPE (t)); + return false; +} + if (TYPE_PRECISION (t) != TYPE_PRECISION (tv)) +{ + error ("type variant has different TYPE_PRECISION"); + debug_tree (tv); + return false; +} return true; }
Re: [PATCH] Fix typo
On 05/10/2015 03:00 PM, Paulo Matos wrote: OK to commit? 2015-05-10 Paulo Matos * configure.ac: Fix typo. * configure: Regenerate. Yes. This would fall under the obvious rule and can be committed without waiting for approvals. jeff
Re: [PATCH 1/6] combine: undo_to_marker
On 05/10/2015 10:13 AM, Segher Boessenkool wrote: This generalises undo_all to allow undoing only the last some SUBSTs. This is used by the next patch, but is more generally useful. Comments? Segher 2015-05-10 Segher Boessenkool * combine.c (get_undo_marker): New function. (undo_to_marker): New function, largely factored out from ... (undo_all): ... this. Adjust. Seems quite reasonable to me. I can't think of any reason offhand why it'd be a bad idea. jeff
Re: [PATCH 2/6] combine: If recog fails, try again with zero_ext{ract,end} simplified
On 05/10/2015 10:13 AM, Segher Boessenkool wrote: Combine has its own ideas of what is "canonical" RTL, forcing all backends to have special patterns in their machine description for the "more simplified" patterns combine often creates, even though the backend already has patterns for a more general form. Backends that do not implement those patterns get less well optimised code. This patch lifts that burden for two cases: combine often converts an AND (with, say, 0xff) to a ZERO_EXTEND of a SUBREG; and an LSHIFTRT followed by an AND to a ZERO_EXTRACT. This is perfectly helpful for e.g. MEMs, but not nice if you have instructions to do more generic masking (like PowerPC rlwinm, and similar on some other archs). With this patch, if recog_for_combine fails, and there are any ZERO_EXT* in the pattern to be matched, it tries again with those expressed as AND etc. If that also fails it rolls back the changes, because it might still match after e.g. splitting, and we want to try the ZERO_EXT* for that as well. Tested on powerpc-linux, before and after removing many patterns from the machine description, and checked that the only changes in the bootstrapped compiler are new and removed functions. I'll also test on x86_64-linux before committing. Segher 2015-05-10 Segher Boessenkool * combine.c (recog_for_combine_1): New function, factored out from recog_for_combine. (change_zero_ext): New function. (recog_for_combine): If recog fails, try again with the pattern modified by change_zero_ext; if that still fails, restore the pattern. I like it. Attacking the extensions are the most obvious candidates, but I wonder if there's others (like the whole "ASHIFT vs MULT" stuff that we were recently looking at for ARM). jeff
Re: Improve LTO type checking during symtab merging
Hi, this is the updated version of patch with testsuite compensation and some changes: - As discussed with Richard on IRC, I added -Wlto-type-mismatch to control the warnings (enabled by default) and split ODR warnings from warnings about incompatible types (in a sense of weak structural equality tested by types_compatible_p at LTO time). Both -Wlto-type-mismatch and -Wodr are on by default. -Wodr points will output warnings only on conflicts between C++ programs that are positively undefined by the standard (modulo implementation bugs) and -Wlto-type-mismatch positives points out likely wrong code since the declarations are not compatible to -fstrit-aliasing. The testuiste fallout of Fortran was not that hard to fix, so I hope -Wlto-type-mismatch is weak enough to make sense for mixed language units. In fact I can use the ODR type matching tocde to implement more strict checks for separate flag (-Wlto-strict-type-mismatch) that would be off by default or perhaps just warn between C and C++ units. - I got Firefox building and noticed a false positives on functions when forward declaration and prototype was mixed. THis is because useless_type_conversion compares function types but requires the outer type to be the one more specified (prototype). types_compatible_p checks that the types are convertible both directions so it return false. This whole code does not make much sense to be. I do not see why useless_type_conversion needs to care about funcition types - we never convert these. I also do not see why it match TYPE_METHOD_BASETYPE when this field is never used for codegen. It is used by ubsan and dbxout only. I think useless_type_conversion can jsut ICE on function/method types and types_compatible_p can be extended by same code as I have in warn_types_mismatch minus the TYPE_METHOD_BASETYPE matching. On a positive note, the patch also finds some real bugs in Firefox :) - I also noticed that we may miss some ODR warnings when the declaration is of compound type, not named type. (i.e. odr_type a[4];). To make these working I added odr_or_derived_type_p and exported the functionality to make structural compare from ipa-devirt. The way of walking compount types was discussed with Jason here: https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00382.html Bootstrapped/regtested x86_64-linux, ppc64 running. Also tested with ltobootstrap. OK? * ipa-utils.h (warn_types_mismatch, odr_or_derived_type_p, odr_types_equivalent_p): Declare. (odr_type_p): Use gcc_checking_assert. * common.opt (Wlto-type-mismatch): New warning. * ipa-devirt.c (compound_type_base): New function. (odr_or_derived_type_p): New function. (odr_types_equivalent_p): New function. (add_type_duplicate): Simplify. * lto-symtab.c (warn_type_compatibility_p): Break out from ...; compare ODR types (if available) and function types. (lto_symtab_merge): ... here; output ODR violation warnings and call warn_types_mismatch. * gfortran.dg/lto/20091028-2_1.c: Fix return value. * gfortran.dg/lto/pr41576_1.f90: Add interface. * gfortran.dg/lto/pr41521_0.f90: Disable lto-type-mismatch * gfortran.dg/lto/pr60635_0.f90: Disable lto-type-mismatch. * gfortran.dg/lto/20091028-1_1.c: Fix return type. * gcc.dg/lto/20120723_0.c: Disbale lto-type-mismatch. Index: ipa-utils.h === --- ipa-utils.h (revision 222991) +++ ipa-utils.h (working copy) @@ -84,6 +84,9 @@ bool types_must_be_same_for_odr (tree, t bool types_odr_comparable (tree, tree, bool strict = false); cgraph_node *try_speculative_devirtualization (tree, HOST_WIDE_INT, ipa_polymorphic_call_context); +void warn_types_mismatch (tree t1, tree t2); +bool odr_or_derived_type_p (const_tree t); +bool odr_types_equivalent_p (tree type1, tree type2); /* Return vector containing possible targets of polymorphic call E. If COMPLETEP is non-NULL, store true if the list is complete. @@ -164,7 +167,7 @@ odr_type_p (const_tree t) return true; /* We do not have this information when not in LTO, but we do not need to care, since it is used only for type merging. */ - gcc_assert (in_lto_p || flag_lto); + gcc_checking_assert (in_lto_p || flag_lto); return (TYPE_NAME (t) && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t; Index: common.opt === --- common.opt (revision 222991) +++ common.opt (working copy) @@ -607,6 +607,10 @@ Woverflow Common Var(warn_overflow) Init(1) Warning Warn about overflow in arithmetic expressions +Wlto-type-mismatch +Common Var(warn_lto_type_mismatch) Init(1) Warning +During link time optimiza
RE: [patch, avr] extend part-clobbered check to AVR_TINY architecture
> -Original Message- > From: Denis Chertykov [mailto:cherty...@gmail.com] > Sent: Sunday, May 10, 2015 12:55 PM > To: Sivanupandi, Pitchumani > Cc: Georg-Johann Lay; GCC Patches > Subject: Re: [patch, avr] extend part-clobbered check to AVR_TINY > architecture > > Sorry for delay. (I was at vacation in Kazakhstan without internet.) > > > 2015-05-08 8:32 GMT+03:00 Sivanupandi, Pitchumani > : > > Ping! > > > >> -Original Message- > >> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- > >> ow...@gcc.gnu.org] On Behalf Of Sivanupandi, Pitchumani > >> Sent: Tuesday, April 21, 2015 8:21 PM > >> To: Georg-Johann Lay; Denis Chertykov > >> Cc: GCC Patches > >> Subject: [patch, avr] extend part-clobbered check to AVR_TINY > >> architecture > >> > >> Hi, > >> > >> When tried backporting AVR_TINY architecture support to 4.9, build > >> failed in libgcc for AVR_TINY. > >> Failure was due to ICE same as: > >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53065 > >> > >> Fix provided for that bug checks for if the mode crosses the callee > >> saved register. > >> Below patch updates that check as the AVR_TINY has different set of > >> callee saved registers (r18 and r19). > >> > >> This patch is against trunk. > >> > >> NOTE: ICE is re-produciable only with 4.9 + tiny patch and > >> --with-dwarf2 enabled. > >> > >> Is this ok for trunk? > >> > >> diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index > >> 68d5ddc..2f441e5 100644 > >> --- a/gcc/config/avr/avr.c > >> +++ b/gcc/config/avr/avr.c > >> @@ -11333,9 +11333,10 @@ avr_hard_regno_call_part_clobbered > (unsigned > >> regno, machine_mode mode) > >> return 0; > >> > >>/* Return true if any of the following boundaries is crossed: > >> - 17/18, 27/28 and 29/30. */ > >> + 17/18 or 19/20 (if AVR_TINY), 27/28 and 29/30. */ > >> > >> - return ((regno < 18 && regno + GET_MODE_SIZE (mode) > 18) > >> + return ((regno <= LAST_CALLEE_SAVED_REG && > >> + regno + GET_MODE_SIZE (mode) > (LAST_CALLEE_SAVED_REG + > >> + 1)) > >>|| (regno < REG_Y && regno + GET_MODE_SIZE (mode) > REG_Y) > >>|| (regno < REG_Z && regno + GET_MODE_SIZE (mode) > > >> REG_Z)); } > >> > > I think it's ok. Could you please commit? I do not have commit access. (--patch--) diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 68d5ddc..2f441e5 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -11333,9 +11333,10 @@ avr_hard_regno_call_part_clobbered (unsigned regno, machine_mode mode) return 0; /* Return true if any of the following boundaries is crossed: - 17/18, 27/28 and 29/30. */ + 17/18 or 19/20 (if AVR_TINY), 27/28 and 29/30. */ - return ((regno < 18 && regno + GET_MODE_SIZE (mode) > 18) + return ((regno <= LAST_CALLEE_SAVED_REG && + regno + GET_MODE_SIZE (mode) > (LAST_CALLEE_SAVED_REG + 1)) || (regno < REG_Y && regno + GET_MODE_SIZE (mode) > REG_Y) || (regno < REG_Z && regno + GET_MODE_SIZE (mode) > REG_Z)); } (--patch--) Regards, Pitchumani gcc/ChangeLog 2015-05-11 Pitchumani Sivanupandi * config/avr/avr.c (avr_hard_regno_call_part_clobbered): Use LAST_CALLEE_SAVED_REG instead of hard-coded register number. (Last callee saved reg is different for AVR_TINY architecture)
Re: [PATCH 2/6] combine: If recog fails, try again with zero_ext{ract,end} simplified
On Sun, May 10, 2015 at 10:15:34PM -0600, Jeff Law wrote: > > (recog_for_combine): If recog fails, try again with the pattern > > modified by change_zero_ext; if that still fails, restore the > > pattern. > I like it. Attacking the extensions are the most obvious candidates, > but I wonder if there's others (like the whole "ASHIFT vs MULT" stuff > that we were recently looking at for ARM). Yeah, I thought about that as well. But that case, MULT instead of shift, outside of MEM, is simply non-canonical RTL; and combine created it on purpose. It just shouldn't. There certainly will be other cases though; hopefully not overlapping, I don't want to recog an exponentially expanding number of times ;-) Segher