[PATCH] D123812: [CUDA] Add wrapper code generation for registering CUDA images

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 13:47:49 PDT 2022


jhuber6 added inline comments.


================
Comment at: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp:351
+///       required for texture / surface / managed variables.
+Function *createRegisterGlobalsFunction(Module &M) {
+  LLVMContext &C = M.getContext();
----------------
tra wrote:
> Do you think generation of the CUDA registration glue could be shared with the front-end?
> 
I was thinking about it, but ultimately decided to keep the noise outside of the new driver to a minimum. Maybe if we move to the offloading entries being a common format we can easily share this code. Keeping it in Clang would have the advantage that it's easier to test directly and ensures we don't de-sync if anything changes. The only downside is that in the future I may want to push this functionality to a linker plugin or similar, which would require pulling it out of Clang again to prevent us needing to link in Clang to build LLVM.

Also needing to do this all through the builder API isn't ideal, it would be nice if we had some kind of runtime to call to do this for us, but I didn't feel like adding yet another shared library for CUDA. I considered putting it inside the cuda header wrappers as well, but forcing every CUDA file to have some externally visible weak registration blob didn't sit well with me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123812/new/

https://reviews.llvm.org/D123812



More information about the cfe-commits mailing list