[cfe-commits] r115374 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/x86-builtin-palignr.c
Chris Lattner
sabre at nondot.org
Fri Oct 1 16:23:24 PDT 2010
Author: lattner
Date: Fri Oct 1 18:23:24 2010
New Revision: 115374
URL: http://llvm.org/viewvc/llvm-project?rev=115374&view=rev
Log:
diagnose errors when a builtin that require constant arguments don't have them.
For example, on:
#include <emmintrin.h>
int foo(int N) {
__m128i white2;
white2 = _mm_slli_si128(white2, N);
return 0;
}
we used to get:
fatal error: error in backend: Cannot yet select: intrinsic %llvm.x86.sse2.psll.dq
now we get:
/Users/sabre/t.c:4:11: error: argument to '__builtin_ia32_pslldqi128' must be a
constant integer
white2 = _mm_slli_si128(white2, N);
^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/sabre/t.c:1:
/Volumes/Projects/cvs/llvm/Debug+Asserts/lib/clang/2.9/include/emmintrin.h:781:13: note: instantiated from:
((__m128i)__builtin_ia32_pslldqi128((__m128i)(VEC), (IMM)*8))
^ ~~~~~~~
1 error generated.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/x86-builtin-palignr.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=115374&r1=115373&r2=115374&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Oct 1 18:23:24 2010
@@ -131,6 +131,24 @@
Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
ExprResult TheCallResult(Owned(TheCall));
+ // Find out if any arguments are required to be integer constant expressions.
+ unsigned ICEArguments = 0;
+ ASTContext::GetBuiltinTypeError Error;
+ Context.GetBuiltinType(BuiltinID, Error, &ICEArguments);
+ if (Error != ASTContext::GE_None)
+ ICEArguments = 0; // Don't diagnose previously diagnosed errors.
+
+ // If any arguments are required to be ICE's, check and diagnose.
+ for (unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
+ // Skip arguments not required to be ICE's.
+ if ((ICEArguments & (1 << ArgNo)) == 0) continue;
+
+ llvm::APSInt Result;
+ if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
+ return true;
+ ICEArguments &= ~(1 << ArgNo);
+ }
+
switch (BuiltinID) {
case Builtin::BI__builtin___CFStringMakeConstantString:
assert(TheCall->getNumArgs() == 1 &&
Modified: cfe/trunk/test/Sema/x86-builtin-palignr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/x86-builtin-palignr.c?rev=115374&r1=115373&r2=115374&view=diff
==============================================================================
--- cfe/trunk/test/Sema/x86-builtin-palignr.c (original)
+++ cfe/trunk/test/Sema/x86-builtin-palignr.c Fri Oct 1 18:23:24 2010
@@ -4,7 +4,13 @@
#include <tmmintrin.h>
-__m64 foo(__m64 a, __m64 b, int c)
-{
+__m64 test1(__m64 a, __m64 b, int c) {
return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}}
}
+
+int test2(int N) {
+ __m128i white2;
+ white2 = __builtin_ia32_pslldqi128(white2, N); // expected-error {{argument to '__builtin_ia32_pslldqi128' must be a constant integer}}
+ return 0;
+}
+
More information about the cfe-commits
mailing list