[committed] Further distinguish between length for warnings vs length for codegen/optimization
This is the second behavior changing hunk of Martin's work. In this patch we improve the distinction between maxbound/maxlen in get_range_strlen. This throttles several of the boundry crossing issues with string length range computations by allowing us to distinguish better between a length for warnings (maxbound) and a length of codegen/optimization purposes (maxlen). The updated tests reflect cases where we incorrectly optimizing based on the assumption that we wouldn't cross field boundaries and the like. This patch also fixes some of the failures in strlen-{5,6,7} which will be introduced in the next patch. I didn't include those in this patch because they'd fail without the next patch. This has been bootstrapped and regression tested on x86_64. It'll go through testing on the other targets overnight. Installing on the trunk momentarily. I'm going to stop here for the night. There's one more behavior changing patch, then some very light cleanup (STK_LENRANGE_2, comments, more tests etc) that I'll wrap up tomorrow. jeff * gimple-fold.c (get_range_strlen_tree): Record if the computed length is optimistic. If it is, then arrange to compute the conservative length as well. * gcc.dg/strlenopt-40.c: Update * gcc.dg/strlenopt-51.c: Likewise. * gcc.dg/tree-ssa/pr79376.c: Likewise. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 6185f98e6bd..cf19db268ad 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1291,6 +1291,12 @@ get_range_strlen_tree (tree arg, bitmap *visited, /* The length computed by this invocation of the function. */ tree val = NULL_TREE; + /* True if VAL is an optimistic (tight) bound determined from + the size of the character array in which the string may be + stored. In that case, the computed VAL is used to set + PDATA->MAXBOUND. */ + bool tight_bound = false; + /* We can end up with &(*iftmp_1)[0] here as well, so handle it. */ if (TREE_CODE (arg) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (arg, 0)) == ARRAY_REF) @@ -1384,6 +1390,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, && optype == TREE_TYPE (TREE_OPERAND (arg, 0)) && array_at_struct_end_p (TREE_OPERAND (arg, 0))) *flexp = true; + tight_bound = true; } else if (TREE_CODE (arg) == COMPONENT_REF && (TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 1))) @@ -1419,17 +1426,24 @@ get_range_strlen_tree (tree arg, bitmap *visited, /* Set the minimum size to zero since the string in the array could have zero length. */ pdata->minlen = ssize_int (0); - } - if (VAR_P (arg)) - { - tree type = TREE_TYPE (arg); - if (POINTER_TYPE_P (type)) - type = TREE_TYPE (type); - - if (TREE_CODE (type) == ARRAY_TYPE) + /* The array size determined above is an optimistic bound +on the length. If the array isn't nul-terminated the +length computed by the library function would be greater. +Even though using strlen to cross the subobject boundary +is undefined, avoid drawing conclusions from the member +type about the length here. */ + tight_bound = true; + } + else if (VAR_P (arg)) + { + /* Avoid handling pointers to arrays. GCC might misuse +a pointer to an array of one bound to point to an array +object of a greater bound. */ + tree argtype = TREE_TYPE (arg); + if (TREE_CODE (argtype) == ARRAY_TYPE) { - val = TYPE_SIZE_UNIT (type); + val = TYPE_SIZE_UNIT (argtype); if (!val || TREE_CODE (val) != INTEGER_CST || integer_zerop (val)) @@ -1476,6 +1490,43 @@ get_range_strlen_tree (tree arg, bitmap *visited, else pdata->maxbound = val; + if (tight_bound) +{ + /* VAL computed above represents an optimistically tight bound +on the length of the string based on the referenced object's +or subobject's type. Determine the conservative upper bound +based on the enclosing object's size if possible. */ + if (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2) + { + poly_int64 offset; + tree base = get_addr_base_and_unit_offset (arg, ); + if (!base) + { + /* When the call above fails due to a non-constant offset +assume the offset is zero and use the size of the whole +enclosing object instead. */ + base = get_base_address (arg); + offset = 0; + } + /* If the base object is a pointer no upper bound on the length +can be determined. Otherwise the maximum length is equal to +the size of the enclosing object minus the offset of +the referenced subobject minus 1
Re: [RFA] fix copyright year range in libstdc++ test file (was: "Re: [v3 PATCH] Implement std::string_view and P0254r2, Integrating std::string_view and std::string.")
> > In working on updating the copyright year notices for the GDB files, > > I noticed something very minor regarding the patch which added the > > file below (the same file was copied in gdb's testsuite); it looks > > like the year range for one of the files is truncated: > > > libstdc++-v3/ChangeLog: > > > > * testsuite/21_strings/basic_string_view/element_access/char/empty.cc: > >Fix year range in copyright header. > > Ok. Thank you, Mike. Pushed to trunk (rev 267504). -- Joel
[committed] Fix a couple minor problems with string length range computations
So the first of probably 3 patches to fix issues with string length computations now that the underlying infrastructure is in place. Like the prior patches, this is primarily Martin's work. My contribution has been to break it down into more manageable hunks. In this patch we change the external API for get_range_strlen to pass in the c_strlen_data pointer. Hence the various changes in client code such as builtins.c, calls.c, tree-ssa-strlen.c, etc. Internally in the public get_range_strlen we also massage the result of the internal call slightly. For example, if the internal call fails, we set the range info to impossible values that we can check for elsewhere. If the internal call didn't set maxbound, then we set it to an appropriate value, etc. With the change in how failures are reported we twiddle the sprintf call site slightly more than the others since it cares. Ultimately it's a slight simplification. This patch also fixes when we set the unlikely range. There's a few new tests and Martin made a couple tweaks to existing tests that are included in this patch. Bootstrapped and regression tested on x86_64. My testers will iterate on this overnight for the other targets. Committing to the trunk momentarily. Jeff * gimple-fold.h (get_range_strlen): Update prototype. * builtins.c (check_access): Update call to get_range_strlen to use c_strlen_data pointer. Change various variable accesses to instead pull data from the c_strlen_data structure. (check_strncat_sizes, expand_builtin_strncat): Likewise. * calls.c (maybe_warn_nonstring_arg): Likewise. * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Likewise. Reset minimum length if maximum lengh is unknown. * gimple-ssa-sprintf.c (get_string_length): Likewise. Drop code that used c_strlen, it's no longer needed. Restructure slightly. (format_string): Set unlikely range appropriately. * gimple-fold.c (get_range_strlen): Update comments. Fix minor formatting issues. (get_range_strlen): Accept c_strlen_data pointer for external call sites as well. Pass through to call to internal get_range_strlen. Adjust minlen, maxlen and maxbound as needed. (get_maxval_strlen): Update comments. (gimple_fold_builtin_strlen): Update call to get_range_strlen to use c_strlen_data pointer. Change variable accesses to instead use c_strlen_data data members. * gcc.dg/strlenopt-40.c: Disable a couple tests. * gcc.dg/strlenopt-48.c: Disable a couple tests. * gcc.dg/strlenopt-59.c: New test. * gcc.dg/tree-ssa/builtin-snprintf-5.c: New test. * g++.dg/init/strlen.C: New test. diff --git a/gcc/builtins.c b/gcc/builtins.c index 9fa11e158c3..28155b8c0aa 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -3341,7 +3341,10 @@ check_access (tree exp, tree, tree, tree dstwrite, the upper bound given by MAXREAD add one to it for the terminating nul. Otherwise, set it to one for the same reason, or to MAXREAD as appropriate. */ - get_range_strlen (srcstr, range); + c_strlen_data lendata = { }; + get_range_strlen (srcstr, , /* eltsize = */ 1); + range[0] = lendata.minlen; + range[1] = lendata.maxbound; if (range[0] && (!maxread || TREE_CODE (maxread) == INTEGER_CST)) { if (maxread && tree_int_cst_le (maxread, range[0])) @@ -4209,8 +4212,8 @@ check_strncat_sizes (tree exp, tree objsize) /* Try to determine the range of lengths that the source expression refers to. */ - tree lenrange[2]; - get_range_strlen (src, lenrange); + c_strlen_data lendata = { }; + get_range_strlen (src, , /* eltsize = */ 1); /* Try to verify that the destination is big enough for the shortest string. */ @@ -4224,8 +4227,8 @@ check_strncat_sizes (tree exp, tree objsize) } /* Add one for the terminating nul. */ - tree srclen = (lenrange[0] -? fold_build2 (PLUS_EXPR, size_type_node, lenrange[0], + tree srclen = (lendata.minlen +? fold_build2 (PLUS_EXPR, size_type_node, lendata.minlen, size_one_node) : NULL_TREE); @@ -4277,12 +4280,15 @@ expand_builtin_strncat (tree exp, rtx) tree slen = c_strlen (src, 1); /* Try to determine the range of lengths that the source expression - refers to. */ - tree lenrange[2]; - if (slen) -lenrange[0] = lenrange[1] = slen; - else -get_range_strlen (src, lenrange); + refers to. Since the lengths are only used for warning and not + for code generation disable strict mode below. */ + tree maxlen = slen; + if (!maxlen) +{ + c_strlen_data lendata = { }; + get_range_strlen (src, , /* eltsize = */ 1); + maxlen = lendata.maxbound; +} /* Try to verify that the destination is
[PATCH,Fortran] Suppress unclassifiable statement error message
Due to the nuances of issuing error messages with ieee_selected_real_kind when used in an initialization expression, it became painfully obvious that gfortran will often issue an "Unclassifiable statement" error as a run-on error. I tried to make the "Unclassifiable ..." error a fatal error, but there is at least one case were the US error is emitted before a useful error message. So, as a compromise I have elected to make emitting a US error conditional on whether any other error has been emitted. Patch tested on i586-*-freebsd. OK to commit? 2019-01-01 Steven G. Kargl * parse.c (decode_statement): Suppress "Unclassifiable statement" error if previous error messages were emitted. 2019-01-01 Steven G. Kargl * gfortran.dg/argument_checking_7.f90: Remove run-on error message. * gfortran.dg/dec_d_lines_3.f: Ditto. * gfortran.dg/dec_structure_24.f90: Ditto. * gfortran.dg/dec_structure_26.f90: Ditto. * gfortran.dg/dec_structure_27.f90: Ditto. * gfortran.dg/dec_type_print_3.f90: Ditto. * gfortran.dg/derived_name_1.f90: Ditto. * gfortran.dg/error_recovery_1.f90: Ditto. * gfortran.dg/gomp/pr29759.f90: Ditto. * gfortran.dg/pr36192.f90: Ditto. * gfortran.dg/pr56007.f90: Ditto. * gfortran.dg/pr56520.f90: Ditto. * gfortran.dg/pr78741.f90: Ditto. * gfortran.dg/print_fmt_2.f90: Ditto. * gfortran.dg/select_type_20.f90: Ditto. -- Steve Index: gcc/fortran/parse.c === --- gcc/fortran/parse.c (revision 267487) +++ gcc/fortran/parse.c (working copy) @@ -587,10 +587,16 @@ decode_statement (void) } /* All else has failed, so give up. See if any of the matchers has - stored an error message of some sort. */ - + stored an error message of some sort. Suppress the "Unclassifiable + statement" if a previous error message was emitted, e.g., by + gfc_error_now (). */ if (!gfc_error_check ()) -gfc_error_now ("Unclassifiable statement at %C"); +{ + int ecnt; + gfc_get_errors (NULL, ); + if (ecnt <= 0) +gfc_error_now ("Unclassifiable statement at %C"); +} reject_statement (); Index: gcc/testsuite/gfortran.dg/argument_checking_7.f90 === --- gcc/testsuite/gfortran.dg/argument_checking_7.f90 (revision 267487) +++ gcc/testsuite/gfortran.dg/argument_checking_7.f90 (working copy) @@ -12,7 +12,7 @@ module cyclic character(len(y)-1) ouch ! { dg-error "used before it is typed" } integer i do i = 1, len(ouch) -ouch(i:i) = achar(ieor(iachar(x(i:i)),iachar(y(i:i ! { dg-error "Unclassifiable statement" } +ouch(i:i) = achar(ieor(iachar(x(i:i)),iachar(y(i:i end do end function ouch end module cyclic Index: gcc/testsuite/gfortran.dg/dec_d_lines_3.f === --- gcc/testsuite/gfortran.dg/dec_d_lines_3.f (revision 267487) +++ gcc/testsuite/gfortran.dg/dec_d_lines_3.f (working copy) @@ -9,6 +9,4 @@ include 'dec_d_lines_2.f' ! { dg-error "character in statement label" " " { target *-*-*} 6 } -! { dg-error "Unclassifiable statement" " " { target *-*-*} 6 } ! { dg-error "character in statement label" " " { target *-*-*} 7 } -! { dg-error "Unclassifiable statement" " " { target *-*-*} 7 } Index: gcc/testsuite/gfortran.dg/dec_structure_24.f90 === --- gcc/testsuite/gfortran.dg/dec_structure_24.f90 (revision 267487) +++ gcc/testsuite/gfortran.dg/dec_structure_24.f90 (working copy) @@ -12,10 +12,6 @@ include 'dec_structure_1.f90' ! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 19 } ! { dg-error "-fdec-structure" " " { target *-*-* } 21 } ! { dg-error "-fdec-structure" " " { target *-*-* } 22 } -! { dg-error "Unclassifiable statement" " " { target *-*-* } 25 } -! { dg-error "Unclassifiable statement" " " { target *-*-* } 26 } -! { dg-error "Unclassifiable statement" " " { target *-*-* } 27 } -! { dg-error "Unclassifiable statement" " " { target *-*-* } 28 } ! { dg-error "is not a variable" " " { target *-*-* } 30 } ! { dg-error "Bad character" " " { target *-*-* } 32 } ! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 34 } Index: gcc/testsuite/gfortran.dg/dec_structure_26.f90 === --- gcc/testsuite/gfortran.dg/dec_structure_26.f90 (revision 267487) +++ gcc/testsuite/gfortran.dg/dec_structure_26.f90 (working copy) @@ -14,10 +14,6 @@ include 'dec_structure_1.f90' ! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 19 } ! { dg-error "-fdec-structure" " " { target *-*-* } 21 } ! { dg-error "-fdec-structure" " " { target *-*-* } 22 } -! { dg-error "Unclassifiable statement" " " { target *-*-* } 25 } -! { dg-error "Unclassifiable
[PATCH] ARM: fix -masm-syntax-unified (PR88648)
This allows to use unified asm syntax when compiling for the ARM instruction. This matches documentation and seems what the initial patch was intended doing when the flag got added. --- gcc/config/arm/arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 3419b6bd0f8..67b2b199f3f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3095,7 +3095,8 @@ arm_option_override_internal (struct gcc_options *opts, /* Thumb2 inline assembly code should always use unified syntax. This will apply to ARM and Thumb1 eventually. */ - opts->x_inline_asm_unified = TARGET_THUMB2_P (opts->x_target_flags); + if (TARGET_THUMB2_P (opts->x_target_flags)) +opts->x_inline_asm_unified = true; #ifdef SUBTARGET_OVERRIDE_INTERNAL_OPTIONS SUBTARGET_OVERRIDE_INTERNAL_OPTIONS; -- 2.20.1
Re: Fix devirtualiation in expanded thunks
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/tree-prof/devirt.C:99:26: > optimized: folding virtual function call to virtual unsigned int > mozPersonalDictionary::_ZThn8_N21mozPersonalDictionary6AddRefEv() > > > Is there a way to dump files for different patterns for 32bit or 64bit > > Why would we: many similar scans just use _ZThn\[0-9\]+ instead. Becuase the testcase was formely dispatching into ZThn8 (or some other constant I forgot) instead of ZThn16 causing wrong code. Well, there is runtime test that right thunk is used, so perhaps we can just drop the part maching the actual value since most probably testcase will ICE if wrong variant is picked again. Honza > > > tarets? Or shall we simply disable this test for 32bit? > > That's counterproductive, I believe. > > Rainer > > -- > - > Rainer Orth, Center for Biotechnology, Bielefeld University
Re: Fix devirtualiation in expanded thunks
Hi Jan, >> Andreas Schwab writes: >> >> > On Dez 31 2018, Martin Liška wrote: >> > >> >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual >> >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" >> >> "dom3" } } */ >> >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual >> >> function call to virtual unsigned int mozPersonalDictionary::AddRef" >> >> "dom3" } } */ >> >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual >> >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 >> >> "dom3" } } */ >> >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual >> >> function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 >> >> "dom3" } } */ >> > >> > New tests that FAIL (1 tests): >> > >> > unix/-mabi=ilp32: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 >> > "folding virtual function call to virtual unsigned int >> > mozPersonalDictionary::_ZThn16" 3 >> >> now it's >> >> +FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 "folding >> virtual function call to virtual unsigned int >> mozPersonalDictionary::_ZThn16" 1 >> >> and the failure seems to occur on every 32-bit target. The log shows >> >> g++.dg/tree-prof/devirt.C: pattern found 0 times > > I guess the ZThn16 should be replaced by ZThm8? not exactly: the dump file has /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/tree-prof/devirt.C:99:26: optimized: folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn8_N21mozPersonalDictionary6AddRefEv() > Is there a way to dump files for different patterns for 32bit or 64bit Why would we: many similar scans just use _ZThn\[0-9\]+ instead. > tarets? Or shall we simply disable this test for 32bit? That's counterproductive, I believe. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: Fix devirtualiation in expanded thunks
> Andreas Schwab writes: > > > On Dez 31 2018, Martin Liška wrote: > > > >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual > >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" > >> "dom3" } } */ > >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual > >> function call to virtual unsigned int mozPersonalDictionary::AddRef" > >> "dom3" } } */ > >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual > >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 > >> "dom3" } } */ > >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual > >> function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 > >> "dom3" } } */ > > > > New tests that FAIL (1 tests): > > > > unix/-mabi=ilp32: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 > > "folding virtual function call to virtual unsigned int > > mozPersonalDictionary::_ZThn16" 3 > > now it's > > +FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 "folding virtual > function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 > > and the failure seems to occur on every 32-bit target. The log shows > > g++.dg/tree-prof/devirt.C: pattern found 0 times I guess the ZThn16 should be replaced by ZThm8? Is there a way to dump files for different patterns for 32bit or 64bit tarets? Or shall we simply disable this test for 32bit? Honza > > Rainer > > -- > - > Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [RFA] fix copyright year range in libstdc++ test file
On 1/1/19 12:45 AM, Joel Brobecker wrote: Hello, In working on updating the copyright year notices for the GDB files, I noticed something very minor regarding the patch which added the file below (the same file was copied in gdb's testsuite); it looks like the year range for one of the files is truncated: | diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/empty.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/empty.cc | new file mode 100644 | index 000..c0f8206 | --- /dev/null | +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/empty.cc | @@ -0,0 +1,40 @@ | +// { dg-options "-std=gnu++17" } | + | +// Copyright (C) 3 Free Software Foundation, Inc. The file was contributed around July 2016, so it should be at least 2016-2018 now, but, looking at all the other test files around, all ranges start with 2013, so I suspect the intention was for this file to be the same. This is what the attached patch proposes. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string_view/element_access/char/empty.cc: Fix year range in copyright header. OK for trunk? One a fix pushed to GCC, I will take care of the GDB side. Thank you, Seems obvious to me. Ed
Bugs fixed in 2018
On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote: > > In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. > Unfortunately, 468 bugs were submitted in 2018. We need to get new and additional eyes looking at the source. I don't know how we do this as efforts in c.l.f to encourage others to step are typically met with "I don't know C". -- Steve
Re: [patch, fortran] Fix PR 82743, warning for truncation on constructors
On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote: > > first of all, Happy New Year to everybody! > > In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. > > Here is a first contribution towards reaching something similar, or even > better, for 2019. It is a rather straightforward patch which adds a > missing warning for truncated strings in constructors. > > Regression-tested. OK for trunk? > > Regards > > Thomas > > 2019-01-01 Thomas Koenig > > PR fortran/82743 > * primary.c (gfc_convert_to_structure_constructor): If a character > in a constructor is too long, add a warning with > -Wcharacter-truncation. > > 2019-01-01 Thomas Koenig > > PR fortran/82743 > * gfortran.dg/structure_constructor_16.f90: New test. Looks good to me. Thanks for the patch. -- Steve 20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4 20161221 https://www.youtube.com/watch?v=IbCHE-hONow
Re: Fix devirtualiation in expanded thunks
Andreas Schwab writes: > On Dez 31 2018, Martin Liška wrote: > >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" >> "dom3" } } */ >> -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual >> function call to virtual unsigned int mozPersonalDictionary::AddRef" >> "dom3" } } */ >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual >> function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 >> "dom3" } } */ >> +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual >> function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 >> "dom3" } } */ > > New tests that FAIL (1 tests): > > unix/-mabi=ilp32: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 > "folding virtual function call to virtual unsigned int > mozPersonalDictionary::_ZThn16" 3 now it's +FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 and the failure seems to occur on every 32-bit target. The log shows g++.dg/tree-prof/devirt.C: pattern found 0 times Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
[patch, fortran] Fix PR 82743, warning for truncation on constructors
Hello world, first of all, Happy New Year to everybody! In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. Here is a first contribution towards reaching something similar, or even better, for 2019. It is a rather straightforward patch which adds a missing warning for truncated strings in constructors. Regression-tested. OK for trunk? Regards Thomas 2019-01-01 Thomas Koenig PR fortran/82743 * primary.c (gfc_convert_to_structure_constructor): If a character in a constructor is too long, add a warning with -Wcharacter-truncation. 2019-01-01 Thomas Koenig PR fortran/82743 * gfortran.dg/structure_constructor_16.f90: New test. Index: primary.c === --- primary.c (Revision 267335) +++ primary.c (Arbeitskopie) @@ -3074,6 +3074,12 @@ gfc_convert_to_structure_constructor (gfc_expr *e, actual->expr->value.character.length = c; actual->expr->value.character.string = dest; + + if (warn_line_truncation && c < e) + gfc_warning_now (OPT_Wcharacter_truncation, + "CHARACTER expression will be truncated " + "in constructor (%ld/%ld) at %L", (long int) c, + (long int) e, >expr->where); } } ! { dg-do compile } ! { dg-additional-options "-Wcharacter-truncation" } ! PR 82743 - warnings were missing on truncation of structure ! constructors. ! Original test case by Simon Klüpfel PROGRAM TEST TYPE A CHARACTER(LEN=1) :: C END TYPE A TYPE(A) :: A1 A1=A("123") ! { dg-warning "CHARACTER expression will be truncated" } A1=A(C="123") ! { dg-warning "CHARACTER expression will be truncated" } A1%C="123" ! { dg-warning "CHARACTER expression will be truncated" } END PROGRAM TEST
Re: [RFA] fix copyright year range in libstdc++ test file (was: "Re: [v3 PATCH] Implement std::string_view and P0254r2, Integrating std::string_view and std::string.")
On Dec 31, 2018, at 9:45 PM, Joel Brobecker wrote: > > In working on updating the copyright year notices for the GDB files, > I noticed something very minor regarding the patch which added the > file below (the same file was copied in gdb's testsuite); it looks > like the year range for one of the files is truncated: > libstdc++-v3/ChangeLog: > > * testsuite/21_strings/basic_string_view/element_access/char/empty.cc: >Fix year range in copyright header. > > OK for trunk? Ok.
[committed] API change for internal get_range_strlen
This changes the internal API for get_range_strlen to use c_strlen_data rather than passing in the tree[2] for min/max length plus the tree * for the nonstr object. It also initializes the "maxbound" member within the c_strlen data object. The publicly visible interface to get_range_strlen doesn't change at this point. The public routine does the simple translation between the existing external API and new internal API. As with previous patches, this should not change any visible behavior. Bootstrapped and regression tested on x86_64-linux-gnu. My tester will churn through it on the other targets through the day. Installing on the trunk momentarily. Jeff * gimple-fold.c (get_range_strlen): Update prototype. (get_range_strlen_tree): Update prototype. Drop minlen/maxlen local variables. Use pdata to return information to caller. Update calls to get_range_strlen. Update pdata->maxbound. (get_range_strlen -- static version): Similarly. (get_range_strlen -- extern version): Update for internal get_range_strlen API change. Convert to external data format. (get_maxval_strlen): Similarly. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 3e7cbfd61e1..5e29f79ee09 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -83,8 +83,8 @@ enum strlen_range_kind { SRK_INT_VALUE }; -static bool get_range_strlen (tree, tree[2], bitmap *, strlen_range_kind, - bool *, unsigned, tree *); +static bool get_range_strlen (tree, bitmap *, strlen_range_kind, + c_strlen_data *, bool *, unsigned); /* Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. @@ -1281,16 +1281,13 @@ gimple_fold_builtin_memset (gimple_stmt_iterator *gsi, tree c, tree len) /* Helper of get_range_strlen for ARG that is not an SSA_NAME. */ static bool -get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, +get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, - bool *flexp, unsigned eltsize, tree *nonstr) + c_strlen_data *pdata, + bool *flexp, unsigned eltsize) { gcc_assert (TREE_CODE (arg) != SSA_NAME); - /* The minimum and maximum length. */ - tree *const minlen = length; - tree *const maxlen = length + 1; - /* The length computed by this invocation of the function. */ tree val = NULL_TREE; @@ -1304,9 +1301,8 @@ get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, tree aop0 = TREE_OPERAND (op, 0); if (TREE_CODE (aop0) == INDIRECT_REF && TREE_CODE (TREE_OPERAND (aop0, 0)) == SSA_NAME) - return get_range_strlen (TREE_OPERAND (aop0, 0), length, -visited, rkind, flexp, -eltsize, nonstr); + return get_range_strlen (TREE_OPERAND (aop0, 0), visited, +rkind, pdata, flexp, eltsize); } else if (TREE_CODE (TREE_OPERAND (op, 0)) == COMPONENT_REF && (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2)) @@ -1344,9 +1340,9 @@ get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, bubble that information up to the caller. */ if (!val && lendata.decl) { - *nonstr = lendata.decl; - *minlen = lendata.minlen; - *maxlen = lendata.minlen; + pdata->decl = lendata.decl; + pdata->minlen = lendata.minlen; + pdata->maxlen = lendata.minlen; return rkind == SRK_STRLEN ? false : true; } } @@ -1354,9 +1350,8 @@ get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, if (!val && (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2)) { if (TREE_CODE (arg) == ADDR_EXPR) - return get_range_strlen (TREE_OPERAND (arg, 0), length, -visited, rkind, flexp, -eltsize, nonstr); + return get_range_strlen (TREE_OPERAND (arg, 0), visited, rkind, +pdata, flexp, eltsize); if (TREE_CODE (arg) == ARRAY_REF) { @@ -1383,7 +1378,7 @@ get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, /* Set the minimum size to zero since the string in the array could have zero length. */ - *minlen = ssize_int (0); + pdata->minlen = ssize_int (0); if (TREE_CODE (TREE_OPERAND (arg, 0)) == COMPONENT_REF && optype == TREE_TYPE (TREE_OPERAND (arg, 0)) @@ -1423,7 +1418,7 @@ get_range_strlen_tree (tree arg, tree length[2], bitmap *visited, /* Set the minimum size to zero since the string in the array could have zero length. */ - *minlen = ssize_int (0); + pdata->minlen = ssize_int (0); }
Re: Fix devirtualiation in expanded thunks
On Dez 31 2018, Martin Liška wrote: > -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual > function call to virtual unsigned int mozPersonalDictionary::_ZThn16" "dom3" > } } */ > -/* { dg-final-use-not-autofdo { scan-ipa-dump-times 3 "folding virtual > function call to virtual unsigned int mozPersonalDictionary::AddRef" "dom3" } > } */ > +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual > function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 > "dom3" } } */ > +/* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual > function call to virtual unsigned int mozPersonalDictionary::AddRef" 3 "dom3" > } } */ New tests that FAIL (1 tests): unix/-mabi=ilp32: g++.dg/tree-prof/devirt.C scan-tree-dump-times dom3 "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 3 Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: Fix unresolved tests I introduced into g++.dg/lto
Hi, this patch does housekeeping for ipa directory. I still plan to port more of the non-LTO testcases into LTO variant (to be sure LTO devirtualization works same way as non-LTO) but will do that after handling bugs and other higher priority tasks. Honza * g++.dg/ipa/devirt-36.C: Add dg-do-compile. * g++.dg/ipa/devirt-53.C: Fix scan template. Index: g++.dg/ipa/devirt-36.C === --- g++.dg/ipa/devirt-36.C (revision 267494) +++ g++.dg/ipa/devirt-36.C (working copy) @@ -1,3 +1,4 @@ +/* { dg-do compile } */ /* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */ struct A {virtual int t(void) {return 1;}}; struct B:A {B(); virtual int t(void) {return 2;}}; Index: g++.dg/ipa/devirt-53.C === --- g++.dg/ipa/devirt-53.C (revision 267494) +++ g++.dg/ipa/devirt-53.C (working copy) @@ -55,4 +55,4 @@ void fn1() { q(new f::L).s(v); } /* Check that f::d appears as possible target. */ -/* { dg-final { scan-tree-dump "f::d" "fre" } } */ +/* { dg-final { scan-tree-dump "f::d" "fre1" } } */
Fix unresolved tests I introduced into g++.dg/lto
Hi, this patch fixes the unresolved tests i accidentally introduced to lto directory. I ended up droping the tree scan for now as I do not know how to get that working and both testcases also tests runtime. Honza * g++.dg/lto/devirt-13_0.C: Drop broken scan of ssa dump. * g++.dg/lto/devirt-14_0.C: Drop broken scan of ssa dump. * g++.dg/lto/devirt-23_0.C: Add -fdump-ipa-cp. Index: g++.dg/lto/devirt-13_0.C === --- g++.dg/lto/devirt-13_0.C(revision 267494) +++ g++.dg/lto/devirt-13_0.C(working copy) @@ -1,5 +1,5 @@ /* { dg-lto-do run } */ /* Call to foo should be devirtualized because there are no derived types of A. */ -/* { dg-lto-options "-O2 -flto -fdump-tree-ssa" } */ +/* { dg-lto-options "-O2 -flto" } */ #include "../ipa/devirt-13.C" -/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "ssa"} } */ +/* Ideally we should also { scan-tree-dump-times "OBJ_TYPE_REF" 0 "ssa"}. */ Index: g++.dg/lto/devirt-14_0.C === --- g++.dg/lto/devirt-14_0.C(revision 267494) +++ g++.dg/lto/devirt-14_0.C(working copy) @@ -1,4 +1,4 @@ /* { dg-lto-do run } */ /* { dg-lto-options "-O2 -fdump-tree-ssa" } */ #include "../ipa/devirt-14.C" -/* { dg-final { scan-tree-dump-not "A.*foo" "ssa"} } */ +/* Ideally we should also { scan-tree-dump-not "A.*foo" "ssa"} } */ Index: g++.dg/lto/devirt-23_0.C === --- g++.dg/lto/devirt-23_0.C(revision 267494) +++ g++.dg/lto/devirt-23_0.C(working copy) @@ -1,4 +1,4 @@ /* { dg-lto-do run } */ -/* { dg-lto-options { "-O3 -fno-early-inlining -fno-ipa-sra -flto -fno-devirtualize-speculatively" } } */ +/* { dg-lto-options { "-O3 -fno-early-inlining -fno-ipa-sra -fdump-ipa-cp -flto -fno-devirtualize-speculatively" } } */ #include "../ipa/devirt-23.C" /* { dg-final { scan-wpa-ipa-dump "Discovered a virtual call to" "cp" { xfail *-*-* } } } */
Fix profiling of thunks
Hi, this patch fixes second problem demonstrated by testcase Jakub reduced from firefox where we inline agressively into thunks. This is because we have no profile and inliner priorities are not really comparable. I will need to look into that case, but this patch adds the missing profile. This is also important to get indirect call profiling right. Profiled-bootstrapped/regtested x86_64-linux, comitted. Honza * coverage.c (get_coverage_counts): Use current_function_decl. * profile.c (read_thunk_profile): New function. (branch_prob): Add THUNK parameter. * tree-profile.c (tree_profiling): Handle thunks. * value-prof.c (init_node_map): Handle thunks. * value-prof.h (branch_prob): Upate prototype. (read_thunk_profile): Declare. * g++.dg/tree-prof/devirt.C: Update testcase. Index: coverage.c === --- coverage.c (revision 267488) +++ coverage.c (working copy) @@ -329,7 +329,7 @@ get_coverage_counts (unsigned counter, u else { gcc_assert (coverage_node_map_initialized_p ()); - elt.ident = cgraph_node::get (cfun->decl)->profile_id; + elt.ident = cgraph_node::get (current_function_decl)->profile_id; } elt.ctr = counter; entry = counts_hash->find (); Index: profile.c === --- profile.c (revision 267488) +++ profile.c (working copy) @@ -963,6 +963,25 @@ compare_freqs (const void *p1, const voi return e2->dest->index - e1->dest->index; } +/* Only read execution count for thunks. */ + +void +read_thunk_profile (struct cgraph_node *node) +{ + tree old = current_function_decl; + current_function_decl = node->decl; + gcov_type *counts = get_coverage_counts (GCOV_COUNTER_ARCS, 0, 0, 1); + if (counts) +{ + node->callees->count = node->count += profile_count::from_gcov_type (counts[0]); + free (counts); +} + current_function_decl = old; + return; +} + + /* Instrument and/or analyze program behavior based on program the CFG. This function creates a representation of the control flow graph (of @@ -983,7 +1002,7 @@ compare_freqs (const void *p1, const voi Main entry point of this file. */ void -branch_prob (void) +branch_prob (bool thunk) { basic_block bb; unsigned i; @@ -1000,118 +1019,121 @@ branch_prob (void) hash_set streamed_locations; - /* We can't handle cyclic regions constructed using abnormal edges. - To avoid these we replace every source of abnormal edge by a fake - edge from entry node and every destination by fake edge to exit. - This keeps graph acyclic and our calculation exact for all normal - edges except for exit and entrance ones. - - We also add fake exit edges for each call and asm statement in the - basic, since it may not return. */ - - FOR_EACH_BB_FN (bb, cfun) + if (!thunk) { - int need_exit_edge = 0, need_entry_edge = 0; - int have_exit_edge = 0, have_entry_edge = 0; - edge e; - edge_iterator ei; + /* We can't handle cyclic regions constructed using abnormal edges. +To avoid these we replace every source of abnormal edge by a fake +edge from entry node and every destination by fake edge to exit. +This keeps graph acyclic and our calculation exact for all normal +edges except for exit and entrance ones. - /* Functions returning multiple times are not handled by extra edges. - Instead we simply allow negative counts on edges from exit to the - block past call and corresponding probabilities. We can't go - with the extra edges because that would result in flowgraph that -needs to have fake edges outside the spanning tree. */ +We also add fake exit edges for each call and asm statement in the +basic, since it may not return. */ - FOR_EACH_EDGE (e, ei, bb->succs) + FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator gsi; - gimple *last = NULL; + int need_exit_edge = 0, need_entry_edge = 0; + int have_exit_edge = 0, have_entry_edge = 0; + edge e; + edge_iterator ei; + + /* Functions returning multiple times are not handled by extra edges. +Instead we simply allow negative counts on edges from exit to the +block past call and corresponding probabilities. We can't go +with the extra edges because that would result in flowgraph that +needs to have fake edges outside the spanning tree. */ - /* It may happen that there are compiler generated statements -without a locus at all. Go through the basic block from the -last to the first statement looking for a locus. */ - for (gsi = gsi_last_nondebug_bb (bb); - !gsi_end_p (gsi); - gsi_prev_nondebug ()) + FOR_EACH_EDGE (e,
[committed] contrib/update-copyright.py --this-year
Hi! See r267494 for details, the patch is way too large. I've also rotated a bunch of ChangeLog files. Jakub
[committed] Tweak update-copyright.py
Hi! update-copyright.py failed because of unknown copyright holder in one of the libstdc++ files. Fixed thusly, committed as obvious: 2019-01-01 Jakub Jelinek * update-copyright.py: Add Gerard Jungman as external author. --- contrib/update-copyright.py.jj 2018-11-28 09:45:11.628717994 +0100 +++ contrib/update-copyright.py 2019-01-01 12:45:24.639976573 +0100 @@ -686,6 +686,7 @@ class GCCCopyright (Copyright): self.add_external_author ('Cavium Networks.') self.add_external_author ('Faraday Technology Corp.') self.add_external_author ('Florida State University') +self.add_external_author ('Gerard Jungman') self.add_external_author ('Greg Colvin and Beman Dawes.') self.add_external_author ('Hewlett-Packard Company') self.add_external_author ('Intel Corporation') Jakub
[committed] Update copyright years
Hi! Happy New Year to everyone! 2019-01-01 Jakub Jelinek * gcc.c (process_command): Update copyright notice dates. * gcov-dump.c (print_version): Ditto. * gcov.c (print_version): Ditto. * gcov-tool.c (print_version): Ditto. * gengtype.c (create_file): Ditto. * doc/cpp.texi: Bump @copying's copyright year. * doc/cppinternals.texi: Ditto. * doc/gcc.texi: Ditto. * doc/gccint.texi: Ditto. * doc/gcov.texi: Ditto. * doc/install.texi: Ditto. * doc/invoke.texi: Ditto. gcc/fortran/ * gfortranspec.c (lang_specific_driver): Update copyright notice dates. * gfc-internals.texi: Bump @copying's copyright year. * gfortran.texi: Ditto. * intrinsic.texi: Ditto. * invoke.texi: Ditto. gcc/go/ * gccgo.texi: Bump @copyrights-go year. gcc/ada/ * gnat_ugn.texi: Bump @copying's copyright year. * gnat_rm.texi: Likewise. gcc/d/ * gdc.texi: Bump @copyrights-d year. libitm/ * libitm.texi: Bump @copying's copyright year. libgomp/ * libgomp.texi: Bump @copying's copyright year. libquadmath/ * libquadmath.texi: Bump @copying's copyright year. --- libitm/libitm.texi (revision 256165) +++ libitm/libitm.texi (revision 256166) @@ -7,7 +7,7 @@ @copying -Copyright @copyright{} 2011-2018 Free Software Foundation, Inc. +Copyright @copyright{} 2011-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or --- libgomp/libgomp.texi(revision 256165) +++ libgomp/libgomp.texi(revision 256166) @@ -7,7 +7,7 @@ @copying -Copyright @copyright{} 2006-2018 Free Software Foundation, Inc. +Copyright @copyright{} 2006-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or --- libquadmath/libquadmath.texi(revision 256165) +++ libquadmath/libquadmath.texi(revision 256166) @@ -6,7 +6,7 @@ @c %**end of header @copying -Copyright @copyright{} 2010-2018 Free Software Foundation, Inc. +Copyright @copyright{} 2010-2019 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document --- gcc/doc/cpp.texi(revision 256165) +++ gcc/doc/cpp.texi(revision 256166) @@ -10,7 +10,7 @@ @copying @c man begin COPYRIGHT -Copyright @copyright{} 1987-2018 Free Software Foundation, Inc. +Copyright @copyright{} 1987-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or --- gcc/doc/gcc.texi(revision 256165) +++ gcc/doc/gcc.texi(revision 256166) @@ -40,7 +40,7 @@ @c %**end of header @copying -Copyright @copyright{} 1988-2018 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or --- gcc/doc/cppinternals.texi (revision 256165) +++ gcc/doc/cppinternals.texi (revision 256166) @@ -18,7 +18,7 @@ @ifinfo This file documents the internals of the GNU C Preprocessor. -Copyright (C) 2000-2018 Free Software Foundation, Inc. +Copyright (C) 2000-2019 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -47,7 +47,7 @@ into another language, under the above c @page @vskip 0pt plus 1filll @c man begin COPYRIGHT -Copyright @copyright{} 2000-2018 Free Software Foundation, Inc. +Copyright @copyright{} 2000-2019 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice --- gcc/doc/gccint.texi (revision 256165) +++ gcc/doc/gccint.texi (revision 256166) @@ -26,7 +26,7 @@ @c %**end of header @copying -Copyright @copyright{} 1988-2018 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or --- gcc/doc/invoke.texi (revision 256165) +++ gcc/doc/invoke.texi (revision 256166) @@ -8,7 +8,7 @@ @c man end @c man begin COPYRIGHT -Copyright @copyright{} 1988-2018 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or --- gcc/doc/gcov.texi (revision 256165) +++ gcc/doc/gcov.texi (revision 256166) @@ -4,7 +4,7 @@ @ignore @c man begin