Repository navigation
[Offload] Fix warn-unused function - #208642
Merged
Merged
Conversation
Unblock the `-Werror` build in pre-merge by adding a few [[maybe_unused]] here and there.
jplehr
requested review from
Kewen12,
RossBrunton,
adurang,
arsenm,
jhuber6,
mhalk and
ro-i
July 10, 2026 08:02
|
@llvm/pr-subscribers-offload @llvm/pr-subscribers-backend-amdgpu Author: Jan Patrick Lehr (jplehr) ChangesUnblock the 4 Files Affected:
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();
|
arsenm
approved these changes
Jul 10, 2026
vgvassilev
reviewed
Jul 10, 2026
| /// 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, |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblock the
-Werrorbuild in pre-merge by adding a few [[maybe_unused]] here and there.