Update an instance of dyn_cast -> cast and other NFC clang-tidy fixes
for Clang CUDA codegen.
Details
- Reviewers
tra yaxunl - Commits
- rG9fb9c6b91e3a: [Clang][NFC] Clang CUDA codegen clean-up
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
The description is a bit misleading. The dyn_cast->cast appears to be a minor part of this patch.
I'd separate clang-tidy cleanups into a separate patch or would just describe all of these changes as a clean-up. dyn_cast->cast is an NFC change here, too, considering that we're operating on a type of FunctionDecl *cudaLaunchKernelFD.
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
240–243 | Nit: you could remove these {...} now, too. |
I agree. I've done the latter.
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
240–243 | I retained this part due to the extra comment in line with LLVM style: |
@tra While on this, I also wanted to ask as to why clang cuda codegen is using an argument on the global ctor and the dtor it's generating. The argument is unused and I couldn't find any code comments to support it in either CGCUDANV.cpp or CodeGenModule.cpp. I assume there is a reason because CodeGenModule.cpp is generating an explicit bitcast and has additional utilities to convert the function type to one with no arguments. Without the argument, one could just use appendToGlobalCtors/Dtors from ModuleUtils.
It's a good question, and I don't have a good answer. It's quite possible that the parameter is not needed.
clang/lib/CodeGen/CGCUDANV.cpp | ||
---|---|---|
240–243 |
I think the comment can be hoisted up in this case. Up to you. |
As a result of this parameter, there appears to be a lot of code in CodegenModule.cpp to add the ctor/dtor to the global lists. All of that would disappear with a single call to appendToGlobalCtors or appendToGlobalDtors if we got rid of the argument. Perhaps the extra argument was used initially for debugging or the fact that an extra argument bumps up the stack frame and makes something else work?
Nit: you could remove these {...} now, too.