[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 03/16] qemu/compiler.h: Add optimize_away
From: |
Alex Bennée |
Subject: |
Re: [PATCH v4 03/16] qemu/compiler.h: Add optimize_away |
Date: |
Tue, 24 Sep 2019 16:47:00 +0100 |
User-agent: |
mu4e 1.3.4; emacs 27.0.50 |
Richard Henderson <address@hidden> writes:
> Use this as a compile-time assert that a particular
> code path is not reachable.
>
> Signed-off-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
> ---
> include/qemu/compiler.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index 20780e722d..6604ccea92 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -221,4 +221,19 @@
> #define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x,
> __VA_ARGS__))
> #define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x,
> __VA_ARGS__))
>
> +/**
> + * optimize_away()
> + *
> + * The compiler, during optimization, is expected to prove that a call
> + * to this function cannot be reached and remove it. If the compiler
> + * supports QEMU_ERROR, this will be reported at compile time; otherwise
> + * this will be reported at link time, due to the missing symbol.
> + */
> +#ifdef __OPTIMIZE__
> +extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
> + optimize_away(void);
> +#else
> +#define optimize_away() g_assert_not_reached()
> +#endif
> +
> #endif /* COMPILER_H */
--
Alex Bennée
- [PATCH v4 00/16] Move rom and notdirty handling to cputlb, Richard Henderson, 2019/09/23
- [PATCH v4 04/16] cputlb: Use optimize_away in load/store_helpers, Richard Henderson, 2019/09/23
- [PATCH v4 06/16] cputlb: Introduce TLB_BSWAP, Richard Henderson, 2019/09/23
- [PATCH v4 07/16] exec: Adjust notdirty tracing, Richard Henderson, 2019/09/23
- [PATCH v4 05/16] cputlb: Split out load/store_memop, Richard Henderson, 2019/09/23