[OpenMP] Link the bitcode library late for device LTO
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 11 Jan 2022 15:53:59 +0000 (10:53 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 1 Feb 2022 04:11:41 +0000 (23:11 -0500)
commit3762111aa9608fce12c4f938bfef2b38aed766dd
tree9a9f062009b37bdaba64abcf0dd0b7bfffb726f3
parentc732c3df749b3d5a127708c05656a226ed5753ab
[OpenMP] Link the bitcode library late for device LTO

Summary:
This patch adds support for linking the OpenMP device bitcode library
late when doing LTO. This simply passes it in as an additional device
file when doing the final device linking phase with LTO. This has the
advantage that we don't link it multiple times, and the device
references do not get inlined and prevent us from doing needed OpenMP
optimizations when we have visiblity of the whole module.
Fix some failings where the implicit conversion of an Error to an
Expected triggered the deleted copy constructor.

Depends on D116675

Differential revision: https://reviews.llvm.org/D117048
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp