From: Jinsong Ji Date: Wed, 4 Sep 2019 15:22:26 +0000 (+0000) Subject: [PowerPC][Altivec][Clang] Check compile-time constant for vec_dst* X-Git-Tag: llvmorg-11-init~10069 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a71c199f82cd3309dd9a1a18d01c28437e672fe3;p=platform%2Fupstream%2Fllvm.git [PowerPC][Altivec][Clang] Check compile-time constant for vec_dst* Summary: This is follow up of https://reviews.llvm.org/D66699. We might get ISEL ICE if we call vec_dss with non const 3rd arg. ``` Cannot select: intrinsic %llvm.ppc.altivec.dst ``` We should check the constraints in clang and generate better error messages. Reviewers: nemanjai, hfinkel, echristo, #powerpc, wuzish Reviewed By: #powerpc, wuzish Subscribers: wuzish, kbarton, MaskRay, shchenz, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66748 llvm-svn: 370912 --- diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index 249e38c..41427cc 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -57,10 +57,10 @@ BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "") BUILTIN(__builtin_altivec_dss, "vUIi", "") BUILTIN(__builtin_altivec_dssall, "v", "") -BUILTIN(__builtin_altivec_dst, "vvC*iUi", "") -BUILTIN(__builtin_altivec_dstt, "vvC*iUi", "") -BUILTIN(__builtin_altivec_dstst, "vvC*iUi", "") -BUILTIN(__builtin_altivec_dststt, "vvC*iUi", "") +BUILTIN(__builtin_altivec_dst, "vvC*iUIi", "") +BUILTIN(__builtin_altivec_dstt, "vvC*iUIi", "") +BUILTIN(__builtin_altivec_dstst, "vvC*iUIi", "") +BUILTIN(__builtin_altivec_dststt, "vvC*iUIi", "") BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "") diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index bb06517..b060ec7 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3231,6 +3231,11 @@ bool Sema::CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case PPC::BI__builtin_tabortdci: return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) || SemaBuiltinConstantArgRange(TheCall, 2, 0, 31); + case PPC::BI__builtin_altivec_dst: + case PPC::BI__builtin_altivec_dstt: + case PPC::BI__builtin_altivec_dstst: + case PPC::BI__builtin_altivec_dststt: + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 3); case PPC::BI__builtin_vsx_xxpermdi: case PPC::BI__builtin_vsx_xxsldwi: return SemaBuiltinVSX(TheCall); diff --git a/clang/test/CodeGen/builtins-ppc-error.c b/clang/test/CodeGen/builtins-ppc-error.c index 067f6b4..39a2458 100644 --- a/clang/test/CodeGen/builtins-ppc-error.c +++ b/clang/test/CodeGen/builtins-ppc-error.c @@ -78,3 +78,14 @@ void testDSS(int index) { vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must be a constant integer}} vec_dss(5); //expected-error {{argument value 5 is outside the valid range [0, 3]}} } + +void testDST(int index) { + vec_dst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dst' must be a constant integer}} + vec_dst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}} + vec_dstt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstt' must be a constant integer}} + vec_dstt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}} + vec_dstst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstst' must be a constant integer}} + vec_dstst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}} + vec_dststt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dststt' must be a constant integer}} + vec_dststt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}} +}