Skip to content

Commit e8845cc

Browse files
committed
Simplify host_pipe attribute checking
1 parent 20e3d80 commit e8845cc

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,6 @@ static bool SYCLCUDAIsSYCLDevice(const clang::LangOptions &LangOpts) {
110110
return LangOpts.SYCLIsDevice && LangOpts.CUDA && !LangOpts.CUDAIsDevice;
111111
}
112112

113-
static bool isSyclType(QualType Ty, SYCLTypeAttr::SYCLType TypeName) {
114-
const auto *RD = Ty->getAsCXXRecordDecl();
115-
if (!RD)
116-
return false;
117-
118-
if (const auto *Attr = RD->getAttr<SYCLTypeAttr>())
119-
return Attr->getType() == TypeName;
120-
121-
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
122-
if (CXXRecordDecl *TemplateDecl =
123-
CTSD->getSpecializedTemplate()->getTemplatedDecl())
124-
if (const auto *Attr = TemplateDecl->getAttr<SYCLTypeAttr>())
125-
return Attr->getType() == TypeName;
126-
127-
return false;
128-
}
129-
130113
CodeGenModule::CodeGenModule(ASTContext &C,
131114
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
132115
const HeaderSearchOptions &HSO,
@@ -5525,20 +5508,22 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
55255508

55265509
if (getLangOpts().SYCLIsDevice) {
55275510
const RecordDecl *RD = D->getType()->getAsRecordDecl();
5528-
// Add IR attributes if add_ir_attribute_global_variable is attached to
5529-
// type.
5530-
if (RD && RD->hasAttr<SYCLAddIRAttributesGlobalVariableAttr>())
5531-
AddGlobalSYCLIRAttributes(GV, RD);
5532-
// If VarDecl has a type decorated with SYCL device_global attribute
5533-
// emit IR attribute 'sycl-unique-id'.
5534-
if (RD && (RD->hasAttr<SYCLDeviceGlobalAttr>()))
5535-
addSYCLUniqueID(GV, D, Context);
5536-
5537-
// If VarDecl type is SYCLTypeAttr::host_pipe, emit the IR attribute
5538-
// 'sycl-unique-id'.
5539-
auto Ty = D->getType();
5540-
if (isSyclType(Ty, SYCLTypeAttr::host_pipe))
5541-
addSYCLUniqueID(GV, D, Context);
5511+
5512+
if (RD) {
5513+
// Add IR attributes if add_ir_attribute_global_variable is attached to
5514+
// type.
5515+
if (RD->hasAttr<SYCLAddIRAttributesGlobalVariableAttr>())
5516+
AddGlobalSYCLIRAttributes(GV, RD);
5517+
// If VarDecl has a type decorated with SYCL device_global attribute
5518+
// emit IR attribute 'sycl-unique-id'.
5519+
if (RD->hasAttr<SYCLDeviceGlobalAttr>())
5520+
addSYCLUniqueID(GV, D, Context);
5521+
// If VarDecl type is SYCLTypeAttr::host_pipe, emit the IR attribute
5522+
// 'sycl-unique-id'.
5523+
if (const auto *Attr = RD->getAttr<SYCLTypeAttr>())
5524+
if (Attr->getType() == SYCLTypeAttr::SYCLType::host_pipe)
5525+
addSYCLUniqueID(GV, D, Context);
5526+
}
55425527
}
55435528

55445529
if (D->getType().isRestrictQualified()) {

0 commit comments

Comments
 (0)