From c97be2c377852fad7eb38409aae5692fa417e49b Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Thu, 26 Mar 2020 11:21:45 -0400 Subject: [hip] Remove `hip_pinned_shadow`. Summary: - Use `device_builtin_surface` and `device_builtin_texture` for surface/texture reference support. So far, both the host and device use the same reference type, which could be revised later when interface/implementation is stablized. Reviewers: yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77583 --- clang/lib/CodeGen/CodeGenModule.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1645a9eb17de..8b7d52b88146 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1955,9 +1955,9 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, } } -void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV, bool SkipCheck) { - assert(SkipCheck || (!GV->isDeclaration() && - "Only globals with definition can force usage.")); +void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) { + assert(!GV->isDeclaration() && + "Only globals with definition can force usage."); LLVMUsed.emplace_back(GV); } @@ -2520,7 +2520,6 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { !Global->hasAttr() && !Global->hasAttr() && !Global->hasAttr() && - !(LangOpts.HIP && Global->hasAttr()) && !Global->getType()->isCUDADeviceBuiltinSurfaceType() && !Global->getType()->isCUDADeviceBuiltinTextureType()) return; @@ -3928,10 +3927,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, D->getType()->isCUDADeviceBuiltinTextureType()); // HIP pinned shadow of initialized host-side global variables are also // left undefined. - bool IsHIPPinnedShadowVar = - getLangOpts().CUDAIsDevice && D->hasAttr(); - if (getLangOpts().CUDA && (IsCUDASharedVar || IsCUDAShadowVar || - IsCUDADeviceShadowVar || IsHIPPinnedShadowVar)) + if (getLangOpts().CUDA && + (IsCUDASharedVar || IsCUDAShadowVar || IsCUDADeviceShadowVar)) Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); else if (D->hasAttr()) Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); @@ -4039,8 +4036,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, // global variables become internal definitions. These have to // be internal in order to prevent name conflicts with global // host variables with the same name in a different TUs. - if (D->hasAttr() || D->hasAttr() || - D->hasAttr()) { + if (D->hasAttr() || D->hasAttr()) { Linkage = llvm::GlobalValue::InternalLinkage; // Shadow variables and their properties must be registered with CUDA // runtime. Skip Extern global variables, which will be registered in @@ -4087,15 +4083,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, } } - // HIPPinnedShadowVar should remain in the final code object irrespective of - // whether it is used or not within the code. Add it to used list, so that - // it will not get eliminated when it is unused. Also, it is an extern var - // within device code, and it should *not* get initialized within device code. - if (IsHIPPinnedShadowVar) - addUsedGlobal(GV, /*SkipCheck=*/true); - else - GV->setInitializer(Init); - + GV->setInitializer(Init); if (emitter) emitter->finalize(GV); -- cgit v1.2.3