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

Callum Fare via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 07:59:57 PDT 2025


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

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.

>From a066d64d6c9a75c5cd47ed7e5ac7bde1120e83df Mon Sep 17 00:00:00 2001
From: Callum Fare <callum at codeplay.com>
Date: Mon, 14 Jul 2025 15:47:08 +0100
Subject: [PATCH] [Offload] Check plugins aren't already deinitialized when
 tearing down

---
 offload/liboffload/src/OffloadImpl.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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



More information about the llvm-commits mailing list