[llvm] [Offload] Check plugins aren't already deinitialized when tearing down (PR #148642)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 08:00:33 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: Callum Fare (callumfare)

<details>
<summary>Changes</summary>

This is a hotfix for #<!-- -->148615 - it fixes the issue for me locally.

I think a broader issue is that in the test environment we're calling olShutDown from a global destructor in the test binaries. We should do something more controlled, either calling olInit/olShutDown in every test, or move those to a GTest global environment. I didn't do that originally because it looked like it needed change's to LLVM's GTest wrapper.

---
Full diff: https://github.com/llvm/llvm-project/pull/148642.diff


1 Files Affected:

- (modified) offload/liboffload/src/OffloadImpl.cpp (+1-1) 


``````````diff
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 17a2b00cb7140..c4e7f9689a900 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -231,7 +231,7 @@ Error olShutDown_impl() {
 
   for (auto &P : OldContext->Platforms) {
     // Host plugin is nullptr and has no deinit
-    if (!P.Plugin)
+    if (!P.Plugin || !P.Plugin->is_initialized())
       continue;
 
     if (auto Res = P.Plugin->deinit())

``````````

</details>


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


More information about the llvm-commits mailing list