[llvm] [DO NOT MERGE] CI verification branch for offload -Wunused-template fix (PR #208492)

Aditya Medhane via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 08:48:28 PDT 2026


https://github.com/flash1729 created https://github.com/llvm/llvm-project/pull/208492

None

>From d3b2b145af287d41171a9faba4848a0ed1f7c3a4 Mon Sep 17 00:00:00 2001
From: flash1729 <sherlockedaditya at gmail.com>
Date: Thu, 9 Jul 2026 20:48:12 +0530
Subject: [PATCH 1/2] [offload] Fix -Wunused-template errors in plugin
 templates (NFC)

Enabling -Wunused-template under -Wall (#202945) turned several
internal-linkage function templates in the offload plugins into hard
errors once offload is built with the just-built clang, breaking
unrelated precommit runs (e.g. #208455, #208122).

  - error::createOffloadError (OffloadError.h) and Plugin::error
    (PluginInterface.h): drop 'static'. Each has a non-template 'inline'
    sibling overload right below it, so the 'static' on the template was
    inconsistent; external (vague) linkage is the correct NFC fix and
    removes the per-TU-copy hazard the warning flags.

  - Plugin::check (PluginInterface.h): declared 'static' in the header
    but defined separately by each plugin (amdgpu/cuda/host), so its
    internal linkage is load-bearing. Removing 'static' would collide the
    definitions and 'inline' would be an ODR violation, so use
    [[maybe_unused]], which is linkage-neutral and only silences the
    warning in the common TUs that see the declaration without
    instantiating it.

  - dlwrap::getSymbolArray (DLWrap.h): this header intentionally keeps its
    symbol-table helpers TU-local, so preserve 'static' and use
    [[maybe_unused]].

  - hsa_utils::iterate two-element overload (amdgpu rtl.cpp): has no caller
    (the specialized wrappers use only the one- and three-argument
    overloads); mark [[maybe_unused]].

Part of #202945.
---
 offload/plugins-nextgen/amdgpu/src/rtl.cpp               | 4 ++--
 offload/plugins-nextgen/common/include/DLWrap.h          | 2 +-
 offload/plugins-nextgen/common/include/OffloadError.h    | 4 ++--
 offload/plugins-nextgen/common/include/PluginInterface.h | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

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/DLWrap.h b/offload/plugins-nextgen/common/include/DLWrap.h
index 95ce86e123cd3..39a058a6ac0c4 100644
--- a/offload/plugins-nextgen/common/include/DLWrap.h
+++ b/offload/plugins-nextgen/common/include/DLWrap.h
@@ -126,7 +126,7 @@ template <size_t N> struct symbol;
 } // namespace type
 
 template <size_t N, size_t... Is>
-constexpr std::array<const char *, N> static getSymbolArray(
+[[maybe_unused]] constexpr std::array<const char *, N> static getSymbolArray(
     std::index_sequence<Is...>) {
   return {{dlwrap::type::symbol<Is>::call()...}};
 }
diff --git a/offload/plugins-nextgen/common/include/OffloadError.h b/offload/plugins-nextgen/common/include/OffloadError.h
index f2a56d2c41117..f2ffafa3d0a02 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) {
+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 e805eeeae8435..bc446cde68a5c 100644
--- a/offload/plugins-nextgen/common/include/PluginInterface.h
+++ b/offload/plugins-nextgen/common/include/PluginInterface.h
@@ -76,7 +76,7 @@ static inline Error success() { return Error::success(); }
 
 /// Create an Offload error.
 template <typename... ArgsTy>
-static Error error(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
+Error error(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
   return error::createOffloadError(Code, ErrFmt, Args...);
 }
 
@@ -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

>From 4ebea45266437138f5919a5e659577208f41112b Mon Sep 17 00:00:00 2001
From: flash1729 <sherlockedaditya at gmail.com>
Date: Thu, 9 Jul 2026 20:49:08 +0530
Subject: [PATCH 2/2] [DO NOT MERGE] CI verification branch for offload
 -Wunused-template fix

Throwaway branch that stacks an empty commit on wunused-template-offload
so a draft PR can force offload into the premerge footprint. Post-reland
(#208001 is in main) the fix branch already pulls offload+openmp into its
own premerge, so this branch is redundant here; kept for the two-branch
habit. Do not merge.



More information about the llvm-commits mailing list