From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF93E3858D3C; Mon, 24 Jan 2022 10:53:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF93E3858D3C From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/104158] [12 Regression] gcc no longer accepts -fsanitize-coverage=trace-pc,trace-cmp since r12-1177 Date: Mon, 24 Jan 2022 10:53:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2022 10:53:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104158 --- Comment #8 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:385196adb52d854ebf4f9237e8a521a17c5524c5 commit r12-6839-g385196adb52d854ebf4f9237e8a521a17c5524c5 Author: Jakub Jelinek Date: Mon Jan 24 11:50:15 2022 +0100 options: Add EnumSet and Set property support [PR104158] The following patch is infrastructure support for at least 3 different options that need changes: 1) PR104158 talks about a regression with the -fsanitizer-coverage=3D option; in GCC 11 and older and on trunk prior to r12-1177, this option behaved similarly to -f{,no-}sanitizer{,-recover}=3D options, namely that the option allows negative and argument of the option is a list of strings, each of them has some enumerator and -fsanitize-coverage=3D enabled those bits in the underlying flag_sanitize_coverage, while -fno-sanitize-coverage=3D disabled the= m. So, -fsanitize-coverage=3Dtrace-pc,trace-cmp was equivalent to -fsanitize-coverage=3Dtrace-pc -fsanitize-coverage=3Dtrace-cmp and b= oth set flag_sanitize_coverage to (SANITIZE_COV_TRACE_PC | SANITIZE_COV_TRACE_CMP) Also, e.g. -fsanitize-coverage=3Dtrace-pc,trace-cmp -fno-sanitize-coverage=3Dtr= ace-pc would in the end set flag_sanitize_coverage to SANITIZE_COV_TRACE_CMP (first set both bits, then subtract one) The r12-1177 change, I think done to improve argument misspelling diagnostic, changed the option incompatibly in multiple ways, -fno-sanitize-coverage=3D is now rejected, only a single argument is allowed, not multiple and -fsanitize-coverage=3Dtrace-pc -fsanitize-coverage=3Dtrace-cmp enables just SANITIZE_COV_TRACE_CMP and not both (each option overrides the previous value) 2) Thomas Koenig wants to extend Fortran -fconvert=3D option for the ppc64le real(kind=3D16) swapping support; currently the option accepts -fconvert=3D{native,swap,big-endian,little-endian} and the intent is to add support for -fconvert=3Dr16_ibm and -fconvert=3Dr16= _ieee (that alone is just normal Enum), but also to handle -fconvert=3Dswap,r16_ieee or -fconvert=3Dr16_ieee,big-endian but not -fconvert=3Dbig-endian,little-endian - the native/swap/big-endian/little-endian are one mutually exclusive set and r16_ieee/r16_ibm another one. See https://gcc.gnu.org/pipermail/gcc-patches/2022-January/587943.ht= ml and thread around that. 3) Similarly Marek Polacek wants to extend the -Wbidi-chars=3D option, such that it will handle not just the current -Wbidi-chars=3D{none,bidirectional,any}, but also -Wbidi-chars=3Ducn and bidirectional,ucn and ucn,any etc. Again two separate sets, one none/bidirectional/any and another one ucn. See https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588960.ht= ml The following patch adds framework for this and I'll post incremental patches for 1) and 2). As I've tried to document, such options are marked by additional EnumSet property on the option and in that case all the EnumValues in the Enum referenced from it must use a new Set property with set number (initially I wanted just mark last enumerator in each mutually exclusive set, but optionlist is sorted and so it doesn't really work well). So e.g. for the Fortran -fconvert=3D, one specifies: fconvert=3D Fortran RejectNegative Joined Enum(gfc_convert) EnumSet Var(flag_conver= t) Init(GFC_FLAG_CONVERT_NATIVE) -fconvert=3D = The endianness used for unformatted files. Enum Name(gfc_convert) Type(enum gfc_convert) UnknownError(Unrecognized opti= on to endianness value: %qs) EnumValue Enum(gfc_convert) String(big-endian) Value(GFC_FLAG_CONVERT_BIG) Set(1) EnumValue Enum(gfc_convert) String(little-endian) Value(GFC_FLAG_CONVERT_LITTLE) Set(1) EnumValue Enum(gfc_convert) String(native) Value(GFC_FLAG_CONVERT_NATIVE) Set(1) EnumValue Enum(gfc_convert) String(swap) Value(GFC_FLAG_CONVERT_SWAP) Set(1) EnumValue Enum(gfc_convert) String(r16_ieee) Value(GFC_FLAG_CONVERT_R16_IEEE) Set= (2) EnumValue Enum(gfc_convert) String(r16_ibm) Value(GFC_FLAG_CONVERT_R16_IBM) Set(2) and this says to the option handling code that 1) if only one arg is specified to one instance of the option, it can be any of those 6 2) if two args are specified, one has to be from the first 4 and another from the last 2, in any order 3) at most 2 args may be specified (there are just 2 sets) There is a requirement on the Value values checked in self-test, the values from one set ored together must be disjunct from values from another set ored together. In the Fortran case, the first 4 are 0-3 so mask is 3, and the last 2 are 4 and 8, so mask is 12. When say -fconvert=3Dbig-endian is specified, it sets the first set to GFC_FLAG_CONVERT_BIG (2) but doesn't modify whatever value the other set had, so e.g. -fconvert=3Dbig-endian -fconvert=3Dr16_ieee -fconvert=3Dr16_ieee -fconvert=3Dbig-endian -fconvert=3Dr16_ieee,big_endian -fconvert=3Dbig_endian,r16_ieee all behave the same. Also, with the EnumSet support, it is now possible to allow not specifying RejectNegative - we can set some set's value and then clear it and set it again to some other value etc. I think with the 2) patch I achieve what we want for Fortran, for 1) the only behavior from gcc 11 is that -fsanitize-coverage=3Dtrace-cmp,trace-cmp is now rejected. This is mainly from the desire to disallow -fconvert=3Dbig-endian,little-endian or -Wbidi-chars=3Dbidirectional,any etc. where it would be confusing to users what exactly it means. But it is the only from these options that actually acts as an Enum bit set, each enumerator can be specified with all the others. So one option would be stop requiring the EnumSet implies Set properties must be specified and just require that either they are specified on all EnumValues, or on none of them; the latter case would be for -fsanitize-coverage=3D and the non-Set case would mean that all the EnumValues need to have disjoint Value bitmasks and that they can be all specified and unlike the Set case also repeated. Thoughts on this? 2022-01-24 Jakub Jelinek PR sanitizer/104158 * opt-functions.awk (var_set): Handle EnumSet property. * optc-gen.awk: Don't disallow RejectNegative if EnumSet is specified. * opt-read.awk: Handle Set property. * opts.h (CL_ENUM_SET_SHIFT, CL_ERR_ENUM_SET_ARG): Define. (struct cl_decoded_option): Mention enum in value description. Add mask member. (set_option): Add mask argument defaulted to 0. * opts.cc (test_enum_sets): New function. (opts_cc_tests): Call it. * opts-common.cc (enum_arg_to_value): Change return argument from bool to int, on success return index into the cl_enum_arg array, on failure -1. Add len argument, if non-0, use strncmp instead of strcmp. (opt_enum_arg_to_value): Adjust caller. (decode_cmdline_option): Handle EnumSet represented as CLVC_ENUM with non-zero var_value. Initialize decoded->mask. (decode_cmdline_options_to_array): CLear opt_array[0].mask. (handle_option): Pass decoded->mask to set_options last argumen= t. (generate_option): Clear decoded->mask. (generate_option_input_file): Likewise. (cmdline_handle_error): Handle CL_ERR_ENUM_SET_ARG. (set_option): Add mask argument, use it for CLVC_ENUM. (control_warning_option): Adjust enum_arg_to_value caller. * doc/options.texi: Document Set and EnumSet properties.=