[all-commits] [llvm/llvm-project] b537a9: [Clang][AMDGPU] Enable `avail-extern-to-local` for...

Shilei Tian via All-commits all-commits at lists.llvm.org
Sun Apr 6 08:24:57 PDT 2025


  Branch: refs/heads/users/shiltian/hip-thinlto-disable-elim-avail-extern
  Home:   https://github.com/llvm/llvm-project
  Commit: b537a910f5869c9267ba20793d1531d63a205fdb
      https://github.com/llvm/llvm-project/commit/b537a910f5869c9267ba20793d1531d63a205fdb
  Author: Shilei Tian <i at tianshilei.me>
  Date:   2025-04-06 (Sun, 06 Apr 2025)

  Changed paths:
    M clang/lib/Driver/ToolChains/HIPAMD.cpp
    A clang/test/Driver/hip-thinlto.hip

  Log Message:
  -----------
  [Clang][AMDGPU] Enable `avail-extern-to-local` for ThinLTO in HIP

In HIP, the Clang driver already sets `force-import-all` when ThinLTO is
enabled. As a result, all imported functions get the `available_externally`
linkage. However, these functions are later removed by the
`EliminateAvailableExternallyPass`, effectively undoing the forced import and
eventually leading to link errors.

The `EliminateAvailableExternallyPass` provides an option to convert
`available_externally` functions into local functions, renaming them to avoid
conflicts. This behavior is exactly what we need for HIP. This PR enables that
option (`avail-extern-to-local`) alongside `force-import-all` when ThinLTO is
used.

With this change, ThinLTO almost works correctly on AMDGPU. The only remaining
issue is an undefined reference to `__assert_fail`, but that falls outside the
scope of this PR.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list