From: Craig Topper Date: Fri, 13 Feb 2015 06:04:48 +0000 (+0000) Subject: [X86] Add range checking on immediate arguments on XOP vpcom builtins. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebc3a5653c0cde1b13f9a5ba85afa01460b359a0;p=clang [X86] Add range checking on immediate arguments on XOP vpcom builtins. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229067 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 3093ac5abe..b9af98da13 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -932,6 +932,14 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case X86::BI__builtin_ia32_cmppd256: case X86::BI__builtin_ia32_cmpps512_mask: case X86::BI__builtin_ia32_cmppd512_mask: i = 2; l = 0; u = 31; break; + case X86::BI__builtin_ia32_vpcomub: + case X86::BI__builtin_ia32_vpcomuw: + case X86::BI__builtin_ia32_vpcomud: + case X86::BI__builtin_ia32_vpcomuq: + case X86::BI__builtin_ia32_vpcomb: + case X86::BI__builtin_ia32_vpcomw: + case X86::BI__builtin_ia32_vpcomd: + case X86::BI__builtin_ia32_vpcomq: i = 2; l = 0; u = 7; break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u); } diff --git a/test/Sema/builtins-x86.c b/test/Sema/builtins-x86.c index 71004e1e2b..326d2a3a7a 100644 --- a/test/Sema/builtins-x86.c +++ b/test/Sema/builtins-x86.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s +typedef long long __m128i __attribute__((__vector_size__(16))); typedef float __m128 __attribute__((__vector_size__(16))); typedef double __m128d __attribute__((__vector_size__(16))); @@ -32,3 +33,35 @@ __mmask16 test__builtin_ia32_cmpps512_mask(__m512d __a, __m512d __b) { __mmask8 test__builtin_ia32_cmppd512_mask(__m512d __a, __m512d __b) { __builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 0); // expected-error {{argument should be a value from 0 to 31}} } + +__m128i test__builtin_ia32_vpcomub(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomuw(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomud(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomuq(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomb(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomw(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomd(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +} + +__m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) { + __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}} +}