bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org
Subject: Re: Clang __built_assume
Date: Sat, 22 Aug 2020 10:32:18 -0700	[thread overview]
Message-ID: <4d87cd4d-f02c-761c-216e-65157754d039@cs.ucla.edu> (raw)
In-Reply-To: <4290937.bpigslQC6F@omega>

On 8/22/20 3:30 AM, Bruno Haible wrote:
> -#if _GL_HAS_BUILTIN_UNREACHABLE
> +   features such as function calls not inlined by the compiler.  */
> +
> +#if _GL_HAS_BUILTIN_ASSUME
> +/* Use a temporary variable, to avoid a clang warning
> +   "the argument to '__builtin_assume' has side effects that will be discarded"
> +   if R contains invocations of functions not marked as 'const'.  */
> +# define assume(R) \
> +    ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \
> +               __builtin_assume (_gl_verify_temp); }))
> +#elif _GL_HAS_BUILTIN_UNREACHABLE
>   # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())

This is OK, but please also mention in the comment that __builtin_assume 
generates better code for Clang 8 than __builtin_unreachable does, as that's the 
only reason to put up with all this mess.


  reply	other threads:[~2020-08-22 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17 22:02 fixes for Clang builtins when compiling Emacs on Fedora Paul Eggert
2020-08-17 23:37 ` Bruno Haible
2020-08-18  1:10   ` Paul Eggert
2020-08-22 10:30     ` Clang __built_assume Bruno Haible
2020-08-22 17:32       ` Paul Eggert [this message]
2020-08-22 23:01         ` Clang __builtin_assume Bruno Haible
2020-08-23 13:46 ` clang's __diagnose_if__ and glibc fortify Bruno Haible

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=4d87cd4d-f02c-761c-216e-65157754d039@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).