<div dir="ltr">This isn't blocking anything. Just doing some archaeology because I noticed we had an intrinsic in the backend, but it wasn't used by the frontend due to a previous revert a couple years ago.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 3:47 PM Benjamin Kramer <<a href="mailto:benny.kra@gmail.com">benny.kra@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I think the only viable solution is to make v8 not define reserved identifiers & reland this change. That will take some time, so unless this is blocking something important I'd prefer to reland after the release cut so the world can catch up before the next release. I can take care of sending v8 a patch if nobody else feels like doing it.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 11:28 PM Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">any suggestions on how to proceed here?<div><br clear="all"><div><div dir="ltr" class="gmail-m_3617481273369787434gmail-m_-2822755480945389288gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 10:56 AM Benjamin Kramer <<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I think the main issue is that libstdc++ 4.9 includes x86intrin.h transitively from <algorithm>. That's probably broken with all compilers :(</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 7:31 PM Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Does V8 work with gcc which also has _xgetbv? Or is it because I had to make _xgetbv a macro to make the patch work?</div><br clear="all"><div><div dir="ltr" class="gmail-m_3617481273369787434gmail-m_-2822755480945389288gmail-m_5279110968567862902gmail-m_-8139943268616470576gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 9:28 AM Benjamin Kramer via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">I rolled it back for now in r351210, this pattern seems to be quite common even outside of v8. Let's figure out if we can keep the code working or if it needs to be fixed all over the place :(</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer <<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">I'm seeing breakages on v8 with this, it defines its own _xgetbv. Any ideas what do do about this?<div><br></div><div><a href="https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36" target="_blank">https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36</a><br></div><div><br></div><div><div>src/x64/assembler-x64.cc:35:1: error: inline variables are incompatible with C++ standards before C++17 [-Werror,-Wc++98-c++11-c++14-compat]</div><div>V8_INLINE uint64_t _xgetbv(unsigned int xcr) {</div><div>^</div><div>include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'</div><div># define V8_INLINE inline __attribute__((always_inline))</div><div>                   ^</div><div>src/x64/assembler-x64.cc:35:41: error: expected ')'</div><div>V8_INLINE uint64_t _xgetbv(unsigned int xcr) {</div><div>                                        ^</div><div>src/x64/assembler-x64.cc:35:20: note: to match this '('</div><div>V8_INLINE uint64_t _xgetbv(unsigned int xcr) {</div><div>                   ^</div><div>lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro '_xgetbv'</div><div>#define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: ctopper<br>
Date: Mon Jan 14 21:03:18 2019<br>
New Revision: 351160<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=351160&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=351160&view=rev</a><br>
Log:<br>
[X86] Make _xgetbv/_xsetbv on non-windows platforms<br>
<br>
Summary:<br>
This patch attempts to redo what was tried in r278783, but was reverted.<br>
<br>
These intrinsics should be available on non-windows platforms with "xsave" feature check. But on Windows platforms they shouldn't have feature check since that's how MSVC behaves.<br>
<br>
To accomplish this I've added a MS builtin with no feature check. And a normal gcc builtin with a feature check. When _MSC_VER is not defined _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.<br>
<br>
I've moved the forward declarations from intrin.h to immintrin.h to match the MSDN documentation and used that as the header file for the MS builtin.<br>
<br>
I'm not super happy with this implementation, and I'm open to suggestions for better ways to do it.<br>
<br>
Reviewers: rnk, RKSimon, spatel<br>
<br>
Reviewed By: rnk<br>
<br>
Subscribers: cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D56686" rel="noreferrer" target="_blank">https://reviews.llvm.org/D56686</a><br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/BuiltinsX86.def<br>
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
    cfe/trunk/lib/Headers/immintrin.h<br>
    cfe/trunk/lib/Headers/intrin.h<br>
    cfe/trunk/lib/Headers/xsaveintrin.h<br>
    cfe/trunk/test/CodeGen/builtins-x86.c<br>
    cfe/trunk/test/CodeGen/x86_32-xsave.c<br>
    cfe/trunk/test/CodeGen/x86_64-xsave.c<br>
    cfe/trunk/test/Headers/ms-intrin.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)<br>
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jan 14 21:03:18 2019<br>
@@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v<br>
 // XSAVE<br>
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")<br>
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")<br>
+TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")<br>
+TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h", ALL_MS_LANGUAGES, "")<br>
+TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")<br>
+TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h", ALL_MS_LANGUAGES, "")<br>
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")<br>
 TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")<br>
 TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jan 14 21:03:18 2019<br>
@@ -9831,7 +9831,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx<br>
   case X86::BI__builtin_ia32_xsavec:<br>
   case X86::BI__builtin_ia32_xsavec64:<br>
   case X86::BI__builtin_ia32_xsaves:<br>
-  case X86::BI__builtin_ia32_xsaves64: {<br>
+  case X86::BI__builtin_ia32_xsaves64:<br>
+  case X86::BI__builtin_ia32_xsetbv:<br>
+  case X86::BI_xsetbv: {<br>
     Intrinsic::ID ID;<br>
 #define INTRINSIC_X86_XSAVE_ID(NAME) \<br>
     case X86::BI__builtin_ia32_##NAME: \<br>
@@ -9851,6 +9853,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx<br>
     INTRINSIC_X86_XSAVE_ID(xsavec64);<br>
     INTRINSIC_X86_XSAVE_ID(xsaves);<br>
     INTRINSIC_X86_XSAVE_ID(xsaves64);<br>
+    INTRINSIC_X86_XSAVE_ID(xsetbv);<br>
+    case X86::BI_xsetbv:<br>
+      ID = Intrinsic::x86_xsetbv;<br>
+      break;<br>
     }<br>
 #undef INTRINSIC_X86_XSAVE_ID<br>
     Value *Mhi = Builder.CreateTrunc(<br>
@@ -9860,6 +9866,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx<br>
     Ops.push_back(Mlo);<br>
     return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);<br>
   }<br>
+  case X86::BI__builtin_ia32_xgetbv:<br>
+  case X86::BI_xgetbv:<br>
+    return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);<br>
   case X86::BI__builtin_ia32_storedqudi128_mask:<br>
   case X86::BI__builtin_ia32_storedqusi128_mask:<br>
   case X86::BI__builtin_ia32_storedquhi128_mask:<br>
