[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
- To: Jan Beulich <jbeulich@xxxxxxxx>, Javi Merino <javi.merino@xxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Mon, 11 Sep 2023 10:48:34 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k4z010ckneWoQ/A6gRHVXyG5/QDC6JofM0AtgN0BeO0=; b=FkvasmuDCf1Z/DOnyis6gdNVNDOTn3Bcm9wO+HPHRGIs3/HaN2+vnIKyRKETw8z66tflSkoIu5RFS420m7sTu9NWzPnZE0STVrA/r7NSIYtGzYSliCGYiLE2IYLmnhi9fiG8Lg0U3n1vYYmiRxOVUAdZBa8tibP8qkA1NQBQ6RyMHfYqF7h/w6KfIMB+ZWf2LAofQT7G5+VPK7cZefeni71ZDg9ANc/fI6cJsx0vmNrhMGT70OMitN/uJRZWP71jZJqAEtsyJmHmc1NANAzaeTt5/Lu+4aM9sH9fQE4CvlxpxIF7kZ8LG6h7QhDLrVjFgjVnl7mVVOwxznlxxfbi8Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQJtaOPTrYHJHip4uNSnSbWtmqoys624PqBoykKECkWV/ufX2O0RLX+2N/awjWA5lO3BCt99jdxzlhAJLc6zcP2ASQwvLx7dfqa19kj1yHEnGBZn+BiXb7fUii8mXblaadj6v1S/5zG7hRdLpxFYHlrfKIJ76JDEcHgbJWvYTdL0bXFx8uzFsna2K5urUza0FWXhmu2CWUvhk4VvOF1DvqZbZ0LcEFYWnBwJJwZbv2ORpOTE12HrHPpcOXr8kqhdUSTSqTtBdT/4huoq0yWdmDvNFfPiBrjvgQz14DayelY/PBRZ91NduBkcZKJjiGsyc0mEcQ188I2lSgPf3/BP4w==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Mon, 11 Sep 2023 09:49:00 +0000
- Ironport-data: A9a23:0uOjD6wTLr676uUwoJl6t+faxyrEfRIJ4+MujC+fZmUNrF6WrkUEz GBJW2iGO63bNmP2fdB2PNu39RsBuMOBzdNnHgM+qyAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjPzOHvykTrecZkidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EkHUMja4mtC5QRvPKgT5zcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KUtz9 aZCCBYUVD+suu667J+UUeNigv12eaEHPKtH0p1h5RfwKK9+BLzmHeDN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvjiVlVQruFTuGIO9ltiibMNZhEuH4 EnB+Hz0GEoyP92D0zuVtHmrg4cjmAuiAthMSezorqcCbFu762wqOSNIfwuA4sako1CFavJQA G8+0397xUQ13AnxJjXnZDW6qnOZuh8XW/JLDvY3rgqKz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n0meHHlfFvTm5YQKZRqW4x+M+LJTn
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 11/09/2023 8:54 am, Jan Beulich wrote:
> On 08.09.2023 18:20, Javi Merino wrote:
>> The current structure of choosing the correct file based on the
>> compiler version makes us make 33 line files just to define a
>> constant. The changes after gcc 4.7 are minimal, just the number of
>> counters.
>>
>> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
>> remove a lot of the boilerplate and keep the logic of choosing the
>> GCOV_COUNTER in gcc_4_7.c.
>>
>> Signed-off-by: Javi Merino <javi.merino@xxxxxxxxx>
>> ---
>> xen/common/coverage/Makefile | 6 +-----
>> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
>> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
>> xen/common/coverage/gcc_5.c | 33 ---------------------------------
>> xen/common/coverage/gcc_7.c | 30 ------------------------------
>> 5 files changed, 10 insertions(+), 109 deletions(-)
>> delete mode 100644 xen/common/coverage/gcc_4_9.c
>> delete mode 100644 xen/common/coverage/gcc_5.c
>> delete mode 100644 xen/common/coverage/gcc_7.c
>>
>> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
>> index 63f98c71d6..d729afc9c7 100644
>> --- a/xen/common/coverage/Makefile
>> +++ b/xen/common/coverage/Makefile
>> @@ -1,11 +1,7 @@
>> obj-y += coverage.o
>> ifneq ($(CONFIG_CC_IS_CLANG),y)
>> obj-y += gcov_base.o gcov.o
>> -obj-y += $(call cc-ifversion,-lt,0407, \
>> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
>> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
>> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
>> - gcc_5.o, gcc_7.o))))
>> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
>> else
>> obj-y += llvm.o
>> endif
>> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
>> index 25b4a8bcdc..ddbc9f4bb0 100644
>> --- a/xen/common/coverage/gcc_4_7.c
>> +++ b/xen/common/coverage/gcc_4_7.c
>> @@ -18,15 +18,16 @@
>>
>> #include "gcov.h"
>>
>> -/*
>> - * GCOV_COUNTERS will be defined if this file is included by other
>> - * source files.
>> - */
>> -#ifndef GCOV_COUNTERS
>> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>> -# error "Wrong version of GCC used to compile gcov"
>> -# endif
>> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>> #define GCOV_COUNTERS 8
>> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
>> +#define GCOV_COUNTERS 9
>> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
>> +#define GCOV_COUNTERS 10
>> +#elif GCC_VERSION >= 70000
>> +#define GCOV_COUNTERS 9
>> +#else
>> +#error "Wrong version of GCC used to compile gcov"
>> #endif
> How about inverse order:
>
> #if GCC_VERSION >= 70000
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 50000
> #define GCOV_COUNTERS 10
> #elif GCC_VERSION >= 40900
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 40700
> #define GCOV_COUNTERS 8
> #else
> #error "Wrong version of GCC used to compile gcov"
> #endif
Forward order is the one that results in a smaller diff when inserting
new entries.
More importantly, it's the more natural way to structure such a list.
~Andrew
|