[llvm] [Offload] Move (most) global state to an `OffloadContext` struct (PR #144494)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 19 08:30:46 PDT 2025


https://github.com/RossBrunton updated https://github.com/llvm/llvm-project/pull/144494

>From 475e56c44de34549162e8b53984583b5603c8d8e Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Tue, 17 Jun 2025 10:50:25 +0100
Subject: [PATCH 1/3] [Offload] Move (most) global state to an `OffloadContext`
 struct

Rather than having a number of static local variables, we now use
a single `OffloadContext` struct to store global state. This is
initialised by `olInit`, but is never deleted (de-initialization of
Offload isn't yet implemented).

The error reporting mechanism has not been moved to the struct, since
that's going to cause issues with teardown (error messages must outlive
liboffload).
---
 offload/liboffload/API/APIDefs.td             |  1 +
 offload/liboffload/API/Common.td              |  2 +
 offload/liboffload/include/OffloadImpl.hpp    | 12 +--
 offload/liboffload/src/OffloadImpl.cpp        | 79 +++++++++++--------
 offload/liboffload/src/OffloadLib.cpp         |  5 --
 .../tools/offload-tblgen/EntryPointGen.cpp    | 77 ++++++++++--------
 offload/tools/offload-tblgen/RecordTypes.hpp  |  1 +
 7 files changed, 102 insertions(+), 75 deletions(-)

diff --git a/offload/liboffload/API/APIDefs.td b/offload/liboffload/API/APIDefs.td
index 640932dcf8464..91d8595b4c5bc 100644
--- a/offload/liboffload/API/APIDefs.td
+++ b/offload/liboffload/API/APIDefs.td
@@ -146,6 +146,7 @@ class Function : APIObject {
   list<Return> returns;
   list<string> details = [];
   list<string> analogues = [];
+  bit trace = 1;
 
   list<Return> returns_with_def = !listconcat(DefaultReturns, returns);
   list<Return> all_returns = AddPointerChecksToReturns<params,
diff --git a/offload/liboffload/API/Common.td b/offload/liboffload/API/Common.td
index 8a2ecd6c6e8f4..97bad94e90b83 100644
--- a/offload/liboffload/API/Common.td
+++ b/offload/liboffload/API/Common.td
@@ -167,6 +167,8 @@ def : Function {
   ];
   let params = [];
   let returns = [];
+  // Since olInit sets up the tracing infrastructure, it can't be traced itself
+  let trace = 0;
 }
 
 def : Function {
diff --git a/offload/liboffload/include/OffloadImpl.hpp b/offload/liboffload/include/OffloadImpl.hpp
index 9b0a21cb9ae12..a12d8c47a180b 100644
--- a/offload/liboffload/include/OffloadImpl.hpp
+++ b/offload/liboffload/include/OffloadImpl.hpp
@@ -22,12 +22,12 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 
-struct OffloadConfig {
-  bool TracingEnabled = false;
-  bool ValidationEnabled = true;
-};
-
-OffloadConfig &offloadConfig();
+namespace llvm {
+namespace offload {
+bool isTracingEnabled();
+bool isValidationEnabled();
+} // namespace offload
+} // namespace llvm
 
 // Use the StringSet container to efficiently deduplicate repeated error
 // strings (e.g. if the same error is hit constantly in a long running program)
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 770c212d804d2..7fff72cfe4f59 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -93,22 +93,31 @@ struct AllocInfo {
   ol_alloc_type_t Type;
 };
 
-using AllocInfoMapT = DenseMap<void *, AllocInfo>;
-AllocInfoMapT &allocInfoMap() {
-  static AllocInfoMapT AllocInfoMap{};
-  return AllocInfoMap;
-}
+// Global shared state for liboffload
+struct OffloadContext;
+static OffloadContext *OffloadContextVal;
+struct OffloadContext {
+  OffloadContext(OffloadContext &) = delete;
+  OffloadContext(OffloadContext &&) = delete;
+
+  bool TracingEnabled = false;
+  bool ValidationEnabled = true;
+  DenseMap<void *, AllocInfo> AllocInfoMap{};
+  SmallVector<ol_platform_impl_t, 4> Platforms{};
+
+  ol_device_handle_t HostDevice() {
+    // The host platform is always inserted last
+    return &Platforms.back().Devices[0];
+  }
 
-using PlatformVecT = SmallVector<ol_platform_impl_t, 4>;
-PlatformVecT &Platforms() {
-  static PlatformVecT Platforms;
-  return Platforms;
-}
+  static OffloadContext &get() {
+    assert(OffloadContextVal);
+    return *OffloadContextVal;
+  }
+};
 
-ol_device_handle_t HostDevice() {
-  // The host platform is always inserted last
-  return &Platforms().back().Devices[0];
-}
+bool isTracingEnabled() { return OffloadContext::get().TracingEnabled; }
+bool isValidationEnabled() { return OffloadContext::get().ValidationEnabled; }
 
 template <typename HandleT> Error olDestroy(HandleT Handle) {
   delete Handle;
@@ -130,10 +139,12 @@ constexpr ol_platform_backend_t pluginNameToBackend(StringRef Name) {
 #include "Shared/Targets.def"
 
 void initPlugins() {
+  auto *Context = new OffloadContext{};
+
   // Attempt to create an instance of each supported plugin.
 #define PLUGIN_TARGET(Name)                                                    \
   do {                                                                         \
-    Platforms().emplace_back(ol_platform_impl_t{                               \
+    Context->Platforms.emplace_back(ol_platform_impl_t{                        \
         std::unique_ptr<GenericPluginTy>(createPlugin_##Name()),               \
         {},                                                                    \
         pluginNameToBackend(#Name)});                                          \
@@ -141,7 +152,7 @@ void initPlugins() {
 #include "Shared/Targets.def"
 
   // Preemptively initialize all devices in the plugin
-  for (auto &Platform : Platforms()) {
+  for (auto &Platform : Context->Platforms) {
     // Do not use the host plugin - it isn't supported.
     if (Platform.BackendType == OL_PLATFORM_BACKEND_UNKNOWN)
       continue;
@@ -157,15 +168,16 @@ void initPlugins() {
   }
 
   // Add the special host device
-  auto &HostPlatform = Platforms().emplace_back(
+  auto &HostPlatform = Context->Platforms.emplace_back(
       ol_platform_impl_t{nullptr,
                          {ol_device_impl_t{-1, nullptr, nullptr}},
                          OL_PLATFORM_BACKEND_HOST});
-  HostDevice()->Platform = &HostPlatform;
+  Context->HostDevice()->Platform = &HostPlatform;
+
+  Context->TracingEnabled = std::getenv("OFFLOAD_TRACE");
+  Context->ValidationEnabled = !std::getenv("OFFLOAD_DISABLE_VALIDATION");
 
-  offloadConfig().TracingEnabled = std::getenv("OFFLOAD_TRACE");
-  offloadConfig().ValidationEnabled =
-      !std::getenv("OFFLOAD_DISABLE_VALIDATION");
+  OffloadContextVal = Context;
 }
 
 // TODO: We can properly reference count here and manage the resources in a more
@@ -229,7 +241,7 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
 
   // Find the info if it exists under any of the given names
   auto GetInfo = [&](std::vector<std::string> Names) {
-    if (Device == HostDevice())
+    if (Device == OffloadContext::get().HostDevice())
       return std::string("Host");
 
     if (!Device->Device)
@@ -251,8 +263,9 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
   case OL_DEVICE_INFO_PLATFORM:
     return ReturnValue(Device->Platform);
   case OL_DEVICE_INFO_TYPE:
-    return Device == HostDevice() ? ReturnValue(OL_DEVICE_TYPE_HOST)
-                                  : ReturnValue(OL_DEVICE_TYPE_GPU);
+    return Device == OffloadContext::get().HostDevice()
+               ? ReturnValue(OL_DEVICE_TYPE_HOST)
+               : ReturnValue(OL_DEVICE_TYPE_GPU);
   case OL_DEVICE_INFO_NAME:
     return ReturnValue(GetInfo({"Device Name"}).c_str());
   case OL_DEVICE_INFO_VENDOR:
@@ -280,7 +293,7 @@ Error olGetDeviceInfoSize_impl(ol_device_handle_t Device,
 }
 
 Error olIterateDevices_impl(ol_device_iterate_cb_t Callback, void *UserData) {
-  for (auto &Platform : Platforms()) {
+  for (auto &Platform : OffloadContext::get().Platforms) {
     for (auto &Device : Platform.Devices) {
       if (!Callback(&Device, UserData)) {
         break;
@@ -311,16 +324,17 @@ Error olMemAlloc_impl(ol_device_handle_t Device, ol_alloc_type_t Type,
     return Alloc.takeError();
 
   *AllocationOut = *Alloc;
-  allocInfoMap().insert_or_assign(*Alloc, AllocInfo{Device, Type});
+  OffloadContext::get().AllocInfoMap.insert_or_assign(*Alloc,
+                                                      AllocInfo{Device, Type});
   return Error::success();
 }
 
 Error olMemFree_impl(void *Address) {
-  if (!allocInfoMap().contains(Address))
+  if (!OffloadContext::get().AllocInfoMap.contains(Address))
     return createOffloadError(ErrorCode::INVALID_ARGUMENT,
                               "address is not a known allocation");
 
-  auto AllocInfo = allocInfoMap().at(Address);
+  auto AllocInfo = OffloadContext::get().AllocInfoMap.at(Address);
   auto Device = AllocInfo.Device;
   auto Type = AllocInfo.Type;
 
@@ -328,7 +342,7 @@ Error olMemFree_impl(void *Address) {
           Device->Device->dataDelete(Address, convertOlToPluginAllocTy(Type)))
     return Res;
 
-  allocInfoMap().erase(Address);
+  OffloadContext::get().AllocInfoMap.erase(Address);
 
   return Error::success();
 }
@@ -395,7 +409,8 @@ Error olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
                     ol_device_handle_t DstDevice, const void *SrcPtr,
                     ol_device_handle_t SrcDevice, size_t Size,
                     ol_event_handle_t *EventOut) {
-  if (DstDevice == HostDevice() && SrcDevice == HostDevice()) {
+  auto Host = OffloadContext::get().HostDevice();
+  if (DstDevice == Host && SrcDevice == Host) {
     if (!Queue) {
       std::memcpy(DstPtr, SrcPtr, Size);
       return Error::success();
@@ -410,11 +425,11 @@ Error olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
   // If no queue is given the memcpy will be synchronous
   auto QueueImpl = Queue ? Queue->AsyncInfo : nullptr;
 
-  if (DstDevice == HostDevice()) {
+  if (DstDevice == Host) {
     if (auto Res =
             SrcDevice->Device->dataRetrieve(DstPtr, SrcPtr, Size, QueueImpl))
       return Res;
-  } else if (SrcDevice == HostDevice()) {
+  } else if (SrcDevice == Host) {
     if (auto Res =
             DstDevice->Device->dataSubmit(DstPtr, SrcPtr, Size, QueueImpl))
       return Res;
diff --git a/offload/liboffload/src/OffloadLib.cpp b/offload/liboffload/src/OffloadLib.cpp
index 8662d3a44124b..0a65815e59698 100644
--- a/offload/liboffload/src/OffloadLib.cpp
+++ b/offload/liboffload/src/OffloadLib.cpp
@@ -30,11 +30,6 @@ ol_code_location_t *&currentCodeLocation() {
   return CodeLoc;
 }
 
-OffloadConfig &offloadConfig() {
-  static OffloadConfig Config{};
-  return Config;
-}
-
 namespace llvm {
 namespace offload {
 // Pull in the declarations for the implementation functions. The actual entry
diff --git a/offload/tools/offload-tblgen/EntryPointGen.cpp b/offload/tools/offload-tblgen/EntryPointGen.cpp
index 85c5c50bf2f20..f46cc49fc7475 100644
--- a/offload/tools/offload-tblgen/EntryPointGen.cpp
+++ b/offload/tools/offload-tblgen/EntryPointGen.cpp
@@ -35,21 +35,30 @@ static void EmitValidationFunc(const FunctionRec &F, raw_ostream &OS) {
   }
   OS << ") {\n";
 
-  OS << TAB_1 "if (offloadConfig().ValidationEnabled) {\n";
-  // Emit validation checks
-  for (const auto &Return : F.getReturns()) {
-    for (auto &Condition : Return.getConditions()) {
-      if (Condition.starts_with("`") && Condition.ends_with("`")) {
-        auto ConditionString = Condition.substr(1, Condition.size() - 2);
-        OS << formatv(TAB_2 "if ({0}) {{\n", ConditionString);
-        OS << formatv(TAB_3 "return createOffloadError(error::ErrorCode::{0}, "
-                            "\"validation failure: {1}\");\n",
-                      Return.getUnprefixedValue(), ConditionString);
-        OS << TAB_2 "}\n\n";
+  bool HasValidation = llvm::any_of(F.getReturns(), [](auto &R) {
+    return llvm::any_of(R.getConditions(), [](auto &C) {
+      return C.starts_with("`") && C.ends_with("`");
+    });
+  });
+
+  if (HasValidation) {
+    OS << TAB_1 "if (llvm::offload::isValidationEnabled()) {\n";
+    // Emit validation checks
+    for (const auto &Return : F.getReturns()) {
+      for (auto &Condition : Return.getConditions()) {
+        if (Condition.starts_with("`") && Condition.ends_with("`")) {
+          auto ConditionString = Condition.substr(1, Condition.size() - 2);
+          OS << formatv(TAB_2 "if ({0}) {{\n", ConditionString);
+          OS << formatv(TAB_3
+                        "return createOffloadError(error::ErrorCode::{0}, "
+                        "\"validation failure: {1}\");\n",
+                        Return.getUnprefixedValue(), ConditionString);
+          OS << TAB_2 "}\n\n";
+        }
       }
     }
+    OS << TAB_1 "}\n\n";
   }
-  OS << TAB_1 "}\n\n";
 
   // Perform actual function call to the implementation
   ParamNameList = ParamNameList.substr(0, ParamNameList.size() - 2);
@@ -74,9 +83,11 @@ static void EmitEntryPointFunc(const FunctionRec &F, raw_ostream &OS) {
   OS << ") {\n";
 
   // Emit pre-call prints
-  OS << TAB_1 "if (offloadConfig().TracingEnabled) {\n";
-  OS << formatv(TAB_2 "llvm::errs() << \"---> {0}\";\n", F.getName());
-  OS << TAB_1 "}\n\n";
+  if (F.getTraceEnabled()) {
+    OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
+    OS << formatv(TAB_2 "llvm::errs() << \"---> {0}\";\n", F.getName());
+    OS << TAB_1 "}\n\n";
+  }
 
   // Perform actual function call to the validation wrapper
   ParamNameList = ParamNameList.substr(0, ParamNameList.size() - 2);
@@ -85,26 +96,28 @@ static void EmitEntryPointFunc(const FunctionRec &F, raw_ostream &OS) {
       PrefixLower, F.getName(), ParamNameList);
 
   // Emit post-call prints
-  OS << TAB_1 "if (offloadConfig().TracingEnabled) {\n";
-  if (F.getParams().size() > 0) {
-    OS << formatv(TAB_2 "{0} Params = {{", F.getParamStructName());
-    for (const auto &Param : F.getParams()) {
-      OS << "&" << Param.getName();
-      if (Param != F.getParams().back()) {
-        OS << ", ";
+  if (F.getTraceEnabled()) {
+    OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
+    if (F.getParams().size() > 0) {
+      OS << formatv(TAB_2 "{0} Params = {{", F.getParamStructName());
+      for (const auto &Param : F.getParams()) {
+        OS << "&" << Param.getName();
+        if (Param != F.getParams().back()) {
+          OS << ", ";
+        }
       }
+      OS << formatv("};\n");
+      OS << TAB_2 "llvm::errs() << \"(\" << &Params << \")\";\n";
+    } else {
+      OS << TAB_2 "llvm::errs() << \"()\";\n";
     }
-    OS << formatv("};\n");
-    OS << TAB_2 "llvm::errs() << \"(\" << &Params << \")\";\n";
-  } else {
-    OS << TAB_2 "llvm::errs() << \"()\";\n";
+    OS << TAB_2 "llvm::errs() << \"-> \" << Result << \"\\n\";\n";
+    OS << TAB_2 "if (Result && Result->Details) {\n";
+    OS << TAB_3 "llvm::errs() << \"     *Error Details* \" << Result->Details "
+                "<< \" \\n\";\n";
+    OS << TAB_2 "}\n";
+    OS << TAB_1 "}\n";
   }
-  OS << TAB_2 "llvm::errs() << \"-> \" << Result << \"\\n\";\n";
-  OS << TAB_2 "if (Result && Result->Details) {\n";
-  OS << TAB_3 "llvm::errs() << \"     *Error Details* \" << Result->Details "
-              "<< \" \\n\";\n";
-  OS << TAB_2 "}\n";
-  OS << TAB_1 "}\n";
 
   OS << TAB_1 "return Result;\n";
   OS << "}\n";
diff --git a/offload/tools/offload-tblgen/RecordTypes.hpp b/offload/tools/offload-tblgen/RecordTypes.hpp
index bb7c06c643da5..3eec7b3bc24e9 100644
--- a/offload/tools/offload-tblgen/RecordTypes.hpp
+++ b/offload/tools/offload-tblgen/RecordTypes.hpp
@@ -224,6 +224,7 @@ class FunctionRec {
   std::vector<StringRef> getAnalogues() const {
     return rec->getValueAsListOfStrings("analogues");
   }
+  bool getTraceEnabled() const { return rec->getValueAsBit("trace"); }
 
 private:
   std::vector<ReturnRec> rets;

>From 6bac27a245a61f1c3a8ac30a5ef0a35abb51f373 Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Tue, 17 Jun 2025 14:22:25 +0100
Subject: [PATCH 2/3] Trace olInit

---
 offload/liboffload/API/APIDefs.td             |  1 -
 offload/liboffload/API/Common.td              |  2 -
 offload/liboffload/src/OffloadImpl.cpp        |  5 ++-
 .../tools/offload-tblgen/EntryPointGen.cpp    | 44 +++++++++----------
 offload/tools/offload-tblgen/RecordTypes.hpp  |  1 -
 5 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/offload/liboffload/API/APIDefs.td b/offload/liboffload/API/APIDefs.td
index 91d8595b4c5bc..640932dcf8464 100644
--- a/offload/liboffload/API/APIDefs.td
+++ b/offload/liboffload/API/APIDefs.td
@@ -146,7 +146,6 @@ class Function : APIObject {
   list<Return> returns;
   list<string> details = [];
   list<string> analogues = [];
-  bit trace = 1;
 
   list<Return> returns_with_def = !listconcat(DefaultReturns, returns);
   list<Return> all_returns = AddPointerChecksToReturns<params,
diff --git a/offload/liboffload/API/Common.td b/offload/liboffload/API/Common.td
index 97bad94e90b83..8a2ecd6c6e8f4 100644
--- a/offload/liboffload/API/Common.td
+++ b/offload/liboffload/API/Common.td
@@ -167,8 +167,6 @@ def : Function {
   ];
   let params = [];
   let returns = [];
-  // Since olInit sets up the tracing infrastructure, it can't be traced itself
-  let trace = 0;
 }
 
 def : Function {
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 7fff72cfe4f59..d2522476ba084 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -116,7 +116,10 @@ struct OffloadContext {
   }
 };
 
-bool isTracingEnabled() { return OffloadContext::get().TracingEnabled; }
+// If the context is uninited, then we assume tracing is disabled
+bool isTracingEnabled() {
+  return OffloadContextVal && OffloadContext::get().TracingEnabled;
+}
 bool isValidationEnabled() { return OffloadContext::get().ValidationEnabled; }
 
 template <typename HandleT> Error olDestroy(HandleT Handle) {
diff --git a/offload/tools/offload-tblgen/EntryPointGen.cpp b/offload/tools/offload-tblgen/EntryPointGen.cpp
index f46cc49fc7475..13aa0d1f63187 100644
--- a/offload/tools/offload-tblgen/EntryPointGen.cpp
+++ b/offload/tools/offload-tblgen/EntryPointGen.cpp
@@ -83,11 +83,9 @@ static void EmitEntryPointFunc(const FunctionRec &F, raw_ostream &OS) {
   OS << ") {\n";
 
   // Emit pre-call prints
-  if (F.getTraceEnabled()) {
-    OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
-    OS << formatv(TAB_2 "llvm::errs() << \"---> {0}\";\n", F.getName());
-    OS << TAB_1 "}\n\n";
-  }
+  OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
+  OS << formatv(TAB_2 "llvm::errs() << \"---> {0}\";\n", F.getName());
+  OS << TAB_1 "}\n\n";
 
   // Perform actual function call to the validation wrapper
   ParamNameList = ParamNameList.substr(0, ParamNameList.size() - 2);
@@ -96,28 +94,26 @@ static void EmitEntryPointFunc(const FunctionRec &F, raw_ostream &OS) {
       PrefixLower, F.getName(), ParamNameList);
 
   // Emit post-call prints
-  if (F.getTraceEnabled()) {
-    OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
-    if (F.getParams().size() > 0) {
-      OS << formatv(TAB_2 "{0} Params = {{", F.getParamStructName());
-      for (const auto &Param : F.getParams()) {
-        OS << "&" << Param.getName();
-        if (Param != F.getParams().back()) {
-          OS << ", ";
-        }
+  OS << TAB_1 "if (llvm::offload::isTracingEnabled()) {\n";
+  if (F.getParams().size() > 0) {
+    OS << formatv(TAB_2 "{0} Params = {{", F.getParamStructName());
+    for (const auto &Param : F.getParams()) {
+      OS << "&" << Param.getName();
+      if (Param != F.getParams().back()) {
+        OS << ", ";
       }
-      OS << formatv("};\n");
-      OS << TAB_2 "llvm::errs() << \"(\" << &Params << \")\";\n";
-    } else {
-      OS << TAB_2 "llvm::errs() << \"()\";\n";
     }
-    OS << TAB_2 "llvm::errs() << \"-> \" << Result << \"\\n\";\n";
-    OS << TAB_2 "if (Result && Result->Details) {\n";
-    OS << TAB_3 "llvm::errs() << \"     *Error Details* \" << Result->Details "
-                "<< \" \\n\";\n";
-    OS << TAB_2 "}\n";
-    OS << TAB_1 "}\n";
+    OS << formatv("};\n");
+    OS << TAB_2 "llvm::errs() << \"(\" << &Params << \")\";\n";
+  } else {
+    OS << TAB_2 "llvm::errs() << \"()\";\n";
   }
+  OS << TAB_2 "llvm::errs() << \"-> \" << Result << \"\\n\";\n";
+  OS << TAB_2 "if (Result && Result->Details) {\n";
+  OS << TAB_3 "llvm::errs() << \"     *Error Details* \" << Result->Details "
+              "<< \" \\n\";\n";
+  OS << TAB_2 "}\n";
+  OS << TAB_1 "}\n";
 
   OS << TAB_1 "return Result;\n";
   OS << "}\n";
diff --git a/offload/tools/offload-tblgen/RecordTypes.hpp b/offload/tools/offload-tblgen/RecordTypes.hpp
index 3eec7b3bc24e9..bb7c06c643da5 100644
--- a/offload/tools/offload-tblgen/RecordTypes.hpp
+++ b/offload/tools/offload-tblgen/RecordTypes.hpp
@@ -224,7 +224,6 @@ class FunctionRec {
   std::vector<StringRef> getAnalogues() const {
     return rec->getValueAsListOfStrings("analogues");
   }
-  bool getTraceEnabled() const { return rec->getValueAsBit("trace"); }
 
 private:
   std::vector<ReturnRec> rets;

>From 932dee4103bcb3b312c6b957684c9b0240c7af81 Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Thu, 19 Jun 2025 16:30:16 +0100
Subject: [PATCH 3/3] Added operator=

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

diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index d2522476ba084..f02497c0a6331 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -99,6 +99,8 @@ static OffloadContext *OffloadContextVal;
 struct OffloadContext {
   OffloadContext(OffloadContext &) = delete;
   OffloadContext(OffloadContext &&) = delete;
+  OffloadContext &operator=(OffloadContext &) = delete;
+  OffloadContext &operator=(OffloadContext &&) = delete;
 
   bool TracingEnabled = false;
   bool ValidationEnabled = true;



More information about the llvm-commits mailing list