[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] Support LLVM raw profile versions 5, 6, 7, 8, 9, and 10


  • To: Saman Dehghan <samaan.dehghan@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 24 Oct 2025 10:33:30 +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=arcselector10001; 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=dm+4Pwx3kYjB7jxJ5WDHiU+ptwFy4CZJqJGq6BBHl7I=; b=acABWsAKJEU/Ztj+NOfE9HTH6ZnPGe3vr76Tz1u6ccQYOspgbxMOn9dEMVyGiL+X4j8TV7X2SOHcUwp3prDVKtSM6GOWgZ6qCpBoBxBmH7ItsTDvXx3FmKamYE4vW9f+ntGU7w/Divwq1UPVntmfKG0SoC6wLwowGbVb7C563100WrHv9Jor5VgNYdRY7iRnaRl25U5InKhti5SyY2vJIjH5k+GUvcNMq1yc8TBVJwEtOy2m5k+CijS5rvriQdAm9pEloKJCCOSQnSoKgDoIYP223ikKwbJQgvBJ7A6h+kG78y10aPe03gsI1M+VbVYu1YybttC5gw0rEFvnGnVvQg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I1qa26IYjxb9lo81WV4FvieU+gNBQxXwG7ZrApp2+cQks+JUSWO93C4fz66RBC54L+y7WpaEwNSjc/2I3VpiYnl7ZAOQIgulxqK80aVHMGMdo/9V9OThNPWk7AcbDk/J6EcpviJFDdmLc8j6OgYkxwO9+Vd7L8xDiCuwsDizQ4gFoEowiWzjFtwv7NZMk5xxM5YTdgjnkKZ6fmWB8vnUmPgG0icdl1M9JS5fxPisIwh57e9MFpwYnGGsTE01mJGg7c0zHoGF5nQgKb0eQpi79ZICijh7hS3kI+EOD4w+5IoEGRaFCG4Oy5YIDWHkDmBPtxecHDdzNc7QpxyH4cC9GQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Wentao Zhang <wentaoz5@xxxxxxxxxxxx>, Matthew L Weber <matthew.l.weber3@xxxxxxxxxx>
  • Delivery-date: Fri, 24 Oct 2025 09:33:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The subject should have a "xen: " prefix, as this applies to the
hypervisor and not other

On 24/10/2025 1:16 am, Saman Dehghan wrote:
> This change enables compatibility for measuring code coverage
> with Clang versions 14 through 20 by supporting their

Stale 14?  It looks to be 11 now.

> respective raw profile formats.
>
> 1- Added support for LLVM raw profile versions 5, 6, 7, 8, 9, and 10.
> 2- Initialized llvm_profile_header for all versions based on llvm source code 
> in
>    compiler-rt/include/profile/InstrProfData.inc for each version.
> 3- We tested this patch for all Clang versions from 11 through 20 on x86 
> platform.
> 4- Fixed linking warnings related to coverage code in x86.
>
> Signed-off-by: Saman Dehghan <samaan.dehghan@xxxxxxxxx>
> ---

When sending multiple revisions, it's customary to put a short list here
if what you've changed from the previous revision.

Also, you didn't accumulate your release ack from v2.

Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>

>  xen/arch/x86/xen.lds.S     |  6 ++++
>  xen/common/coverage/llvm.c | 73 ++++++++++++++++++++++++++++++++++----
>  xen/include/xen/xen.lds.h  | 18 ++++++++++
>  3 files changed, 91 insertions(+), 6 deletions(-)
>
> diff --git a/xen/common/coverage/llvm.c b/xen/common/coverage/llvm.c
> index 517b2aa8c2..e3272a546f 100644
> --- a/xen/common/coverage/llvm.c
> +++ b/xen/common/coverage/llvm.c
> @@ -107,11 +145,34 @@ static int cf_check dump(
>      struct llvm_profile_header header = {
>          .magic = LLVM_PROFILE_MAGIC,
>          .version = LLVM_PROFILE_VERSION,
> -        .data_size = (END_DATA - START_DATA) / sizeof(struct 
> llvm_profile_data),
> -        .counters_size = (END_COUNTERS - START_COUNTERS) / sizeof(uint64_t),
> +#if __clang_major__ >= 13
> +        .binary_ids_size = 0,
> +#endif
> +        .num_data = ((END_DATA + sizeof(struct llvm_profile_data) - 1)
> +                - START_DATA) / sizeof(struct llvm_profile_data),

There's a helper for this expression.

DIV_ROUND_UP(END_DATA - START_DATA, sizeof(llvm_profile_data))

> +        .padding_bytes_before_counters = 0,
> +        .num_counters = ((END_COUNTERS + sizeof(uint64_t) - 1)
> +                - START_COUNTERS) / sizeof(uint64_t),

DIV_ROUND_UP(END_COUNTERS - START_COUNTERS, sizeof(uint64_t))


> +        .padding_bytes_after_counters = 0,
> +#if __clang_major__ >= 18
> +        .num_bitmap_bytes = 0,
> +        .padding_bytes_after_bitmap_bytes = 0,
> +#endif
>          .names_size = END_NAMES - START_NAMES,
> +#if __clang_major__ >= 14
> +        .counters_delta = START_COUNTERS - START_DATA,
> +#else
>          .counters_delta = (uintptr_t)START_COUNTERS,
> +#endif
> +
> +#if __clang_major__ >= 18
> +        .bitmap_delta = 0,
> +#endif
>          .names_delta = (uintptr_t)START_NAMES,
> +#if __clang_major__ >= 19 && __clang_major__ <= 20
> +        .num_vtables = 0,
> +        .vnames_size = 0,
> +#endif

Because this is a structure initialiser, everything set explicitly to 0
can be omitted.  This removes all #ifdef-ary except the .counters_delta
I believe, as well as the .padding_byte_* fields.

The resulting diff is far smaller.

>          .value_kind_last = LLVM_PROFILE_NUM_KINDS - 1,
>      };
>      unsigned int off = 0;
> diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
> index b126dfe887..42550a85a2 100644
> --- a/xen/include/xen/xen.lds.h
> +++ b/xen/include/xen/xen.lds.h
> @@ -81,6 +81,24 @@
>    .stab.index 0 : { *(.stab.index) }         \
>    .stab.indexstr 0 : { *(.stab.indexstr) }
>  
> +#if defined(CONFIG_COVERAGE) && defined(CONFIG_CC_IS_CLANG)
> +
> +#define LLVM_COV_RW_DATA                                   \
> +    DECL_SECTION(__llvm_prf_cnts) { *(__llvm_prf_cnts) }   \
> +    DECL_SECTION(__llvm_prf_data) { *(__llvm_prf_data) }   \
> +    DECL_SECTION(__llvm_prf_bits) { *(__llvm_prf_bits) }
> +
> +#define LLVM_COV_RO_DATA                                   \
> +    DECL_SECTION(__llvm_prf_names) { *(__llvm_prf_names) }
> +
> +#define LLVM_COV_DEBUG                                     \
> +    DECL_DEBUG(__llvm_covfun, 8)                           \
> +    DECL_DEBUG(__llvm_covmap, 8)
> +#else
> +#define LLVM_COV_RW_DATA
> +#define LLVM_COV_RO_DATA
> +#define LLVM_COV_DEBUG
> +#endif

Newline here.

But, there's no problem stating sections which are unused.  I think the
outer #if/#else can be dropped.

Otherwise, Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

I can fix these all up on commit, seeing as it's release acked for 4.21

~Andrew



 


Rackspace

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