Skip to content

[Offload] Fix warn-unused function - #208642

Merged
jplehr merged 1 commit into
llvm:mainfrom
jplehr:feat/fix-warn-unused-in-offload
Jul 10, 2026
Merged

jplehr merged 1 commit into
llvm:mainfrom
jplehr:feat/fix-warn-unused-in-offload

Conversation

@jplehr

@jplehr jplehr commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Unblock the -Werror build in pre-merge by adding a few [[maybe_unused]] here and there.

Unblock the `-Werror` build in pre-merge by adding a few
[[maybe_unused]] here and there.
@llvmorg-github-actions

llvmorg-github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

@llvm/pr-subscribers-offload

@llvm/pr-subscribers-backend-amdgpu

Author: Jan Patrick Lehr (jplehr)

Changes

Unblock the -Werror build in pre-merge by adding a few [[maybe_unused]] here and there.


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

4 Files Affected:

  • (modified) offload/plugins-nextgen/amdgpu/src/rtl.cpp (+2-2)
  • (modified) offload/plugins-nextgen/common/include/OffloadError.h (+2-2)
  • (modified) offload/plugins-nextgen/common/include/PluginInterface.h (+2-1)
  • (modified) offload/plugins-nextgen/host/src/rtl.cpp (+2-1)
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
index e6ceeea5331d1..f1caee0c4c1e2 100644
--- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -126,8 +126,8 @@ static hsa_status_t iterate(IterFuncTy Func, IterFuncArgTy FuncArg,
 /// use this function directly but the specialized ones below instead.
 template <typename Elem1Ty, typename Elem2Ty, typename IterFuncTy,
           typename IterFuncArgTy, typename CallbackTy>
-static hsa_status_t iterate(IterFuncTy Func, IterFuncArgTy FuncArg,
-                            CallbackTy Cb) {
+[[maybe_unused]] static hsa_status_t
+iterate(IterFuncTy Func, IterFuncArgTy FuncArg, CallbackTy Cb) {
   auto L = [](Elem1Ty Elem1, Elem2Ty Elem2, void *Data) -> hsa_status_t {
     CallbackTy *Unwrapped = static_cast<CallbackTy *>(Data);
     return (*Unwrapped)(Elem1, Elem2);
diff --git a/offload/plugins-nextgen/common/include/OffloadError.h b/offload/plugins-nextgen/common/include/OffloadError.h
index f2a56d2c41117..3d0ceb400c99c 100644
--- a/offload/plugins-nextgen/common/include/OffloadError.h
+++ b/offload/plugins-nextgen/common/include/OffloadError.h
@@ -49,8 +49,8 @@ class OffloadError : public llvm::ErrorInfo<OffloadError, llvm::StringError> {
 
 /// Create an Offload error.
 template <typename... ArgsTy>
-static llvm::Error createOffloadError(error::ErrorCode Code, const char *ErrFmt,
-                                      ArgsTy... Args) {
+[[maybe_unused]] static llvm::Error
+createOffloadError(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
   std::string Buffer;
   llvm::raw_string_ostream(Buffer) << llvm::format(ErrFmt, Args...);
   return llvm::make_error<error::OffloadError>(Code, Buffer);
diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h
index 400605763b365..2a23d319fff49 100644
--- a/offload/plugins-nextgen/common/include/PluginInterface.h
+++ b/offload/plugins-nextgen/common/include/PluginInterface.h
@@ -98,7 +98,8 @@ inline Error error(error::ErrorCode Code, Error &&OtherError,
 /// the plugin-specific code.
 /// TODO: Refactor this, must be defined individually by each plugin.
 template <typename... ArgsTy>
-static Error check(int32_t ErrorCode, const char *ErrFmt, ArgsTy... Args);
+[[maybe_unused]] static Error check(int32_t ErrorCode, const char *ErrFmt,
+                                    ArgsTy... Args);
 } // namespace Plugin
 
 /// Class that wraps the __tgt_async_info to simply its usage. In case the
diff --git a/offload/plugins-nextgen/host/src/rtl.cpp b/offload/plugins-nextgen/host/src/rtl.cpp
index 505494095a10a..a5d4ffd003fd7 100644
--- a/offload/plugins-nextgen/host/src/rtl.cpp
+++ b/offload/plugins-nextgen/host/src/rtl.cpp
@@ -558,7 +558,8 @@ struct GenELF64PluginTy final : public GenericPluginTy {
 };
 
 template <typename... ArgsTy>
-static Error Plugin::check(int32_t Code, const char *ErrMsg, ArgsTy... Args) {
+[[maybe_unused]] static Error Plugin::check(int32_t Code, const char *ErrMsg,
+                                            ArgsTy... Args) {
   if (Code == 0)
     return Plugin::success();
 

@jplehr
jplehr merged commit 380c581 into llvm:main Jul 10, 2026
12 checks passed
@jplehr
jplehr deleted the feat/fix-warn-unused-in-offload branch July 10, 2026 08:21
/// TODO: Refactor this, must be defined individually by each plugin.
template <typename... ArgsTy>
static Error check(int32_t ErrorCode, const char *ErrFmt, ArgsTy... Args);
[[maybe_unused]] static Error check(int32_t ErrorCode, const char *ErrFmt,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static is an odr violation since if means internal linkage. We need to drop the static templates in header files.

pedroMVicente pushed a commit to pedroMVicente/llvm-project that referenced this pull request Jul 15, 2026
Unblock the `-Werror` build in pre-merge by adding a few
[[maybe_unused]] here and there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants