bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clang __built_assume


From: Paul Eggert
Subject: Re: Clang __built_assume
Date: Sat, 22 Aug 2020 10:32:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]