[clang] 3723868 - [OpenMP] Fix file arguments for embedding bitcode in the linker wrapper

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 10:46:09 PDT 2022


Author: Joseph Huber
Date: 2022-05-24T13:45:52-04:00
New Revision: 3723868d9e07de5d4a7468a4c2c74fc8517afc14

URL: https://github.com/llvm/llvm-project/commit/3723868d9e07de5d4a7468a4c2c74fc8517afc14
DIFF: https://github.com/llvm/llvm-project/commit/3723868d9e07de5d4a7468a4c2c74fc8517afc14.diff

LOG: [OpenMP] Fix file arguments for embedding bitcode in the linker wrapper

Summary:
The linker wrapper supports embedding bitcode images instead of linked
device images to facilitate JIT in the device runtime. However, we were
incorrectly passing in the file twice when this option was set. This
patch makes sure we only use the intermediate result of the LTO pass and
don't add the final output to the full job.

In the future we will want to add both of these andle handle that
accoridngly to allow the runtime to either use the AoT compiled version
or JIT compile the bitcode version if availible.

Added: 
    

Modified: 
    clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index a06409fdab610..74c03a26b884f 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1012,8 +1012,14 @@ Error linkBitcodeFiles(SmallVectorImpl<std::string> &InputFiles,
   if (Error Err = LTOBackend->run(AddStream))
     return Err;
 
+  // If we are embedding bitcode we only need the intermediate output.
+  if (EmbedBitcode) {
+    InputFiles = NewInputFiles;
+    return Error::success();
+  }
+
   // Is we are compiling for NVPTX we need to run the assembler first.
-  if (TheTriple.isNVPTX() && !EmbedBitcode) {
+  if (TheTriple.isNVPTX()) {
     for (auto &File : Files) {
       auto FileOrErr = nvptx::assemble(File, TheTriple, Arch, !WholeProgram);
       if (!FileOrErr)


        


More information about the cfe-commits mailing list