[all-commits] [llvm/llvm-project] 80072f: [CUDA][HIP] Allow comdat for kernels

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Wed Nov 10 13:43:19 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 80072fde61d40a4e8a9da673476730d34a483fa2
      https://github.com/llvm/llvm-project/commit/80072fde61d40a4e8a9da673476730d34a483fa2
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2021-11-10 (Wed, 10 Nov 2021)

  Changed paths:
    M clang/lib/CodeGen/CGCUDANV.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/test/CodeGenCUDA/kernel-stub-name.cu
    M clang/test/CodeGenCUDA/usual-deallocators.cu

  Log Message:
  -----------
  [CUDA][HIP] Allow comdat for kernels

Two identical instantiations of a template function can be emitted by two TU's
with linkonce_odr linkage without causing duplicate symbols in linker. MSVC
also requires these symbols be in comdat sections. Linux does not require
the symbols in comdat sections to be merged by linker but by default
clang puts them in comdat sections.

If a template kernel is instantiated identically in two TU's. MSVC requires
that them to be in comdat sections, otherwise MSVC linker will diagnose them as
duplicate symbols. However, currently clang does not put instantiated template
kernels in comdat sections, which causes link error for MSVC.

This patch allows putting instantiated template kernels into comdat sections.

Reviewed by: Artem Belevich, Reid Kleckner

Differential Revision: https://reviews.llvm.org/D112492




More information about the All-commits mailing list