[PATCH] Makes softmmu compile with clang at HEAD

Shu-Chun Weng posted 1 patch 4 years, 2 months ago
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test checkpatch passed
Test FreeBSD passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200318062057.224953-1-scw@google.com
Maintainers: Richard Henderson <rth@twiddle.net>, Paolo Bonzini <pbonzini@redhat.com>
accel/tcg/cputlb.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] Makes softmmu compile with clang at HEAD
Posted by Shu-Chun Weng 4 years, 2 months ago
With clang at HEAD, linking fails with "undefined symbol:
qemu_build_not_reached". It's because `store_helper` and
`helper_ret_stb_mmu` are mutually recursive and clang inlined latter
inside the former, making `store_helper` a recursive function and no
longer fully inlineable preventing constant propogation.

Signed-off-by: Shu-Chun Weng <scw@google.com>
---
 accel/tcg/cputlb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index e3b5750c3b..a7c812ed72 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -2050,6 +2050,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
     store_memop(haddr, val, op);
 }
 
+__attribute__((noinline))
 void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val,
                         TCGMemOpIdx oi, uintptr_t retaddr)
 {
-- 
2.25.1.481.gfbce0eb801-goog


Re: [PATCH] Makes softmmu compile with clang at HEAD
Posted by Shu-Chun Weng 4 years, 1 month ago
Ping.

On Tue, Mar 17, 2020 at 11:21 PM Shu-Chun Weng <scw@google.com> wrote:

> With clang at HEAD, linking fails with "undefined symbol:
> qemu_build_not_reached". It's because `store_helper` and
> `helper_ret_stb_mmu` are mutually recursive and clang inlined latter
> inside the former, making `store_helper` a recursive function and no
> longer fully inlineable preventing constant propogation.
>
> Signed-off-by: Shu-Chun Weng <scw@google.com>
> ---
>  accel/tcg/cputlb.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index e3b5750c3b..a7c812ed72 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -2050,6 +2050,7 @@ store_helper(CPUArchState *env, target_ulong addr,
> uint64_t val,
>      store_memop(haddr, val, op);
>  }
>
> +__attribute__((noinline))
>  void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val,
>                          TCGMemOpIdx oi, uintptr_t retaddr)
>  {
> --
> 2.25.1.481.gfbce0eb801-goog
>
>
Re: [PATCH] Makes softmmu compile with clang at HEAD
Posted by Alex Bennée 4 years, 1 month ago
Shu-Chun Weng <scw@google.com> writes:

> With clang at HEAD, linking fails with "undefined symbol:
> qemu_build_not_reached". It's because `store_helper` and
> `helper_ret_stb_mmu` are mutually recursive and clang inlined latter
> inside the former, making `store_helper` a recursive function and no
> longer fully inlineable preventing constant propogation.
>
> Signed-off-by: Shu-Chun Weng <scw@google.com>
> ---
>  accel/tcg/cputlb.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index e3b5750c3b..a7c812ed72 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -2050,6 +2050,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
>      store_memop(haddr, val, op);
>  }
>  
> +__attribute__((noinline))
>  void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val,
>                          TCGMemOpIdx oi, uintptr_t retaddr)

Hmm I wonder if the correct fix is for store_helper to callL

  store_memop(addr + i, val8, MO_UB);

direct in the fallback case - although the page crossing may be tricky
to get right. Perhaps we should out of line all the unaligned stuff?


-- 
Alex Bennée