]> granicus.if.org Git - clang/commit
Add an error when calling a builtin that requires features that don't
authorEric Christopher <echristo@gmail.com>
Thu, 15 Oct 2015 23:47:11 +0000 (23:47 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 15 Oct 2015 23:47:11 +0000 (23:47 +0000)
commitcea709e6909305f86838ee87cc31a34664de16db
tree14c4609c5dbc3490939020ac59b7038568ea4dc0
parent57d69b32b52e74acf052bdb236ec9096893b5391
Add an error when calling a builtin that requires features that don't
match the feature set of the function that they're being called from.

This ensures that we can effectively diagnose some[1] code that would
instead ICE in the backend with a failure to select message.

Example:

__m128d foo(__m128d a, __m128d b) {
  return __builtin_ia32_addsubps(b, a);
}

compiled for normal x86_64 via:

clang -target x86_64-linux-gnu -c

would fail to compile in the back end because the normal subtarget
features for x86_64 only include sse2 and the builtin requires sse3.

[1] We're still not erroring on:

__m128i bar(__m128i const *p) { return _mm_lddqu_si128(p); }

where we should fail and error on an always_inline function being
inlined into a function that doesn't support the subtarget features
required.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250473 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/target-builtin-error-2.c [new file with mode: 0644]
test/CodeGen/target-builtin-error.c [new file with mode: 0644]
test/CodeGen/target-builtin-noerror.c [new file with mode: 0644]