diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index abb83701759ce..0c25a40d94a10 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -103,8 +103,10 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA, // ToDo: Remove this option after AMDGPU backend supports ISA-level linking. // Since AMDGPU backend currently does not support ISA-level linking, all // called functions need to be imported. - if (IsThinLTO) + if (IsThinLTO) { LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all")); + LldArgs.push_back(Args.MakeArgString("-plugin-opt=-avail-extern-to-local")); + } for (const Arg *A : Args.filtered(options::OPT_mllvm)) { LldArgs.push_back( diff --git a/clang/test/Driver/hip-thinlto.hip b/clang/test/Driver/hip-thinlto.hip new file mode 100644 index 0000000000000..4227cd3f2e9f9 --- /dev/null +++ b/clang/test/Driver/hip-thinlto.hip @@ -0,0 +1,8 @@ +// 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; +}