diff options
| author | Michael Liao <michael.hliao@gmail.com> | 2021-08-08 11:28:28 -0400 |
|---|---|---|
| committer | Michael Liao <michael.hliao@gmail.com> | 2021-08-09 13:27:40 -0400 |
| commit | 6ec36d18ec7b29b471bbe50502beb5b35de3975c (patch) | |
| tree | f7a2a01a73ad4562a352bd1e27e5919202d4317f /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | dc11e69dd4089ba66733d25b182fedee9b54ac81 (diff) | |
[cuda] Mark builtin texture/surface reference variable as 'externally_initialized'.
- They need to be preserved even if there's no reference within the
device code as the host code may need to initialize them based on the
application logic.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D107718
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 49a1396b58e3..13520861fe9b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4438,7 +4438,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, if (GV && LangOpts.CUDA) { if (LangOpts.CUDAIsDevice) { if (Linkage != llvm::GlobalValue::InternalLinkage && - (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>())) + (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>() || + D->getType()->isCUDADeviceBuiltinSurfaceType() || + D->getType()->isCUDADeviceBuiltinTextureType())) GV->setExternallyInitialized(true); } else { getCUDARuntime().internalizeDeviceSideVar(D, Linkage); |
