diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-05-13 22:40:11 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-05-13 22:40:11 +0000 |
commit | 51e79f06342b7a39f2e794b19bcd464d4c592f05 (patch) | |
tree | 90428c9ec9eba59603f293d8a5960def3f7a27ec | |
parent | 5f245bfca8391c5b61b3d59798bc5819b42f6097 (diff) | |
download | bcm5719-llvm-51e79f06342b7a39f2e794b19bcd464d4c592f05.tar.gz bcm5719-llvm-51e79f06342b7a39f2e794b19bcd464d4c592f05.zip |
[X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.
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
Reviewers: craig.topper, GBuella, rnk, echristo
Reviewed By: rnk
Subscribers: jkorous, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D61621
llvm-svn: 360630
-rw-r--r-- | clang/lib/Headers/immintrin.h | 4 | ||||
-rw-r--r-- | clang/lib/Headers/pconfigintrin.h | 4 | ||||
-rw-r--r-- | clang/lib/Headers/sgxintrin.h | 4 | ||||
-rw-r--r-- | clang/test/Modules/compiler_builtins_x86.c | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h index 2bd79bd88f3..ea009bd88b1 100644 --- a/clang/lib/Headers/immintrin.h +++ b/clang/lib/Headers/immintrin.h @@ -421,7 +421,7 @@ _storebe_i64(void * __P, long long __D) { #include <invpcidintrin.h> #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 @@ _InterlockedCompareExchange64_HLERelease(__int64 volatile *_Destination, #undef __DEFAULT_FN_ATTRS -#endif /* _MSC_VER */ +#endif /* defined(_MSC_VER) && __has_extension(gnu_asm) */ #endif /* __IMMINTRIN_H */ diff --git a/clang/lib/Headers/pconfigintrin.h b/clang/lib/Headers/pconfigintrin.h index d2b39cd5832..d2014b026f3 100644 --- a/clang/lib/Headers/pconfigintrin.h +++ b/clang/lib/Headers/pconfigintrin.h @@ -16,6 +16,8 @@ #define __PCONFIG_KEY_PROGRAM 0x00000001 +#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 @@ _pconfig_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) #undef __DEFAULT_FN_ATTRS +#endif /* __has_extension(gnu_asm) */ + #endif diff --git a/clang/lib/Headers/sgxintrin.h b/clang/lib/Headers/sgxintrin.h index 55805e3954d..303a21f6b2e 100644 --- a/clang/lib/Headers/sgxintrin.h +++ b/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 @@ _enclv_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) #undef __DEFAULT_FN_ATTRS +#endif /* __has_extension(gnu_asm) */ + #endif diff --git a/clang/test/Modules/compiler_builtins_x86.c b/clang/test/Modules/compiler_builtins_x86.c index 1b4d42177ab..43e2283dfbe 100644 --- a/clang/test/Modules/compiler_builtins_x86.c +++ b/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<x86intrin.h> |