From 3faed8de6341a01c63c410891211a0cf488f5755 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 5 Jun 2018 21:54:35 +0000 Subject: [PATCH] [X86] Make __builtin_ia32_vec_ext_v2si require ICE for its index argument. Add warnings for out of range indices for __builtin_ia32_vec_ext_v2si, __builtin_ia32_vec_ext_v4hi, and __builtin_ia32_vec_set_v4hi. These should take a constant value for an index and that constant should be a valid element number. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334051 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/BuiltinsX86.def | 2 +- lib/Sema/SemaChecking.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index 6f7ecaf28c..0657354bd5 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -142,7 +142,7 @@ TARGET_BUILTIN(__builtin_ia32_movntq, "vV1LLi*V1LLi", "n", "mmx") TARGET_BUILTIN(__builtin_ia32_vec_init_v2si, "V2iii", "nc", "mmx") TARGET_BUILTIN(__builtin_ia32_vec_init_v4hi, "V4sssss", "nc", "mmx") TARGET_BUILTIN(__builtin_ia32_vec_init_v8qi, "V8ccccccccc", "nc", "mmx") -TARGET_BUILTIN(__builtin_ia32_vec_ext_v2si, "iV2ii", "nc", "mmx") +TARGET_BUILTIN(__builtin_ia32_vec_ext_v2si, "iV2iIi", "nc", "mmx") // MMX2 (MMX+SSE) intrinsics TARGET_BUILTIN(__builtin_ia32_cvtpi2ps, "V4fV4fV2i", "nc", "mmx,sse") diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 7b9975e6ab..643c103c8a 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2555,7 +2555,14 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case X86::BI_mm_prefetch: i = 1; l = 0; u = 7; break; + case X86::BI__builtin_ia32_vec_ext_v2si: + i = 1; l = 0; u = 1; + break; + case X86::BI__builtin_ia32_vec_ext_v4hi: + i = 1; l = 0; u = 3; + break; case X86::BI__builtin_ia32_sha1rnds4: + case X86::BI__builtin_ia32_vec_set_v4hi: i = 2; l = 0; u = 3; break; case X86::BI__builtin_ia32_vpermil2pd: -- 2.40.0