Reviewers: iant,
Description:
runtime: yield with _mm_pause instead of __builtin_ia32_pause when built
with Clang
The former is more portable than the latter, being supported by at
least GCC and Clang, but we need to continue using __builtin_ia32_pause
with GCC to work around a bug preventing us from using _mm_pause
with GCC when targeting 32-bit x86.
Please review this at
https://codereview.appspot.com/100810044/
Affected files (+9, -0 lines):
M libgo/runtime/yield.c
Index: libgo/runtime/yield.c
===================================================================
--- a/libgo/runtime/yield.c
+++ b/libgo/runtime/yield.c
@@ -14,6 +14,10 @@
#include <sys/select.h>
#endif
+#if defined (__clang__) && (defined (__i386__) || defined (__x86_64__))
+#include "xmmintrin.h"
+#endif
+
#include "runtime.h"
/* Spin wait. */
@@ -26,8 +30,13 @@
for (i = 0; i < cnt; ++i)
{
#if defined (__i386__) || defined (__x86_64__)
+#ifdef __clang__
+ _mm_pause ();
+#else
+ // TODO: fix GCC bug preventing us from using _mm_pause.
__builtin_ia32_pause ();
#endif
+#endif
}
}