[clang] [clang-sycl-linker] AOT-compile split modules concurrently (PR #224548)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 17:04:10 PDT 2026


================
@@ -924,6 +930,54 @@ static bool canSkipModuleSplit(IRSplitMode Mode, const Module &M,
   });
 }
 
+/// AOT-compiles every JIT image in \p SplitModules concurrently and swaps each
+/// module's path to point at the compiled object.
+static Error aotCompileSplitModules(SmallVectorImpl<SplitModule> &SplitModules,
+                                    const ArgList &Args, StringRef OutputFile) {
+  // Each worker thread writes only its own index, so this is race-free.
+  SmallVector<std::string, 0> AOTFiles(SplitModules.size());
+  // std::optional, not Error: pre-filled Error::success() move-assigned
+  // from a worker thread would abort on the unchecked-value assert.
+  SmallVector<std::optional<Error>, 0> AOTErrors(SplitModules.size());
+  for (size_t I = 0, E = SplitModules.size(); I != E; ++I) {
----------------
wenju-he wrote:

done, thanks, much simpler now. Behavior change is that `llvm::heavyweight_hardware_concurrency()` (one thread per hardware core) is changed to `hardware_concurrency()` (hyperthreads also used). This should be fine and consistent with `clang-linker-wrapper` lines you mentioned.

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


More information about the cfe-commits mailing list