diff mbox series

[v3,08/20] cputlb: Disable __always_inline__ without optimization

Message ID 20190922035458.14879-9-richard.henderson@linaro.org
State Superseded
Headers show
Series Move rom and notdirty handling to cputlb | expand

Commit Message

Richard Henderson Sept. 22, 2019, 3:54 a.m. UTC
This forced inlining can result in missing symbols,
which makes a debugging build harder to follow.

Reviewed-by: David Hildenbrand <david@redhat.com>

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 include/qemu/compiler.h | 11 +++++++++++
 accel/tcg/cputlb.c      |  4 ++--
 2 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Philippe Mathieu-Daudé Sept. 23, 2019, 9:18 a.m. UTC | #1
On 9/22/19 5:54 AM, Richard Henderson wrote:
> This forced inlining can result in missing symbols,

> which makes a debugging build harder to follow.

> 

> Reviewed-by: David Hildenbrand <david@redhat.com>

> Reported-by: Peter Maydell <peter.maydell@linaro.org>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  include/qemu/compiler.h | 11 +++++++++++

>  accel/tcg/cputlb.c      |  4 ++--

>  2 files changed, 13 insertions(+), 2 deletions(-)

> 

> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h

> index 09fc44cca4..d6d400c523 100644

> --- a/include/qemu/compiler.h

> +++ b/include/qemu/compiler.h

> @@ -170,6 +170,17 @@

>  # define QEMU_NONSTRING

>  #endif

>  

> +/*

> + * Forced inlining may be desired to encourage constant propagation

> + * of function parameters.  However, it can also make debugging harder,

> + * so disable it for a non-optimizing build.

> + */

> +#if defined(__OPTIMIZE__) && __has_attribute(always_inline)

> +#define QEMU_ALWAYS_INLINE  __attribute__((always_inline))

> +#else

> +#define QEMU_ALWAYS_INLINE

> +#endif

> +

>  /* Implement C11 _Generic via GCC builtins.  Example:

>   *

>   *    QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)

> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c

> index abae79650c..2222b87764 100644

> --- a/accel/tcg/cputlb.c

> +++ b/accel/tcg/cputlb.c

> @@ -1281,7 +1281,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,

>  typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr,

>                                  TCGMemOpIdx oi, uintptr_t retaddr);

>  

> -static inline uint64_t __attribute__((always_inline))

> +static inline uint64_t QEMU_ALWAYS_INLINE

>  load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,

>              uintptr_t retaddr, MemOp op, bool code_read,

>              FullLoadHelper *full_load)

> @@ -1530,7 +1530,7 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,

>   * Store Helpers

>   */

>  

> -static inline void __attribute__((always_inline))

> +static inline void QEMU_ALWAYS_INLINE

>  store_helper(CPUArchState *env, target_ulong addr, uint64_t val,

>               TCGMemOpIdx oi, uintptr_t retaddr, MemOp op)

>  {

> 


Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Paolo Bonzini Sept. 23, 2019, 9:45 a.m. UTC | #2
On 22/09/19 05:54, Richard Henderson wrote:
> +/*

> + * Forced inlining may be desired to encourage constant propagation

> + * of function parameters.  However, it can also make debugging harder,

> + * so disable it for a non-optimizing build.

> + */

> +#if defined(__OPTIMIZE__) && __has_attribute(always_inline)

> +#define QEMU_ALWAYS_INLINE  __attribute__((always_inline))


GCC doesn't have __has_attribute, does it?  I think you can just assume
that it exists and #ifdef __OPTIMIZE__.

Paolo

> +#else

> +#define QEMU_ALWAYS_INLINE
Richard Henderson Sept. 23, 2019, 4 p.m. UTC | #3
On 9/23/19 2:45 AM, Paolo Bonzini wrote:
> On 22/09/19 05:54, Richard Henderson wrote:

>> +/*

>> + * Forced inlining may be desired to encourage constant propagation

>> + * of function parameters.  However, it can also make debugging harder,

>> + * so disable it for a non-optimizing build.

>> + */

>> +#if defined(__OPTIMIZE__) && __has_attribute(always_inline)

>> +#define QEMU_ALWAYS_INLINE  __attribute__((always_inline))

> 

> GCC doesn't have __has_attribute, does it?


It does, since at least gcc 5.  And now I realize that's only a reorganization
of the support and not when it was introduced.


r~
Paolo Bonzini Sept. 23, 2019, 4:49 p.m. UTC | #4
On 23/09/19 18:00, Richard Henderson wrote:
> On 9/23/19 2:45 AM, Paolo Bonzini wrote:

>> On 22/09/19 05:54, Richard Henderson wrote:

>>> +/*

>>> + * Forced inlining may be desired to encourage constant propagation

>>> + * of function parameters.  However, it can also make debugging harder,

>>> + * so disable it for a non-optimizing build.

>>> + */

>>> +#if defined(__OPTIMIZE__) && __has_attribute(always_inline)

>>> +#define QEMU_ALWAYS_INLINE  __attribute__((always_inline))

>>

>> GCC doesn't have __has_attribute, does it?

> 

> It does, since at least gcc 5.  And now I realize that's only a reorganization

> of the support and not when it was introduced.


Hmm, still we support 4.8 and always_inline is much older than that.  So
I'm not sure it's useful to test it.

Paolo
Richard Henderson Sept. 23, 2019, 6:09 p.m. UTC | #5
On 9/23/19 9:49 AM, Paolo Bonzini wrote:
> Hmm, still we support 4.8 and always_inline is much older than that.  So

> I'm not sure it's useful to test it.


Fair enough.


r~
diff mbox series

Patch

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 09fc44cca4..d6d400c523 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -170,6 +170,17 @@ 
 # define QEMU_NONSTRING
 #endif
 
+/*
+ * Forced inlining may be desired to encourage constant propagation
+ * of function parameters.  However, it can also make debugging harder,
+ * so disable it for a non-optimizing build.
+ */
+#if defined(__OPTIMIZE__) && __has_attribute(always_inline)
+#define QEMU_ALWAYS_INLINE  __attribute__((always_inline))
+#else
+#define QEMU_ALWAYS_INLINE
+#endif
+
 /* Implement C11 _Generic via GCC builtins.  Example:
  *
  *    QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index abae79650c..2222b87764 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1281,7 +1281,7 @@  static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
 typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr,
                                 TCGMemOpIdx oi, uintptr_t retaddr);
 
-static inline uint64_t __attribute__((always_inline))
+static inline uint64_t QEMU_ALWAYS_INLINE
 load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
             uintptr_t retaddr, MemOp op, bool code_read,
             FullLoadHelper *full_load)
@@ -1530,7 +1530,7 @@  tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
  * Store Helpers
  */
 
-static inline void __attribute__((always_inline))
+static inline void QEMU_ALWAYS_INLINE
 store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
              TCGMemOpIdx oi, uintptr_t retaddr, MemOp op)
 {