<br>
Modified: cfe/trunk/lib/Headers/immintrin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/immintrin.h (original)<br>
+++ cfe/trunk/lib/Headers/immintrin.h Mon Jan 14 21:03:18 2019<br>
@@ -378,9 +378,8 @@ _storebe_i64(void * __P, long long __D)<br>
 #include <fxsrintrin.h><br>
 #endif<br>
<br>
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVE__)<br>
+/* No feature check desired due to internal MSC_VER checks */<br>
 #include <xsaveintrin.h><br>
-#endif<br>
<br>
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEOPT__)<br>
 #include <xsaveoptintrin.h><br>
<br>
Modified: cfe/trunk/lib/Headers/intrin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/intrin.h (original)<br>
+++ cfe/trunk/lib/Headers/intrin.h Mon Jan 14 21:03:18 2019<br>
@@ -200,10 +200,7 @@ __attribute__((__deprecated__("use other<br>
 _WriteBarrier(void);<br>
 unsigned __int32 xbegin(void);<br>
 void _xend(void);<br>
-static __inline__<br>
 #define _XCR_XFEATURE_ENABLED_MASK 0<br>
-unsigned __int64 __cdecl _xgetbv(unsigned int);<br>
-void __cdecl _xsetbv(unsigned int, unsigned __int64);<br>
<br>
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */<br>
 #ifdef __x86_64__<br>
@@ -539,12 +536,6 @@ __cpuidex(int __info[4], int __level, in<br>
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3])<br>
                    : "a"(__level), "c"(__ecx));<br>
 }<br>
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS<br>
-_xgetbv(unsigned int __xcr_no) {<br>
-  unsigned int __eax, __edx;<br>
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));<br>
-  return ((unsigned __int64)__edx << 32) | __eax;<br>
-}<br>
 static __inline__ void __DEFAULT_FN_ATTRS<br>
 __halt(void) {<br>
   __asm__ volatile ("hlt");<br>
<br>
Modified: cfe/trunk/lib/Headers/xsaveintrin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/xsaveintrin.h (original)<br>
+++ cfe/trunk/lib/Headers/xsaveintrin.h Mon Jan 14 21:03:18 2019<br>
@@ -28,6 +28,10 @@<br>
 #ifndef __XSAVEINTRIN_H<br>
 #define __XSAVEINTRIN_H<br>
<br>
+#ifndef _MSC_VER<br>
+#define _XCR_XFEATURE_ENABLED_MASK 0<br>
+#endif<br>
+<br>
 /* Define the default attributes for the functions in this file. */<br>
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("xsave")))<br>
<br>
@@ -41,6 +45,20 @@ _xrstor(void *__p, unsigned long long __<br>
   __builtin_ia32_xrstor(__p, __m);<br>
 }<br>
