[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 9 11:04:01 PST 2021


tra added subscribers: kpyzhov, rnk.
tra added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4290-4293
-  // Do not set COMDAT attribute for CUDA/HIP stub functions to prevent
-  // them being "merged" by the COMDAT Folding linker optimization.
-  if (D.hasAttr<CUDAGlobalAttr>())
-    return false;
----------------
This was added in D63277 specifically to deal with comdat-related issue on windows. 

We do need to have unique addresses for each kernel stub. Placing stubs into comdat may allow them to be merged into one and that would be a problem.
https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=vs-2019 

@rnk, at kpyzhov -- how do we make sure that identical functions are placed in comdat (needed for templates) but do not get comdat-folded with `/OPT:ICF`? 



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

https://reviews.llvm.org/D112492



More information about the cfe-commits mailing list