[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 16:17:24 PDT 2019
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<x86intrin.h>
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 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 @@
#undef __DEFAULT_FN_ATTRS
+#endif /* __has_extension(gnu_asm) */
+
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61621.198365.patch
Type: text/x-patch
Size: 1876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190506/ef6a8441/attachment.bin>
More information about the cfe-commits
mailing list