Author: Ivan R. Ivanov
Date: 2026-11-03T17:49:47+01:00
New Revision: 6f3ec76b51713b86d55868196839db3c790ad6c3

URL: 
https://github.com/llvm/llvm-project/commit/6f3ec76b51713b86d55868196839db3c790ad6c3
DIFF: 
https://github.com/llvm/llvm-project/commit/6f3ec76b51713b86d55868196839db3c790ad6c3.diff

LOG: [offload] Remove redundant call to usesLLVMOffloadWrapper (#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.

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 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

Reply via email to