<br>
+#ifndef _MSC_VER<br>
+#define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))<br>
+#define _xsetbv(A, B) __builtin_ia32_xsetbv((unsigned int)(A), (unsigned long long)(B));<br>
+#else<br>
+#ifdef __cplusplus<br>
+extern "C" {<br>
+#endif<br>
+unsigned __int64 __cdecl _xgetbv(unsigned int);<br>
+void __cdecl _xsetbv(unsigned int, unsigned __int64);<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+#endif /* _MSC_VER */<br>
+<br>
 #ifdef __x86_64__<br>
 static __inline__ void __DEFAULT_FN_ATTRS<br>
 _xsave64(void *__p, unsigned long long __m) {<br>
@@ -51,6 +69,7 @@ static __inline__ void __DEFAULT_FN_ATTR<br>
 _xrstor64(void *__p, unsigned long long __m) {<br>
   __builtin_ia32_xrstor64(__p, __m);<br>
 }<br>
+<br>
 #endif<br>
<br>
 #undef __DEFAULT_FN_ATTRS<br>
<br>
Modified: cfe/trunk/test/CodeGen/builtins-x86.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/builtins-x86.c (original)<br>
+++ cfe/trunk/test/CodeGen/builtins-x86.c Mon Jan 14 21:03:18 2019<br>
@@ -281,6 +281,8 @@ void f0() {<br>
<br>
   (void)__builtin_ia32_xsave(tmp_vp, tmp_ULLi);<br>
   (void)__builtin_ia32_xsave64(tmp_vp, tmp_ULLi);<br>
+  tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);<br>
+  (void)__builtin_ia32_xsetbv(tmp_Ui, tmp_ULLi);<br>
   (void)__builtin_ia32_xrstor(tmp_vp, tmp_ULLi);<br>
   (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi);<br>
   (void)__builtin_ia32_xsaveopt(tmp_vp, tmp_ULLi);<br>
<br>
Modified: cfe/trunk/test/CodeGen/x86_32-xsave.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-xsave.c?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-xsave.c?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/x86_32-xsave.c (original)<br>
+++ cfe/trunk/test/CodeGen/x86_32-xsave.c Mon Jan 14 21:03:18 2019<br>
@@ -1,6 +1,9 @@<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=i686-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE<br>
<br>
+// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XGETBV<br>
+// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSETBV<br>
+<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT<br>
<br>
@@ -10,9 +13,15 @@<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES<br>
<br>
+// Don't include mm_malloc.h, it's system specific.<br>
+#define __MM_MALLOC_H<br>
+#include <x86intrin.h><br>
+<br>
 void test() {<br>
-  unsigned long long tmp_ULLi = 0;<br>
-  void*              tmp_vp = 0;<br>
+  unsigned long long tmp_ULLi;<br>
+  unsigned int       tmp_Ui;<br>
+  void*              tmp_vp;<br>
+  tmp_ULLi = 0; tmp_Ui = 0; tmp_vp = 0;<br>
<br>
 #ifdef TEST_XSAVE<br>
 // XSAVE: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4<br>
@@ -30,6 +39,12 @@ void test() {<br>
 // XSAVE: [[low32_3:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_3]] to i32<br>
 // XSAVE: call void @llvm.x86.xrstor(i8* [[tmp_vp_3]], i32 [[high32_3]], i32 [[low32_3]])<br>
   (void)__builtin_ia32_xrstor(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xsave<br>
+  (void)_xsave(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xrstor<br>
+  (void)_xrstor(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVEOPT<br>
@@ -40,6 +55,9 @@ void test() {<br>
 // XSAVEOPT: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i32<br>
 // XSAVEOPT: call void @llvm.x86.xsaveopt(i8* [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])<br>
   (void)__builtin_ia32_xsaveopt(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVEOPT: call void @llvm.x86.xsaveopt<br>
+  (void)_xsaveopt(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVEC<br>
@@ -50,6 +68,9 @@ void test() {<br>
 // XSAVEC: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i32<br>
 // XSAVEC: call void @llvm.x86.xsavec(i8* [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])<br>
   (void)__builtin_ia32_xsavec(tmp_vp, tmp_ULLi);<br>
+ <br>
+// XSAVEC: call void @llvm.x86.xsavec <br>
+  (void)_xsavec(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVES<br>
@@ -68,5 +89,34 @@ void test() {<br>
 // XSAVES: [[low32_3:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_3]] to i32<br>
 // XSAVES: call void @llvm.x86.xrstors(i8* [[tmp_vp_3]], i32 [[high32_3]], i32 [[low32_3]])<br>
   (void)__builtin_ia32_xrstors(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVES: call void @llvm.x86.xsaves<br>
+  (void)_xsaves(tmp_vp, tmp_ULLi); <br>
+<br>
+// XSAVES: call void @llvm.x86.xrstors<br>
+  (void)_xrstors(tmp_vp, tmp_ULLi);<br>
+#endif<br>
+<br>
+#ifdef TEST_XGETBV<br>
+// XGETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4<br>
+// XGETBV: call i64 @llvm.x86.xgetbv(i32 [[tmp_Ui]])<br>
+  tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);<br>
+  <br>
+// XGETBV: call i64 @llvm.x86.xgetbv<br>
+  tmp_ULLi = _xgetbv(tmp_Ui);<br>
+#endif<br>
+<br>
+#ifdef TEST_XSETBV<br>
+// XSETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4<br>
+// XSETBV: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8<br>
+// XSETBV: [[high64_3:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_3]], 32<br>
+// XSETBV: [[high32_3:%[0-9a-zA-z]+]] = trunc i64 [[high64_3]] to i32<br>
+// XSETBV: [[low32_3:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_3]] to i32<br>
+// XSETBV: call void @llvm.x86.xsetbv(i32 [[tmp_Ui]], i32 [[high32_3]], i32 [[low32_3]])<br>
+  (void)__builtin_ia32_xsetbv(tmp_Ui, tmp_ULLi);<br>
+  <br>
+  // XSETBV: call void @llvm.x86.xsetbv<br>
+  (void)_xsetbv(tmp_Ui, tmp_ULLi);<br>
 #endif<br>
+<br>
 }<br>
<br>
Modified: cfe/trunk/test/CodeGen/x86_64-xsave.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-xsave.c?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-xsave.c?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/x86_64-xsave.c (original)<br>
+++ cfe/trunk/test/CodeGen/x86_64-xsave.c Mon Jan 14 21:03:18 2019<br>
@@ -1,6 +1,9 @@<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE<br>
<br>
+// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XGETBV<br>
+// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSETBV<br>
+<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT<br>
<br>
@@ -10,9 +13,16 @@<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES<br>
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES<br>
<br>
+// Don't include mm_malloc.h, it's system specific.<br>
+#define __MM_MALLOC_H<br>
+#include <x86intrin.h><br>
+<br>
+<br>
 void test() {<br>
-  unsigned long long tmp_ULLi = 0;<br>
-  void*              tmp_vp = 0;<br>
+  unsigned long long tmp_ULLi;<br>
+  unsigned int       tmp_Ui;<br>
+  void*              tmp_vp;<br>
+  tmp_ULLi = 0; tmp_Ui = 0; tmp_vp = 0;<br>
<br>
 #ifdef TEST_XSAVE<br>
 // XSAVE: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 8<br>
@@ -46,6 +56,18 @@ void test() {<br>
 // XSAVE: [[low32_4:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_4]] to i32<br>
 // XSAVE: call void @llvm.x86.xrstor64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])<br>
   (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xsave<br>
+  (void)_xsave(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xsave64<br>
+  (void)_xsave64(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xrstor<br>
+  (void)_xrstor(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVE: call void @llvm.x86.xrstor64<br>
+  (void)_xrstor64(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVEOPT<br>
@@ -64,6 +86,12 @@ void test() {<br>
 // XSAVEOPT: [[low32_2:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_2]] to i32<br>
 // XSAVEOPT: call void @llvm.x86.xsaveopt64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])<br>
   (void)__builtin_ia32_xsaveopt64(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVEOPT: call void @llvm.x86.xsaveopt<br>
+  (void)_xsaveopt(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVEOPT: call void @llvm.x86.xsaveopt64<br>
+  (void)_xsaveopt64(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVEC<br>
@@ -82,6 +110,12 @@ void test() {<br>
 // XSAVEC: [[low32_2:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_2]] to i32<br>
 // XSAVEC: call void @llvm.x86.xsavec64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])<br>
   (void)__builtin_ia32_xsavec64(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVEC: call void @llvm.x86.xsavec <br>
+  (void)_xsavec(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVEC: call void @llvm.x86.xsavec64<br>
+  (void)_xsavec64(tmp_vp, tmp_ULLi);<br>
 #endif<br>
<br>
 #ifdef TEST_XSAVES<br>
@@ -116,5 +150,39 @@ void test() {<br>
 // XSAVES: [[low32_4:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_4]] to i32<br>
 // XSAVES: call void @llvm.x86.xrstors64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])<br>
   (void)__builtin_ia32_xrstors64(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVES: call void @llvm.x86.xsaves<br>
+  (void)_xsaves(tmp_vp, tmp_ULLi); <br>
+  <br>
+// XSAVES: call void @llvm.x86.xsaves64<br>
+  (void)_xsaves64(tmp_vp, tmp_ULLi); <br>
+<br>
+// XSAVES: call void @llvm.x86.xrstors<br>
+  (void)_xrstors(tmp_vp, tmp_ULLi);<br>
+  <br>
+// XSAVES: call void @llvm.x86.xrstors64<br>
+  (void)_xrstors64(tmp_vp, tmp_ULLi);<br>
+#endif<br>
+<br>
+#ifdef TEST_XGETBV<br>
+// XGETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4<br>
+// XGETBV: call i64 @llvm.x86.xgetbv(i32 [[tmp_Ui]])<br>
+  tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);<br>
+  <br>
+// XGETBV: call i64 @llvm.x86.xgetbv<br>
+  tmp_ULLi = _xgetbv(tmp_Ui);<br>
+#endif<br>
+<br>
+#ifdef TEST_XSETBV<br>
+// XSETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4<br>
+// XSETBV: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8<br>
+// XSETBV: [[high64_3:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_3]], 32<br>
+// XSETBV: [[high32_3:%[0-9a-zA-z]+]] = trunc i64 [[high64_3]] to i32<br>
+// XSETBV: [[low32_3:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_3]] to i32<br>
+// XSETBV: call void @llvm.x86.xsetbv(i32 [[tmp_Ui]], i32 [[high32_3]], i32 [[low32_3]])<br>
+  (void)__builtin_ia32_xsetbv(tmp_Ui, tmp_ULLi);<br>
+  <br>
+  // XSETBV: call void @llvm.x86.xsetbv<br>
+  (void)_xsetbv(tmp_Ui, tmp_ULLi);<br>
 #endif<br>
 }<br>
<br>
Modified: cfe/trunk/test/Headers/ms-intrin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=351160&r1=351159&r2=351160&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=351160&r1=351159&r2=351160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Headers/ms-intrin.cpp (original)<br>
+++ cfe/trunk/test/Headers/ms-intrin.cpp Mon Jan 14 21:03:18 2019<br>
@@ -49,7 +49,9 @@ void f() {<br>
   int info[4];<br>
   __cpuid(info, 0);<br>
   __cpuidex(info, 0, 0);<br>
+#if defined(_M_X64) || defined(_M_IX86)<br>
   _xgetbv(0);<br>
+#endif<br>
   __halt();<br>
   __nop();<br>
   __readmsr(0);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>