public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
To: linux-kernel@vger.kernel.org, Uros Bizjak <ubizjak@gmail.com>,
	x86@kernel.org, Andrew Morton <akpm@linux-foundation.org>
Cc: sv@linux.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] compiler-gcc.h: Remove ancient workaround for gcc PR 58670
Date: Thu, 25 Aug 2022 16:00:52 +0530	[thread overview]
Message-ID: <1661422971.cqtahfm22j.naveen@linux.ibm.com> (raw)
In-Reply-To: <20220624141412.72274-1-ubizjak@gmail.com>

Uros Bizjak wrote:
> The workaround for 'asm goto' miscompilation introduces a compiler
> barrier quirk that inhibits many useful compiler optimizations. For
> example, __try_cmpxchg_user compiles to:
> 
>    11375:	41 8b 4d 00          	mov    0x0(%r13),%ecx
>    11379:	41 8b 02             	mov    (%r10),%eax
>    1137c:	f0 0f b1 0a          	lock cmpxchg %ecx,(%rdx)
>    11380:	0f 94 c2             	sete   %dl
>    11383:	84 d2                	test   %dl,%dl
>    11385:	75 c4                	jne    1134b <...>
>    11387:	41 89 02             	mov    %eax,(%r10)
> 
> where the barrier inhibits flags propagation from asm when
> compiled with gcc-12.
> 
> When the mentioned quirk is removed, the following code is generated:
> 
>    11553:	41 8b 4d 00          	mov    0x0(%r13),%ecx
>    11557:	41 8b 02             	mov    (%r10),%eax
>    1155a:	f0 0f b1 0a          	lock cmpxchg %ecx,(%rdx)
>    1155e:	74 c9                	je     11529 <...>
>    11560:	41 89 02             	mov    %eax,(%r10)
> 
> The refered compiler bug:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
> 
> was fixed for gcc-4.8.2.
> 
> Current minimum required version of GCC is version 5.1 which has
> the above 'asm goto' miscompilation fixed, so remove the workaround.
> 
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  include/linux/compiler-gcc.h | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index a0c55eeaeaf1..9b157b71036f 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -66,17 +66,6 @@
>  		__builtin_unreachable();	\
>  	} while (0)
>  
> -/*
> - * GCC 'asm goto' miscompiles certain code sequences:
> - *
> - *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
> - *
> - * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
> - *
> - * (asm goto is automatically volatile - the naming reflects this.)
> - */
> -#define asm_volatile_goto(x...)	do { asm goto(x); asm (""); } while (0)
> -
>  #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
>  #define __HAVE_BUILTIN_BSWAP32__
>  #define __HAVE_BUILTIN_BSWAP64__

This is causing a build issue on ppc64le with a new patch replacing use 
of unreachable() with __builtin_unreachable() in __WARN_FLAGS():
https://lore.kernel.org/linuxppc-dev/20220808114908.240813-2-sv@linux.ibm.com/

during RTL pass: combine
In file included from /linux/kernel/locking/rtmutex_api.c:9:
/linux/kernel/locking/rtmutex.c: In function '__rt_mutex_slowlock.constprop':
/linux/kernel/locking/rtmutex.c:1612:1: internal compiler error: in purge_dead_edges, at cfgrtl.c:3369
 1612 | }
      | ^
0x142817c internal_error(char const*, ...)
	???:0
0x5c8a1b fancy_abort(char const*, int, char const*)
	???:0
0x72017f purge_all_dead_edges()
	???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.


So, it looks like gcc still has issues with certain uses of asm goto.


- Naveen


  reply	other threads:[~2022-08-25 10:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 14:14 [PATCH] compiler-gcc.h: Remove ancient workaround for gcc PR 58670 Uros Bizjak
2022-08-25 10:30 ` Naveen N. Rao [this message]
2022-08-25 11:19   ` Christophe Leroy
2022-08-25 11:34   ` Uros Bizjak
2022-08-25 18:08   ` Segher Boessenkool
2022-08-26  7:02     ` Christophe Leroy
2022-08-26  7:38       ` Christophe Leroy
2022-08-26 10:12     ` Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1661422971.cqtahfm22j.naveen@linux.ibm.com \
    --to=naveen.n.rao@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=sv@linux.ibm.com \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox