[PATCH] D96195: [HIP] Fix managed variable linkage
Artem Belevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 17:49:13 PST 2021
tra added inline comments.
================
Comment at: clang/lib/CodeGen/CGCUDANV.cpp:1017
+
+void CGNVCUDARuntime::transformManagedVars() {
+ for (auto &&Info : DeviceVars) {
----------------
A comment about how exactly we're transforming the vars would be helpful.
================
Comment at: clang/lib/CodeGen/CGCUDARuntime.h:107
+ /// Transform managed variables in device compilation.
+ virtual void transformManagedVars() = 0;
};
----------------
Can we fold it into `makeModuleCtorFunction` ? It does not look like something we would need to customize independently of other glue generating machinery.
================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:463-466
+ if (Context.getLangOpts().CUDAIsDevice)
+ CUDARuntime->transformManagedVars();
+ else if (llvm::Function *CudaCtorFunction =
+ CUDARuntime->makeModuleCtorFunction())
----------------
This does not look right.
Was `transformManagedVars()` supposed to *replace* `AddGlobalCtor(CudaCtorFunction)`?
I would expect it to be in addition to the ctor we create now.
```
if (Context.getLangOpts().CUDAIsDevice)
CUDARuntime->transformManagedVars();
if (llvm::Function *CudaCtorFunction =
CUDARuntime->makeModuleCtorFunction())
AddGlobalCtor(CudaCtorFunction);
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96195/new/
https://reviews.llvm.org/D96195
More information about the llvm-commits
mailing list