On 25.07.2024 12:56, Roger Pau Monne wrote:
> --- a/xen/arch/x86/include/asm/alternative.h
> +++ b/xen/arch/x86/include/asm/alternative.h
> @@ -184,11 +184,11 @@ extern void alternative_branches(void);
>   * https://github.com/llvm/llvm-project/issues/82598
>   */
>  #define ALT_CALL_ARG(arg, n)                                            \
> -    register union {                                                    \
> -        typeof(arg) e[sizeof(long) / sizeof(arg)];                      \
> -        unsigned long r;                                                \
> +    register struct {                                                   \
> +        typeof(arg) e;                                                  \
> +        char pad[sizeof(void *) - sizeof(arg)];                         \

One thing that occurred to me only after our discussion, and I then forgot
to mention this before you would send a patch: What if sizeof(void *) ==
sizeof(arg)? Zero-sized arrays are explicitly something we're trying to
get rid of.

I was wondering whether we could get away resorting to bitfields, as those
are well-defined when having a width of zero:

    register struct {                                                   \
        typeof(arg) e;                                                  \
        unsigned long pad:(sizeof(void *) - sizeof(arg)) * 8;           \
    } ...

Yet when the width is zero, the field may not have name, whereas when the
field uniformly doesn't have a name, Clang would, like also for

    register struct {                                                   \
        typeof(arg) e;                                                  \
        unsigned long :0;                                               \
    } ...

regards that space as not needing any (re)init. Bottom line: For the
moment I'm out of ideas.

Jan

Reply via email to