[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>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 11 Sep 2023 10:59:46 +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=Ga+XuRzbufw66ZoM84Ke2eonqarSoIkRltvF+VB1wck=; b=muilFuK84OVQ7klE90jHf7RtvVv0XrXQ4bw8pt32nt/AIOhFAXg3VMk9Ka5k2dQDqXRpIcNBqriYvpcx63rLvk9a9WDIvg9ItUijKQjN8sl0F1NwMgiZhOd/kVfoHK0kPWPCt15Rhe9gZf/ltthPKzbUTyofslZQzOKbMAJh1ato7xgY83dMxxZfgaX+CnlIhskm4Dp47PXoLoe66ZLOLJe9kpBm9NXVi7BA4lY82f2FojlN66TuFMS5SyDIrsmxj2nx4enoiEuQKiQsAEf2P51xIaXO+IGZP3ro//rfgA+ZOMW7QNm4LpbY7yPoAY/zvyYXPehEEkjY5KNTAyK8Bg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uc3bUoUKb2njMwA9wTBOTEzrKV8DTSoy275aR4cjapyWeTknQ5VF1ehtFJN9awbZgv9V3VkrBHddnjtqycKtfOHJSGopUoDWOnP+3UUJ8qc0Y2s7tZoAdtocZr+eZJieeoKVSP0MDiuersmxyarztuNOfq3wzh+UtQrGdxJkM0NzLeSZU6mXze6ipHgIWfG/cZFfzBwpuFniDf+eFUuX+E357B9WcRNMKcqxAVNzMM0h39A3XI+/CrszwhsJ5fuWK+H3kAdasaWrjpDcWJFD1mB5CL4xDLj/tQtbWyX4tBe7Oo4QmVlEz5zpt3hYFblQLwblkG4z0cQk/BOfLJMQfw==
  • 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, Javi Merino <javi.merino@xxxxxxxxx>
  • Delivery-date: Mon, 11 Sep 2023 10:00:08 +0000
  • Ironport-data: A9a23:tNERt6LESFYrCteZFE+RMpQlxSXFcZb7ZxGr2PjKsXjdYENS1GdRy mMcWW6OOPuMMDb0eYwgPoS08klVuZODy4QwQFFlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAhk/nOHvylULKs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrZwP9TlK6q4mhA7wVmPasjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5sDX0Q9 v8kcwovVUiEi/6E+5O0DfRj05FLwMnDZOvzu1lG5BSBV7MdZ8mGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dopTSNpOBy+OGF3N79U9qGX8hK2G2fo XrL5T/RCRAGLt2PjzGC9xpAg8eWx3mlBtpCTO3QGvhCmFqQxzw3GEMsRHi5nN+DuB+5C45dA hlBksYphe1onKCxdfH/VRClpH+PvjYHRsFdVeY97WmlyLfQ4gufLngJSHhGctNOnNQtWTUg2 1uNntXoLT9iqruYTTSa7Lj8hSy2ETgYKykFfyBsZRsI5ZzvrZ8+ijrLT81/C+ilg9vtAzbyz juW6i8kiN07j8cV1uO+8ErGhTWErZzOUwJz7QLSNl9J9St8bY+hIpeusF7S6K4aKJ7DFgXf+ n8Zh8KZ8eYCS4mXkzCAS/kMG7fv4OuZNDrbghhkGJxJGymRxkNPtLt4uFlWTHqF+O5dEdM1S Cc/YT9s2aI=
  • Ironport-hdrordr: A9a23:WFtD2aMgI2V4fsBcTjejsMiBIKoaSvp037BK7S1MoNJuEvBw9v re+sjzsCWftN9/Yh4dcLy7VpVoBEmsl6KdgrNhWotKPjOW21dARbsKheffKn/bakjDH4Zmvp uIGJIObOEYY2IasS77ijPIbOrJwrO8gd6VbTG19QYdceloAZsQnzuQEmygYzRLrJEtP+tFKH KbjPA33waISDAsQemQIGIKZOTHr82jruObXfZXbyRXkzVnlFmTmcTHLyQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11/09/2023 10:53 am, Jan Beulich wrote:
> On 11.09.2023 11:48, Andrew Cooper wrote:
>> 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.
> Hmm, even in forward order one prior #elif will need touching

 #if GCC_VERSION < 40700
 #define GCOV_COUNTERS 8
 #elif GCC_VERSION < 40900
 #define GCOV_COUNTERS 9
 #elif GCC_VERSION < 50000
 #define GCOV_COUNTERS 10
 #elif GCC_VERSION < 70000
 #define GCOV_COUNTERS 9
+#elif GCC_VERSION < FOO
+#define GCOV_COUNTERS BAR
 #else
 #error "Wrong version of GCC used to compile gcov"
 #endif

~Andrew



 


Rackspace

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