Extract registering device variable to CUDA runtime codegen function since it
will be called in multiple places.
Details
- Reviewers
tra - Commits
- rG0b2af1a28894: [NFC][CUDA] Refactor registering device variable
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
158 | clang-format it? void hanging all by itself looks odd. | |
925 | The name and the functionality do not match -- despite what the name says, the function will set internal linkage on any var with device-side attributes. Rename to internalizeDeviceSideVars ? | |
clang/lib/CodeGen/CGCUDARuntime.h | ||
85 | handleVarRegistration to make it distinct from the implementation of specific registration kinds. Maybe, move registerDevice* functions under private: as they will only be used from the top-level handler called by CGM. | |
88 | Just registerDeviceVar would do. |
Couple of minor nits LGTM otherwise,
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
925 | My suggestion could be improved, too. Vars -> Var as we're dealing with only one VarDecl here. | |
clang/lib/CodeGen/CodeGenModule.cpp | ||
4300–4302 | Should we fold internalizeDeviceSideVar into handleVarRegistration or call it from there? |
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
925 | will do | |
clang/lib/CodeGen/CodeGenModule.cpp | ||
4300–4302 | For function scope static variable, I only need to call handleVarRegistration since the variable already has internal linkage. If internalizeDeviceSideVars is absorbed into handleVarRegistration, there be useless work and I also need to define a useless automatic variable Linkage and pass it to handleVarRegistration. |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
4300–4302 | internalizeDeviceSideVars is nearly trivial. I doubt that it will have any measureable impact, either way. At the moment handleVarRegistration() is called only from here. Are you saying that separate internalization and registration will be needed in the future changes? If that's the case I'm fine keeping them separate. As things are in the patch, I do not see why internalizeDeviceSideVars needs to be a base class interface. It's always used along with handleVarRegistration and we have no need to be able to override it independently of it. Folding it into or calling it from handleVarRegistration looks like a natural fit. |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
4300–4302 | It is used differently in https://reviews.llvm.org/D95560, where only handleVarRegistration is called. |
clang-format it? void hanging all by itself looks odd.