Files
clang-p2996/clang/test/Driver/hip-thinlto.hip
Shilei Tian fcf0f810ac [Clang][AMDGPU] Enable avail-extern-to-local for ThinLTO in HIP (#134476)
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.
2025-04-14 11:52:19 -04:00

9 lines
248 B
Plaintext

// RUN: %clang -foffload-lto=thin -nogpulib -nogpuinc %s -### 2>&1 | FileCheck %s
// CHECK: -plugin-opt=thinlto
// CHECK-SAME: -plugin-opt=-force-import-all
// CHECK-SAME: -plugin-opt=-avail-extern-to-local
int main(int, char *[]) {
return 0;
}