[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: Javi Merino <javi.merino@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Sep 2023 09:54:53 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=8ZiSXLeVFAdtRK2ZaQzhK7Z8qpa2d+a926zKVRu/02s=; b=L1slzabOceTPWhhoZmRgU1mn1rXEXD/2nYGbYnW2UccMkkJ9AiNMf+OewJsUYiS3qUYXFLPqtonb8gvj3mXVQNkJqfey3TS+RikSfRB5Psye27uwvCWAsaYnpofik/JY57P7W87/L4sp7h2kv7Gdhg6yy6CigdxcF9GWYUiNecDJAP8M6T8kjvYSqLuvcnISaci28ya1IIHNC2NH3MFypqFDz+/U9FvU4h+lQ7RXy+tUyxcuaNST16Der3C0ozUV/ThxG6GOunkH+Gcfn8W+/pTM3H9uQNsZXMDvAgnQc5nQiQkyFVr3ENlQVDokYdyWYUquLImcBjjndLuJC5xY3w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NG6FaREWGUQRi5mLxvuX4QzAbdXGLPC4d3yIboPwD3rqVN+WdSMVxW/7ZE82BqlGD36Fo2Z9v4wAtbuJnkPtR0L4R21l8NaaOgeK/k30kmZL2ldrSzMOfhGQDfoxWThPlhP/Qk9B7hFz4Pd3R8mNBpaPakiIvkyl0CwGP4S21ofR5AfYvPHBsCq+vtAy4ArRFIYiF+J8H7tggZ4kAW86LKEfvrrFbXilgS9w8zD269ArI4dbMHzq/7nv7HBh7VsMEn+byL5ecbGGM6ykqJAYeJ96DDcLqcgkVSgHFzw7JCoJAeAzp2QkwFXKnDKWH5zEGWvw18y/dXnWmOpIdXkbLQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, 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 07:55:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

Otherwise a nit and a question: Parentheses would want using consistently.
And wouldn't it make sense to combine the two ranges resulting in 9 being
chosen? (Imo in the alternative layout that's less desirable.)

Since the adjustment would be easy to make, I'd be fine doing so while
committing, and then
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

As an unrelated remark: gcc_3_4.c is clearly outdated as well, simply by
its name. Imo it would have wanted to be gcc_4_1.c the latest as of commit
03f22f0070f3 ("README: adjust gcc version requirement"), i.e. for over 10
years.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.