[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/8] compiler.h: Don't use compile-time assert when __NO_INLINE__
From: |
Richard Henderson |
Subject: |
[PULL 2/8] compiler.h: Don't use compile-time assert when __NO_INLINE__ is defined |
Date: |
Fri, 28 Feb 2020 18:43:41 -0800 |
From: Zenghui Yu <address@hidden>
Our robot reported the following compile-time warning while compiling
Qemu with -fno-inline cflags:
In function 'load_memop',
inlined from 'load_helper' at /qemu/accel/tcg/cputlb.c:1578:20,
inlined from 'full_ldub_mmu' at /qemu/accel/tcg/cputlb.c:1624:12:
/qemu/accel/tcg/cputlb.c:1502:9: error: call to 'qemu_build_not_reached'
declared with attribute error: code path is reachable
qemu_build_not_reached();
^~~~~~~~~~~~~~~~~~~~~~~~
[...]
It looks like a false-positive because only (MO_UB ^ MO_BSWAP) will
hit the default case in load_memop() while need_swap (size > 1) has
already ensured that MO_UB is not involved.
So the thing is that compilers get confused by the -fno-inline and
just can't accurately evaluate memop_size(op) at compile time, and
then the qemu_build_not_reached() is wrongly triggered by (MO_UB ^
MO_BSWAP). Let's carefully don't use the compile-time assert when
no functions will be inlined into their callers.
Reported-by: Euler Robot <address@hidden>
Suggested-by: Richard Henderson <address@hidden>
Signed-off-by: Zenghui Yu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
include/qemu/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 85c02c16d3..c76281f354 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -236,7 +236,7 @@
* 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__
+#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
qemu_build_not_reached(void);
#else
--
2.20.1
- [PULL 0/8] tcg patch queue, Richard Henderson, 2020/02/28
- [PULL 1/8] accel/tcg: fix race in cpu_exec_step_atomic (bug 1863025), Richard Henderson, 2020/02/28
- [PULL 6/8] accel/tcg: remove link between guest ram and TCG cache size, Richard Henderson, 2020/02/28
- [PULL 7/8] accel/tcg: only USE_STATIC_CODE_GEN_BUFFER on 32 bit hosts, Richard Henderson, 2020/02/28
- [PULL 8/8] accel/tcg: increase default code gen buffer size for 64 bit, Richard Henderson, 2020/02/28
- [PULL 3/8] tcg/arm: Split out tcg_out_epilogue, Richard Henderson, 2020/02/28
- [PULL 5/8] accel/tcg: use units.h for defining code gen buffer sizes, Richard Henderson, 2020/02/28
- [PULL 2/8] compiler.h: Don't use compile-time assert when __NO_INLINE__ is defined,
Richard Henderson <=
- [PULL 4/8] tcg/arm: Expand epilogue inline, Richard Henderson, 2020/02/28