[llvm-branch-commits] [clang] bf2a6a3 - Fix missing error for use of 128-bit integer inside SPIR64 device code.
Author: Jennifer Yu Date: 2020-12-04T14:31:50-08:00 New Revision: bf2a6a3326761af4a5ff4836de2b62df0d7a44b6 URL: https://github.com/llvm/llvm-project/commit/bf2a6a3326761af4a5ff4836de2b62df0d7a44b6 DIFF: https://github.com/llvm/llvm-project/commit/bf2a6a3326761af4a5ff4836de2b62df0d7a44b6.diff LOG: Fix missing error for use of 128-bit integer inside SPIR64 device code. Emit error for use of 128-bit integer inside device code had been already implemented in https://reviews.llvm.org/D74387. However, the error is not emitted for SPIR64, because for SPIR64, hasInt128Type return true. hasInt128Type: is also used to control generation of certain 128-bit predefined macros, initializer predefined 128-bit integer types and build 128-bit ArithmeticTypes. Except predefined macros, only the device target is considered, since error only emit when 128-bit integer is used inside device code, the host target (auxtarget) also needs to be considered. The change address: 1. (SPIR.h) Correct hasInt128Type() for SPIR targets. 2. Sema.cpp and SemaOverload.cpp: Add additional check to consider host target(auxtarget) when call to hasInt128Type. So that __int128_t and __int128() are allowed to avoid error when they used outside device code. 3. SemaType.cpp: add check for SYCLIsDevice to delay the error message. The error will be emitted if the use of 128-bit integer in the device code. Added: clang/test/SemaSYCL/int128.cpp Modified: clang/lib/Basic/Targets/SPIR.h clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/ext-int-cc.c Removed: diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index 6473138982c1..130ce1872dce 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -104,6 +104,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo { } bool hasExtIntType() const override { return true; } + + bool hasInt128Type() const override { return false; } }; class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { public: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 3901c5e1fec8..b99dc33d8748 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -236,7 +236,9 @@ void Sema::Initialize() { return; // Initialize predefined 128-bit integer types, if needed. - if (Context.getTargetInfo().hasInt128Type()) { + if (Context.getTargetInfo().hasInt128Type() || + (Context.getAuxTargetInfo() && + Context.getAuxTargetInfo()->hasInt128Type())) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 8db31c5fef12..8af7447b03ed 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -8199,12 +8199,16 @@ class BuiltinOperatorOverloadBuilder { ArithmeticTypes.push_back(S.Context.IntTy); ArithmeticTypes.push_back(S.Context.LongTy); ArithmeticTypes.push_back(S.Context.LongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.Int128Ty); ArithmeticTypes.push_back(S.Context.UnsignedIntTy); ArithmeticTypes.push_back(S.Context.UnsignedLongTy); ArithmeticTypes.push_back(S.Context.UnsignedLongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty); LastPromotedIntegralType = ArithmeticTypes.size(); LastPromotedArithmeticType = ArithmeticTypes.size(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index a8ba0643d41d..0d80bce10ffd 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1515,6 +1515,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { } case DeclSpec::TST_int128: if (!S.Context.getTargetInfo().hasInt128Type() && +!S.getLangOpts().SYCLIsDevice && !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__int128"; diff --git a/clang/test/CodeGen/ext-int-cc.c b/clang/test/CodeGen/ext-int-cc.c index 02e2f3aef274..dd21845592a8 100644 --- a/clang/test/CodeGen/ext-int-cc.c +++ b/clang/test/CodeGen/ext-int-cc.c @@ -43,7 +43,7 @@ void ParamPassing(_ExtInt(129) a, _ExtInt(128) b, _ExtInt(64) c) {} // SPARC: define void @ParamPassing(i129* byval(
[llvm-branch-commits] [clang] 224596c - Fix missing error for use of 128-bit integer inside SPIR64 device code.
Author: Jennifer Yu Date: 2020-12-07T10:08:30-08:00 New Revision: 224596c4fe02f741ca13a5dd7cecd8b4d2739034 URL: https://github.com/llvm/llvm-project/commit/224596c4fe02f741ca13a5dd7cecd8b4d2739034 DIFF: https://github.com/llvm/llvm-project/commit/224596c4fe02f741ca13a5dd7cecd8b4d2739034.diff LOG: Fix missing error for use of 128-bit integer inside SPIR64 device code. Emit error for use of 128-bit integer inside device code had been already implemented in https://reviews.llvm.org/D74387. However, the error is not emitted for SPIR64, because for SPIR64, hasInt128Type return true. hasInt128Type: is also used to control generation of certain 128-bit predefined macros, initializer predefined 128-bit integer types and build 128-bit ArithmeticTypes. Except predefined macros, only the device target is considered, since error only emit when 128-bit integer is used inside device code, the host target (auxtarget) also needs to be considered. The change address: 1. (SPIR.h) Correct hasInt128Type() for SPIR targets. 2. Sema.cpp and SemaOverload.cpp: Add additional check to consider host target(auxtarget) when call to hasInt128Type. So that __int128_t and __int128() are allowed to avoid error when they used outside device code. 3. SemaType.cpp: add check for SYCLIsDevice to delay the error message. The error will be emitted if the use of 128-bit integer in the device code. Reviewed By: Johannes Doerfert and Aaron Ballman Differential Revision: https://reviews.llvm.org/D92439 Added: clang/test/SemaSYCL/int128.cpp Modified: clang/lib/Basic/Targets/SPIR.h clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/ext-int-cc.c Removed: diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index 6473138982c1..130ce1872dce 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -104,6 +104,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo { } bool hasExtIntType() const override { return true; } + + bool hasInt128Type() const override { return false; } }; class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { public: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 3901c5e1fec8..b99dc33d8748 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -236,7 +236,9 @@ void Sema::Initialize() { return; // Initialize predefined 128-bit integer types, if needed. - if (Context.getTargetInfo().hasInt128Type()) { + if (Context.getTargetInfo().hasInt128Type() || + (Context.getAuxTargetInfo() && + Context.getAuxTargetInfo()->hasInt128Type())) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 8db31c5fef12..8af7447b03ed 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -8199,12 +8199,16 @@ class BuiltinOperatorOverloadBuilder { ArithmeticTypes.push_back(S.Context.IntTy); ArithmeticTypes.push_back(S.Context.LongTy); ArithmeticTypes.push_back(S.Context.LongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.Int128Ty); ArithmeticTypes.push_back(S.Context.UnsignedIntTy); ArithmeticTypes.push_back(S.Context.UnsignedLongTy); ArithmeticTypes.push_back(S.Context.UnsignedLongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty); LastPromotedIntegralType = ArithmeticTypes.size(); LastPromotedArithmeticType = ArithmeticTypes.size(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index a8ba0643d41d..0d80bce10ffd 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1515,6 +1515,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { } case DeclSpec::TST_int128: if (!S.Context.getTargetInfo().hasInt128Type() && +!S.getLangOpts().SYCLIsDevice && !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__int128"; diff --git a/clang/test/CodeGen/ext-int-cc.c b/clang/test/CodeGen/ext-int-cc.c index 02e2f3aef274..dd21845592a8 100644 --- a/clang/test/CodeGen/ext-int-cc.c +++ b/clang/test/CodeGen/ext-int-cc.c @@ -43,7 +43,7 @@ void P
[llvm-branch-commits] [clang] f8d5b49 - Fix missing error for use of 128-bit integer inside SPIR64 device code.
Author: Jennifer Yu Date: 2020-12-07T10:42:32-08:00 New Revision: f8d5b49c786f5766aa89b59606bd4c4ae10b46f6 URL: https://github.com/llvm/llvm-project/commit/f8d5b49c786f5766aa89b59606bd4c4ae10b46f6 DIFF: https://github.com/llvm/llvm-project/commit/f8d5b49c786f5766aa89b59606bd4c4ae10b46f6.diff LOG: Fix missing error for use of 128-bit integer inside SPIR64 device code. Emit error for use of 128-bit integer inside device code had been already implemented in https://reviews.llvm.org/D74387. However, the error is not emitted for SPIR64, because for SPIR64, hasInt128Type return true. hasInt128Type: is also used to control generation of certain 128-bit predefined macros, initializer predefined 128-bit integer types and build 128-bit ArithmeticTypes. Except predefined macros, only the device target is considered, since error only emit when 128-bit integer is used inside device code, the host target (auxtarget) also needs to be considered. The change address: 1. (SPIR.h) Correct hasInt128Type() for SPIR targets. 2. Sema.cpp and SemaOverload.cpp: Add additional check to consider host target(auxtarget) when call to hasInt128Type. So that __int128_t and __int128() are allowed to avoid error when they used outside device code. 3. SemaType.cpp: add check for SYCLIsDevice to delay the error message. The error will be emitted if the use of 128-bit integer in the device code. Reviewed By: Johannes Doerfert and Aaron Ballman Differential Revision: https://reviews.llvm.org/D92439 Added: clang/test/SemaSYCL/int128.cpp Modified: clang/lib/Basic/Targets/SPIR.h clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/ext-int-cc.c Removed: diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index 6473138982c1..130ce1872dce 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -104,6 +104,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo { } bool hasExtIntType() const override { return true; } + + bool hasInt128Type() const override { return false; } }; class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { public: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 3901c5e1fec8..b99dc33d8748 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -236,7 +236,9 @@ void Sema::Initialize() { return; // Initialize predefined 128-bit integer types, if needed. - if (Context.getTargetInfo().hasInt128Type()) { + if (Context.getTargetInfo().hasInt128Type() || + (Context.getAuxTargetInfo() && + Context.getAuxTargetInfo()->hasInt128Type())) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 02638beb6627..ff010fd6e4df 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -8187,12 +8187,16 @@ class BuiltinOperatorOverloadBuilder { ArithmeticTypes.push_back(S.Context.IntTy); ArithmeticTypes.push_back(S.Context.LongTy); ArithmeticTypes.push_back(S.Context.LongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.Int128Ty); ArithmeticTypes.push_back(S.Context.UnsignedIntTy); ArithmeticTypes.push_back(S.Context.UnsignedLongTy); ArithmeticTypes.push_back(S.Context.UnsignedLongLongTy); -if (S.Context.getTargetInfo().hasInt128Type()) +if (S.Context.getTargetInfo().hasInt128Type() || +(S.Context.getAuxTargetInfo() && + S.Context.getAuxTargetInfo()->hasInt128Type())) ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty); LastPromotedIntegralType = ArithmeticTypes.size(); LastPromotedArithmeticType = ArithmeticTypes.size(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index a8ba0643d41d..0d80bce10ffd 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1515,6 +1515,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { } case DeclSpec::TST_int128: if (!S.Context.getTargetInfo().hasInt128Type() && +!S.getLangOpts().SYCLIsDevice && !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__int128"; diff --git a/clang/test/CodeGen/ext-int-cc.c b/clang/test/CodeGen/ext-int-cc.c index 02e2f3aef274..dd21845592a8 100644 --- a/clang/test/CodeGen/ext-int-cc.c +++ b/clang/test/CodeGen/ext-int-cc.c @@ -43,7 +43,7 @@ void P