Index: include/clang/Basic/BuiltinsAArch64.def =================================================================== --- include/clang/Basic/BuiltinsAArch64.def +++ include/clang/Basic/BuiltinsAArch64.def @@ -14,6 +14,10 @@ // The format of this database matches clang/Basic/Builtins.def. +#if defined(BUILTIN) && !defined(LANGBUILTIN) +# define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS) +#endif + // In libgcc BUILTIN(__clear_cache, "vv*v*", "i") @@ -61,4 +65,9 @@ BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc") BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc") +LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) + #undef BUILTIN +#undef LANGBUILTIN Index: lib/Basic/Targets/AArch64.cpp =================================================================== --- lib/Basic/Targets/AArch64.cpp +++ lib/Basic/Targets/AArch64.cpp @@ -27,6 +27,8 @@ #define BUILTIN(ID, TYPE, ATTRS) \ {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, +#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ + {#ID, TYPE, ATTRS, nullptr, LANG, nullptr}, #include "clang/Basic/BuiltinsAArch64.def" }; Index: test/CodeGen/arm64-microsoft-intrinsics.c =================================================================== --- /dev/null +++ test/CodeGen/arm64-microsoft-intrinsics.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s \ +// RUN: | FileCheck %s -check-prefix CHECK-MSVC + +// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-LINUX + +void check__dmb(void) { + __dmb(0); +} + +// CHECK-MSVC: @llvm.aarch64.dmb(i32 0) +// CHECK-LINUX: error: implicit declaration of function '__dmb' + +void check__dsb(void) { + __dsb(0); +} + +// CHECK-MSVC: @llvm.aarch64.dsb(i32 0) +// CHECK-LINUX: error: implicit declaration of function '__dsb' + +void check__isb(void) { + __isb(0); +} + +// CHECK-MSVC: @llvm.aarch64.isb(i32 0) +// CHECK-LINUX: error: implicit declaration of function '__isb'