[clang] [lld] [llvm] [LTO][LLD] Prevent invalid LTO libfunc transforms (PR #164916)

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 13 16:48:16 PST 2026


================
@@ -2701,14 +2701,30 @@ static void markBuffersAsDontNeed(Ctx &ctx, bool skipLinkedOutput) {
 template <class ELFT>
 void LinkerDriver::compileBitcodeFiles(bool skipLinkedOutput) {
   llvm::TimeTraceScope timeScope("LTO");
+  // Capture the triple before moving the bitcode into the bitcode compiler.
+  // Note that this assumes that the set of possible libfuncs is roughly
+  // equivalent for all bitcode translation units.
+  std::optional<llvm::Triple> tt;
+  if (!ctx.bitcodeFiles.empty())
+    tt = llvm::Triple(ctx.bitcodeFiles.front()->obj->getTargetTriple());
----------------
mysterymath wrote:

As per the comment, the files can only examined before the call to add, since it moves the bitcode files into the LTO object. At that point, they are left in an undefined state. I can get rid of the optional  though with default initialization; done.

https://github.com/llvm/llvm-project/pull/164916


More information about the llvm-commits mailing list