From: Erich Keane Date: Wed, 20 Jan 2021 19:33:22 +0000 (-0800) Subject: [EXTINT][OMP] Fix _ExtInt type checking in device code X-Git-Tag: llvmorg-13-init~674 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8776e3f289c19ee2e85c593792806e6503408d59;p=platform%2Fupstream%2Fllvm.git [EXTINT][OMP] Fix _ExtInt type checking in device code _ExtInt gets stuck in the device-type-checking for __int128 if it is between 65 and 128 bits inclusive. Anything larger or smaller was permitted despite this, so this is simply enabling 65-128 bit _ExtInts. _ExtInt is supported on all our current ABIs, but we stil use the hasExtIntType in the target info to differentiate here so that it can be disabled. --- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e936578..758b2ed 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10468,8 +10468,9 @@ def err_omp_invariant_or_linear_dependency : Error< "expected loop invariant expression or ' * %0 + ' kind of expression">; def err_omp_wrong_dependency_iterator_type : Error< "expected an integer or a pointer type of the outer loop counter '%0' for non-rectangular nests">; -def err_device_unsupported_type : Error < - "%0 requires %1 bit size %2 type support, but device '%3' does not support it">; +def err_device_unsupported_type + : Error<"%0 requires %select{|%2 bit size}1 %3 type support, but device " + "'%4' does not support it">; def err_omp_lambda_capture_in_declare_target_not_to : Error< "variable captured in declare target region must appear in a to clause">; def err_omp_device_type_mismatch : Error< diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index cca82fb..23dba75 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1795,6 +1795,15 @@ void Sema::checkDeviceDecl(const ValueDecl *D, SourceLocation Loc) { if (Ty->isDependentType()) return; + if (Ty->isExtIntType()) { + if (!Context.getTargetInfo().hasExtIntType()) { + targetDiag(Loc, diag::err_device_unsupported_type) + << D << false /*show bit size*/ << 0 /*bitsize*/ + << Ty << Context.getTargetInfo().getTriple().str(); + } + return; + } + if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) || ((Ty->isFloat128Type() || (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128)) && @@ -1802,7 +1811,8 @@ void Sema::checkDeviceDecl(const ValueDecl *D, SourceLocation Loc) { (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 && !Context.getTargetInfo().hasInt128Type())) { targetDiag(Loc, diag::err_device_unsupported_type) - << D << static_cast(Context.getTypeSize(Ty)) << Ty + << D << true /*show bit size*/ + << static_cast(Context.getTypeSize(Ty)) << Ty << Context.getTargetInfo().getTriple().str(); targetDiag(D->getLocation(), diag::note_defined_here) << D; } diff --git a/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp b/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp index e56105a..814a475 100644 --- a/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ b/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -131,3 +131,7 @@ struct B { enum { value = bool(Sp::value) || bool(Tp::value) }; typedef typename A_type::type type; }; + +void bar(_ExtInt(66) a) { + auto b = a; +}