https://github.com/ivanradanov created https://github.com/llvm/llvm-project/pull/238343
usesLLVMOffloadWrapper was called twice when it could just be used to override the Kind once for both bundleLinkedOutput and wrapDeviceImages. This also allows that path to take the verbose image bundling. >From a041902b26103bba34dace7682c4277c3c657a15 Mon Sep 17 00:00:00 2001 From: Ivan Radanov Ivanov <[email protected]> Date: Tue, 3 Nov 2026 05:09:32 -0800 Subject: [PATCH] [offload] Remove redundant call to usesLLVMOffloadWrapper usesLLVMOffloadWrapper was called twice when it could just be used to override the Kind once for both bundleLinkedOutput and wrapDeviceImages. This also allows that path to take the verbose image bundling. --- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 010335fd9fd37e..9f3976949d3f6b 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -980,9 +980,6 @@ Expected<SmallVector<std::unique_ptr<MemoryBuffer>>> bundleLinkedOutput(ArrayRef<OffloadingImage> Images, const ArgList &Args, OffloadKind Kind) { llvm::TimeTraceScope TimeScope("Bundle linked output"); - if (usesLLVMOffloadWrapper(Images)) - return bundleOpenMP(Images); - switch (Kind) { case OFK_OpenMP: return (Verbose && SaveTemps) ? bundleOpenMPVerbose(Images) @@ -1192,6 +1189,7 @@ linkAndWrapDeviceFiles(ArrayRef<SmallVector<OffloadFile>> LinkerInputFiles, // fat binary directly (e.g. .hipfb / .fatbin). SmallVector<StringRef> WrappedOutput; for (auto &[Kind, Input] : Images) { + OffloadKind WrapperKind = usesLLVMOffloadWrapper(Input) ? OFK_OpenMP : Kind; // We sort the entries before bundling so they appear in a deterministic // order in the final binary. llvm::sort(Input, [](OffloadingImage &A, OffloadingImage &B) { @@ -1205,7 +1203,7 @@ linkAndWrapDeviceFiles(ArrayRef<SmallVector<OffloadFile>> LinkerInputFiles, return ArchA > ArchB; return A.TheOffloadKind < B.TheOffloadKind; }); - auto BundledImagesOrErr = bundleLinkedOutput(Input, Args, Kind); + auto BundledImagesOrErr = bundleLinkedOutput(Input, Args, WrapperKind); if (!BundledImagesOrErr) return BundledImagesOrErr.takeError(); @@ -1228,7 +1226,6 @@ linkAndWrapDeviceFiles(ArrayRef<SmallVector<OffloadFile>> LinkerInputFiles, continue; } - OffloadKind WrapperKind = usesLLVMOffloadWrapper(Input) ? OFK_OpenMP : Kind; auto OutputOrErr = wrapDeviceImages(*BundledImagesOrErr, Args, WrapperKind); if (!OutputOrErr) return OutputOrErr.takeError(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
