[llvm] Revert "Revert "Fix memory leak in Offloading API" (#161465)" (PR #161573)

David Salinas via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 13:51:04 PDT 2025


https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/161573

>From 78d5ad84b49674cbae4772170138150d602803e3 Mon Sep 17 00:00:00 2001
From: david-salinas <dsalinas at amd.com>
Date: Wed, 1 Oct 2025 19:35:52 +0000
Subject: [PATCH 1/2] Revert "Revert "Fix memory leak in Offloading API"
 (#161465)"

This reverts commit d392563433316e310edacf35a40fb2f9aa477acc.
---
 llvm/lib/Object/OffloadBundle.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp
index 0dd378e65fd81..a6a9628acddcc 100644
--- a/llvm/lib/Object/OffloadBundle.cpp
+++ b/llvm/lib/Object/OffloadBundle.cpp
@@ -120,14 +120,15 @@ OffloadBundleFatBin::create(MemoryBufferRef Buf, uint64_t SectionOffset,
   if (identify_magic(Buf.getBuffer()) != file_magic::offload_bundle)
     return errorCodeToError(object_error::parse_failed);
 
-  OffloadBundleFatBin *TheBundle = new OffloadBundleFatBin(Buf, FileName);
+  std::unique_ptr<OffloadBundleFatBin> TheBundle(
+      new OffloadBundleFatBin(Buf, FileName));
 
   // Read the Bundle Entries
   Error Err = TheBundle->readEntries(Buf.getBuffer(), SectionOffset);
   if (Err)
     return Err;
 
-  return std::unique_ptr<OffloadBundleFatBin>(TheBundle);
+  return TheBundle;
 }
 
 Error OffloadBundleFatBin::extractBundle(const ObjectFile &Source) {

>From 593be0baefc5a07e769e97b0e013bf52fdef4c00 Mon Sep 17 00:00:00 2001
From: david-salinas <dsalinas at amd.com>
Date: Wed, 1 Oct 2025 20:50:30 +0000
Subject: [PATCH 2/2] resolve openmp build bot error

---
 llvm/lib/Object/OffloadBundle.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp
index a6a9628acddcc..329dcbf2d939a 100644
--- a/llvm/lib/Object/OffloadBundle.cpp
+++ b/llvm/lib/Object/OffloadBundle.cpp
@@ -128,7 +128,7 @@ OffloadBundleFatBin::create(MemoryBufferRef Buf, uint64_t SectionOffset,
   if (Err)
     return Err;
 
-  return TheBundle;
+  return std::move(TheBundle);
 }
 
 Error OffloadBundleFatBin::extractBundle(const ObjectFile &Source) {



More information about the llvm-commits mailing list