[Compiler] Addressing new compiler warnings (#3640)

* [Compiler] Addressing new compiler warnings

Clang enables new lifetime warnings in production and we see build
errors due to this with the staging compiler.

The attributes added in this PR are suggested by the compiler. However,
I'm not very familiar with the code base, so the changes may be
incorrect.

* Update some more instances

* Adds file-level ignores via clang diagnostic pragma

The number of instances was large, so I decided to use file-level scope
to disable the warning via pragma clang diagnostic ignored.

It also showed this warning coming from the gtest dependency. For that,
I did add the respective command line flag to the CMake variables. I
don't know if this is acceptable or not.

* This adds the remaining instances

For a build on gfx90a.

* fix clang format

* Adding couple more instances from gfx1200 build

* Fixed another few instances

---------

Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
Co-authored-by: illsilin_amdeng <Illia.Silin@amd.com>
This commit is contained in:
Jan Patrick Lehr
2026-02-02 18:39:48 +01:00
committed by GitHub
parent e6bcd192d4
commit 069500464d
50 changed files with 228 additions and 43 deletions

View File

@@ -110,4 +110,5 @@ ConvParam parse_conv_param(int num_dim_spatial, int arg_idx, char* const argv[])
} // namespace utils
} // namespace ck
std::ostream& operator<<(std::ostream& os, const ck::utils::conv::ConvParam& p);
std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
const ck::utils::conv::ConvParam& p);

View File

@@ -23,10 +23,14 @@
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wlifetime-safety-intra-tu-suggestions"
#pragma clang diagnostic ignored "-Wlifetime-safety-cross-tu-suggestions"
namespace ck {
template <typename Range>
std::ostream& LogRange(std::ostream& os, Range&& range, std::string delim)
std::ostream& LogRange([[clang::lifetimebound]] std::ostream& os, Range&& range, std::string delim)
{
bool first = true;
for(auto&& v : range)
@@ -580,8 +584,9 @@ struct HostTensorDescriptor
return std::inner_product(iss.begin(), iss.end(), mStrides.begin(), std::size_t{0});
}
friend std::ostream& operator<<(std::ostream& os, const HostTensorDescriptor& desc);
friend std::ostream& operator<<(std::ostream& os, ChosenLayout tag);
friend std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
const HostTensorDescriptor& desc);
friend std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os, ChosenLayout tag);
private:
std::vector<std::size_t> mLens;
@@ -1171,3 +1176,4 @@ struct Tensor
};
} // namespace ck
#pragma clang diagnostic pop