diff options
| author | Artem Belevich <tra@google.com> | 2020-03-27 10:01:38 -0700 |
|---|---|---|
| committer | Artem Belevich <tra@google.com> | 2020-03-27 10:01:38 -0700 |
| commit | fe8063e1a0e983f1b4d38530f4fb157a26c0771c (patch) | |
| tree | 5a5a08763659010e689e88b1bcdbdbf89052d0e7 /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | 667781592a44ed02f42d4a07c85cf1a898543304 (diff) | |
Revert "[cuda][hip] Add CUDA builtin surface/texture reference support."
This reverts commit 6a9ad5f3f4ac66f0cae592e911f4baeb6ee5eca6.
The patch breaks CUDA copmilation.
Differential Revision: https://reviews.llvm.org/D76365
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index fbde1bf5cab7..b91c38ec9956 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -713,19 +713,6 @@ llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) { TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) { if (!TBAA) return TBAAAccessInfo(); - if (getLangOpts().CUDAIsDevice) { - // As CUDA builtin surface/texture types are replaced, skip generating TBAA - // access info. - if (AccessType->isCUDADeviceBuiltinSurfaceType()) { - if (getTargetCodeGenInfo().getCUDADeviceBuiltinSurfaceDeviceType() != - nullptr) - return TBAAAccessInfo(); - } else if (AccessType->isCUDADeviceBuiltinTextureType()) { - if (getTargetCodeGenInfo().getCUDADeviceBuiltinTextureDeviceType() != - nullptr) - return TBAAAccessInfo(); - } - } return TBAA->getAccessInfo(AccessType); } @@ -2520,9 +2507,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { !Global->hasAttr<CUDAGlobalAttr>() && !Global->hasAttr<CUDAConstantAttr>() && !Global->hasAttr<CUDASharedAttr>() && - !(LangOpts.HIP && Global->hasAttr<HIPPinnedShadowAttr>()) && - !Global->getType()->isCUDADeviceBuiltinSurfaceType() && - !Global->getType()->isCUDADeviceBuiltinTextureType()) + !(LangOpts.HIP && Global->hasAttr<HIPPinnedShadowAttr>())) return; } else { // We need to emit host-side 'shadows' for all global @@ -3922,16 +3907,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, !getLangOpts().CUDAIsDevice && (D->hasAttr<CUDAConstantAttr>() || D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDASharedAttr>()); - bool IsCUDADeviceShadowVar = - getLangOpts().CUDAIsDevice && - (D->getType()->isCUDADeviceBuiltinSurfaceType() || - D->getType()->isCUDADeviceBuiltinTextureType()); // HIP pinned shadow of initialized host-side global variables are also // left undefined. bool IsHIPPinnedShadowVar = getLangOpts().CUDAIsDevice && D->hasAttr<HIPPinnedShadowAttr>(); - if (getLangOpts().CUDA && (IsCUDASharedVar || IsCUDAShadowVar || - IsCUDADeviceShadowVar || IsHIPPinnedShadowVar)) + if (getLangOpts().CUDA && + (IsCUDASharedVar || IsCUDAShadowVar || IsHIPPinnedShadowVar)) Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); else if (D->hasAttr<LoaderUninitializedAttr>()) Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); @@ -4042,48 +4023,25 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, if (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>() || D->hasAttr<HIPPinnedShadowAttr>()) { Linkage = llvm::GlobalValue::InternalLinkage; - // Shadow variables and their properties must be registered with CUDA - // runtime. Skip Extern global variables, which will be registered in - // the TU where they are defined. + + // Shadow variables and their properties must be registered + // with CUDA runtime. + unsigned Flags = 0; + if (!D->hasDefinition()) + Flags |= CGCUDARuntime::ExternDeviceVar; + if (D->hasAttr<CUDAConstantAttr>()) + Flags |= CGCUDARuntime::ConstantDeviceVar; + // Extern global variables will be registered in the TU where they are + // defined. if (!D->hasExternalStorage()) - getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(), - D->hasAttr<CUDAConstantAttr>()); - } else if (D->hasAttr<CUDASharedAttr>()) { + getCUDARuntime().registerDeviceVar(D, *GV, Flags); + } else if (D->hasAttr<CUDASharedAttr>()) // __shared__ variables are odd. Shadows do get created, but // they are not registered with the CUDA runtime, so they // can't really be used to access their device-side // counterparts. It's not clear yet whether it's nvcc's bug or // a feature, but we've got to do the same for compatibility. Linkage = llvm::GlobalValue::InternalLinkage; - } else if (D->getType()->isCUDADeviceBuiltinSurfaceType() || - D->getType()->isCUDADeviceBuiltinTextureType()) { - // Builtin surfaces and textures and their template arguments are - // also registered with CUDA runtime. - Linkage = llvm::GlobalValue::InternalLinkage; - const ClassTemplateSpecializationDecl *TD = - cast<ClassTemplateSpecializationDecl>( - D->getType()->getAs<RecordType>()->getDecl()); - const TemplateArgumentList &Args = TD->getTemplateInstantiationArgs(); - if (TD->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>()) { - assert(Args.size() == 2 && - "Unexpected number of template arguments of CUDA device " - "builtin surface type."); - auto SurfType = Args[1].getAsIntegral(); - if (!D->hasExternalStorage()) - getCUDARuntime().registerDeviceSurf(D, *GV, !D->hasDefinition(), - SurfType.getSExtValue()); - } else { - assert(Args.size() == 3 && - "Unexpected number of template arguments of CUDA device " - "builtin texture type."); - auto TexType = Args[1].getAsIntegral(); - auto Normalized = Args[2].getAsIntegral(); - if (!D->hasExternalStorage()) - getCUDARuntime().registerDeviceTex(D, *GV, !D->hasDefinition(), - TexType.getSExtValue(), - Normalized.getZExtValue()); - } - } } } |
