[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360630: [X86] Make `x86intrin.h`, `immintrin.h` includable 
with `-fno-gnu-inline-asm`. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61621?vs=198875=199342#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61621/new/

https://reviews.llvm.org/D61621

Files:
  cfe/trunk/lib/Headers/immintrin.h
  cfe/trunk/lib/Headers/pconfigintrin.h
  cfe/trunk/lib/Headers/sgxintrin.h
  cfe/trunk/test/Modules/compiler_builtins_x86.c


Index: cfe/trunk/test/Modules/compiler_builtins_x86.c
===
--- cfe/trunk/test/Modules/compiler_builtins_x86.c
+++ cfe/trunk/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s 
-verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: cfe/trunk/lib/Headers/pconfigintrin.h
===
--- cfe/trunk/lib/Headers/pconfigintrin.h
+++ cfe/trunk/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/lib/Headers/immintrin.h
@@ -421,7 +421,7 @@
 #include 
 #endif
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && __has_extension(gnu_asm)
 /* Define the default attributes for these intrinsics */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 #ifdef __cplusplus
@@ -503,6 +503,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* _MSC_VER */
+#endif /* defined(_MSC_VER) && __has_extension(gnu_asm) */
 
 #endif /* __IMMINTRIN_H */
Index: cfe/trunk/lib/Headers/sgxintrin.h
===
--- cfe/trunk/lib/Headers/sgxintrin.h
+++ cfe/trunk/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif


Index: cfe/trunk/test/Modules/compiler_builtins_x86.c
===
--- cfe/trunk/test/Modules/compiler_builtins_x86.c
+++ cfe/trunk/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: cfe/trunk/lib/Headers/pconfigintrin.h
===
--- cfe/trunk/lib/Headers/pconfigintrin.h
+++ cfe/trunk/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: cfe/trunk/lib/Headers/immintrin.h

[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D61621#1497027 , @rnk wrote:

> lgtm, thanks!
>
> In D61621#1496978 , @vsapsai wrote:
>
> > Didn't use `-fms-compatibility` in the test and it seems to be working fine.
> >  Don't know if it is accidental and if I should add the flag.
>
>
> `-fms-extensions` is probably all you need. That's the one that defines 
> _MSC_VER.


Thanks for extra information and for the review. In my testing it was 
`-fms-compatibility-version` that defines `_MSC_VER` on macOS. I haven't tested 
extensively but looks like for the driver `-fms-extensions` should be enough 
but for -cc1 you need `-fms-compatibility-version`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61621/new/

https://reviews.llvm.org/D61621



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!

In D61621#1496978 , @vsapsai wrote:

> Didn't use `-fms-compatibility` in the test and it seems to be working fine.
>  Don't know if it is accidental and if I should add the flag.


`-fms-extensions` is probably all you need. That's the one that defines 
_MSC_VER.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61621/new/

https://reviews.llvm.org/D61621



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-09 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 198875.
vsapsai added a comment.

- Improve `-fno-gnu-inline-asm` support for MS-compatibility too.

Didn't use `-fms-compatibility` in the test and it seems to be working fine.
Don't know if it is accidental and if I should add the flag.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61621/new/

https://reviews.llvm.org/D61621

Files:
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/pconfigintrin.h
  clang/lib/Headers/sgxintrin.h
  clang/test/Modules/compiler_builtins_x86.c


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s 
-verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -421,7 +421,7 @@
 #include 
 #endif
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && __has_extension(gnu_asm)
 /* Define the default attributes for these intrinsics */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 #ifdef __cplusplus
@@ -503,6 +503,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* _MSC_VER */
+#endif /* defined(_MSC_VER) && __has_extension(gnu_asm) */
 
 #endif /* __IMMINTRIN_H */


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if 

[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see one more instance of unprotected __asm__ usage, but it's under `#ifdef 
_MSC_VER`, it's the HLE extensions. Can you protect that, and then add another 
RUN line with a windows triple and -fms-extensions to test it?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61621/new/

https://reviews.llvm.org/D61621



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-06 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: craig.topper, GBuella.
Herald added subscribers: dexonsmith, jkorous.
vsapsai added a parent revision: D61619: Make language option `GNUAsm` 
discoverable with `__has_extension` macro..

Currently `immintrin.h` includes `pconfigintrin.h` and `sgxintrin.h`
which contain inline assembly. It causes failures when building with the
flag `-fno-gnu-inline-asm`.

Fix by excluding functions with inline assembly when this extension is
disabled. So far there was no need to support `_pconfig_u32`,
`_enclu_u32`, `_encls_u32`, `_enclv_u32` on platforms that require
`-fno-gnu-inline-asm`. But if developers start using these functions,
they'll have compile-time undeclared identifier errors which is
preferrable to runtime errors.

rdar://problem/49540880


https://reviews.llvm.org/D61621

Files:
  clang/lib/Headers/pconfigintrin.h
  clang/lib/Headers/sgxintrin.h
  clang/test/Modules/compiler_builtins_x86.c


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s 
-verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits