[all-commits] [llvm/llvm-project] 8784b6: [Clang] Allow bitcode linking when the input is LL...
Joseph Huber via All-commits
all-commits at lists.llvm.org
Tue Jun 20 06:03:15 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8784b6a8540f4a333690e7233587859f1d82f620
https://github.com/llvm/llvm-project/commit/8784b6a8540f4a333690e7233587859f1d82f620
Author: Joseph Huber <jhuber6 at vols.utk.edu>
Date: 2023-06-20 (Tue, 20 Jun 2023)
Changed paths:
M clang/include/clang/CodeGen/CodeGenAction.h
M clang/lib/CodeGen/CGCall.cpp
M clang/lib/CodeGen/CGCall.h
M clang/lib/CodeGen/CodeGenAction.cpp
M clang/test/CodeGen/link-bitcode-file.c
A clang/test/CodeGen/link-builtin-bitcode.c
Log Message:
-----------
[Clang] Allow bitcode linking when the input is LLVM-IR
Clang provides the `-mlink-bitcode-file` and `-mlink-builtin-bitcode`
options to insert LLVM-IR into the current TU. These are usefuly
primarily for including LLVM-IR files that require special handling to
be correct and cannot be linked normally, such as GPU vendor libraries
like `libdevice.10.bc`. Currently these options can only be used if the
source input goes through the AST consumer path. This patch makes the
changes necessary to also support this when the input is LLVM-IR. This
will allow the following operation:
```
clang in.bc -Xclang -mlink-builtin-bitcode -Xclang libdevice.10.bc
```
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D152391
Commit: efacdfc235e327341d2b8a733d9963fb526cf17b
https://github.com/llvm/llvm-project/commit/efacdfc235e327341d2b8a733d9963fb526cf17b
Author: Joseph Huber <jhuber6 at vols.utk.edu>
Date: 2023-06-20 (Tue, 20 Jun 2023)
Changed paths:
M clang/test/Driver/linker-wrapper.c
M clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
M clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
Log Message:
-----------
[LinkerWrapper] Support linking vendor bitcode late
The GPU vendors currently provide bitcode files for their device
runtime. These files need to be handled specially as they are not built
to be linked in with a standard `llvm-link` call or through LTO linking.
This patch adds an alternative to use the existing clang handling of
these libraries that does the necessary magic to make this work.
We do this by causing the LTO backend to emit bitcode before running the
backend. We then pass this through to clang which uses the existing
support which has been fixed to support this by D152391. The backend
will then be run with the merged module.
This patch adds the `--builtin-bitcode=<triple>=file.bc` to specify a single
file, or just `--clang-backend` to let the toolchain handle its defaults
(currently nothing for NVPTX and the ROCm device libs for AMDGPU). This may have
a performance impact due to running the optimizations again, we could
potentially disable optimizations in LTO and only do the linking if this is an
issue.
This should allow us to resolve issues when relying on the `linker-wrapper` to
do a late linking that may depend on vendor libraries.
Depends on D152391
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D152442
Compare: https://github.com/llvm/llvm-project/compare/87da4b6fa6ea...efacdfc235e3
More information about the All-commits
mailing list