mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
[mlir] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163703)
This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]], introduced as part of C++17.
This commit is contained in:
@@ -61,7 +61,7 @@ LogicalResult loopUnrollUpToFactor(AffineForOp forOp, uint64_t unrollFactor);
|
||||
|
||||
/// Returns true if `loops` is a perfectly nested loop nest, where loops appear
|
||||
/// in it from outermost to innermost.
|
||||
bool LLVM_ATTRIBUTE_UNUSED isPerfectlyNested(ArrayRef<AffineForOp> loops);
|
||||
[[maybe_unused]] bool isPerfectlyNested(ArrayRef<AffineForOp> loops);
|
||||
|
||||
/// Get perfectly nested sequence of loops starting at root of loop nest
|
||||
/// (the first op being another AffineFor, and the second op - a terminator).
|
||||
|
||||
@@ -1244,8 +1244,9 @@ bool FlatLinearValueConstraints::areVarsAlignedWithOther(
|
||||
|
||||
/// Checks if the SSA values associated with `cst`'s variables in range
|
||||
/// [start, end) are unique.
|
||||
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique(
|
||||
const FlatLinearValueConstraints &cst, unsigned start, unsigned end) {
|
||||
[[maybe_unused]] static bool
|
||||
areVarsUnique(const FlatLinearValueConstraints &cst, unsigned start,
|
||||
unsigned end) {
|
||||
|
||||
assert(start <= cst.getNumDimAndSymbolVars() &&
|
||||
"Start position out of bounds");
|
||||
@@ -1267,14 +1268,14 @@ static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique(
|
||||
}
|
||||
|
||||
/// Checks if the SSA values associated with `cst`'s variables are unique.
|
||||
static bool LLVM_ATTRIBUTE_UNUSED
|
||||
[[maybe_unused]] static bool
|
||||
areVarsUnique(const FlatLinearValueConstraints &cst) {
|
||||
return areVarsUnique(cst, 0, cst.getNumDimAndSymbolVars());
|
||||
}
|
||||
|
||||
/// Checks if the SSA values associated with `cst`'s variables of kind `kind`
|
||||
/// are unique.
|
||||
static bool LLVM_ATTRIBUTE_UNUSED
|
||||
[[maybe_unused]] static bool
|
||||
areVarsUnique(const FlatLinearValueConstraints &cst, VarKind kind) {
|
||||
|
||||
if (kind == VarKind::SetDim)
|
||||
|
||||
@@ -34,7 +34,7 @@ using Direction = Simplex::Direction;
|
||||
const int nullIndex = std::numeric_limits<int>::max();
|
||||
|
||||
// Return a + scale*b;
|
||||
LLVM_ATTRIBUTE_UNUSED
|
||||
[[maybe_unused]]
|
||||
static SmallVector<DynamicAPInt, 8>
|
||||
scaleAndAddForAssert(ArrayRef<DynamicAPInt> a, const DynamicAPInt &scale,
|
||||
ArrayRef<DynamicAPInt> b) {
|
||||
|
||||
@@ -125,9 +125,9 @@ static bool remainsLegalAfterInline(OpTy op, Region *src, Region *dest,
|
||||
// Use "unused attribute" marker to silence clang-tidy warning stemming from
|
||||
// the inability to see through "llvm::TypeSwitch".
|
||||
template <>
|
||||
bool LLVM_ATTRIBUTE_UNUSED remainsLegalAfterInline(AffineApplyOp op,
|
||||
Region *src, Region *dest,
|
||||
const IRMapping &mapping) {
|
||||
[[maybe_unused]] bool remainsLegalAfterInline(AffineApplyOp op, Region *src,
|
||||
Region *dest,
|
||||
const IRMapping &mapping) {
|
||||
// If it's a valid dimension, we need to check that it remains so.
|
||||
if (isValidDim(op.getResult(), src))
|
||||
return remainsLegalAfterInline(
|
||||
@@ -1032,8 +1032,8 @@ static void simplifyMinOrMaxExprWithOperands(AffineMap &map,
|
||||
/// Simplify the map while exploiting information on the values in `operands`.
|
||||
// Use "unused attribute" marker to silence warning stemming from the inability
|
||||
// to see through the template expansion.
|
||||
static void LLVM_ATTRIBUTE_UNUSED
|
||||
simplifyMapWithOperands(AffineMap &map, ArrayRef<Value> operands) {
|
||||
[[maybe_unused]] static void simplifyMapWithOperands(AffineMap &map,
|
||||
ArrayRef<Value> operands) {
|
||||
assert(map.getNumInputs() == operands.size() && "invalid operands for map");
|
||||
SmallVector<AffineExpr> newResults;
|
||||
newResults.reserve(map.getNumResults());
|
||||
|
||||
@@ -1357,7 +1357,7 @@ bool mlir::affine::isValidLoopInterchangePermutation(
|
||||
|
||||
/// Returns true if `loops` is a perfectly nested loop nest, where loops appear
|
||||
/// in it from outermost to innermost.
|
||||
bool LLVM_ATTRIBUTE_UNUSED
|
||||
[[maybe_unused]] bool
|
||||
mlir::affine::isPerfectlyNested(ArrayRef<AffineForOp> loops) {
|
||||
assert(!loops.empty() && "no loops provided");
|
||||
|
||||
@@ -1920,8 +1920,7 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
|
||||
return copyNestRoot;
|
||||
}
|
||||
|
||||
static InFlightDiagnostic LLVM_ATTRIBUTE_UNUSED
|
||||
emitRemarkForBlock(Block &block) {
|
||||
[[maybe_unused]] static InFlightDiagnostic emitRemarkForBlock(Block &block) {
|
||||
return block.getParentOp()->emitRemark();
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +134,10 @@ static void printExtTypeParams(AsmPrinter &p, ArrayRef<Type> typeParams,
|
||||
|
||||
/// These are unused for now.
|
||||
/// TODO: Move over to these once more types have been migrated to TypeDef.
|
||||
LLVM_ATTRIBUTE_UNUSED static OptionalParseResult
|
||||
[[maybe_unused]] static OptionalParseResult
|
||||
generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value);
|
||||
LLVM_ATTRIBUTE_UNUSED static LogicalResult
|
||||
generatedTypePrinter(Type def, AsmPrinter &printer);
|
||||
[[maybe_unused]] static LogicalResult generatedTypePrinter(Type def,
|
||||
AsmPrinter &printer);
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/LLVMTypeInterfaces.cpp.inc"
|
||||
|
||||
|
||||
@@ -143,8 +143,8 @@ void VarInfo::setNum(Var::Num n) {
|
||||
|
||||
/// Helper function for `assertUsageConsistency` to better handle SMLoc
|
||||
/// mismatches.
|
||||
LLVM_ATTRIBUTE_UNUSED static llvm::SMLoc
|
||||
minSMLoc(AsmParser &parser, llvm::SMLoc sm1, llvm::SMLoc sm2) {
|
||||
[[maybe_unused]] static llvm::SMLoc minSMLoc(AsmParser &parser, llvm::SMLoc sm1,
|
||||
llvm::SMLoc sm2) {
|
||||
const auto loc1 = dyn_cast<FileLineColLoc>(parser.getEncodedSourceLoc(sm1));
|
||||
assert(loc1 && "Could not get `FileLineColLoc` for first `SMLoc`");
|
||||
const auto loc2 = dyn_cast<FileLineColLoc>(parser.getEncodedSourceLoc(sm2));
|
||||
|
||||
@@ -43,8 +43,8 @@ using namespace mlir::sparse_tensor;
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NDEBUG
|
||||
LLVM_ATTRIBUTE_UNUSED static void dumpIndexMemRef(OpBuilder &builder,
|
||||
Location loc, Value memref) {
|
||||
[[maybe_unused]] static void dumpIndexMemRef(OpBuilder &builder, Location loc,
|
||||
Value memref) {
|
||||
memref = memref::CastOp::create(
|
||||
builder, loc, UnrankedMemRefType::get(builder.getIndexType(), 0), memref);
|
||||
createFuncCall(builder, loc, "printMemrefInd", TypeRange{},
|
||||
|
||||
@@ -21,10 +21,10 @@ using namespace mlir;
|
||||
|
||||
// These are automatically generated by ODS but are not used as the Transform
|
||||
// dialect uses a different dispatch mechanism to support dialect extensions.
|
||||
LLVM_ATTRIBUTE_UNUSED static OptionalParseResult
|
||||
[[maybe_unused]] static OptionalParseResult
|
||||
generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value);
|
||||
LLVM_ATTRIBUTE_UNUSED static LogicalResult
|
||||
generatedTypePrinter(Type def, AsmPrinter &printer);
|
||||
[[maybe_unused]] static LogicalResult generatedTypePrinter(Type def,
|
||||
AsmPrinter &printer);
|
||||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "mlir/Dialect/Transform/IR/TransformTypes.cpp.inc"
|
||||
|
||||
@@ -1204,7 +1204,7 @@ AffineMap AffineMap::getImpl(unsigned dimCount, unsigned symbolCount,
|
||||
/// present in result expressions is less than `dimCount` and the highest index
|
||||
/// of symbolic identifier present in result expressions is less than
|
||||
/// `symbolCount`.
|
||||
LLVM_ATTRIBUTE_UNUSED static bool
|
||||
[[maybe_unused]] static bool
|
||||
willBeValidAffineMap(unsigned dimCount, unsigned symbolCount,
|
||||
ArrayRef<AffineExpr> results) {
|
||||
int64_t maxDimPosition = -1;
|
||||
|
||||
@@ -93,7 +93,7 @@ void CodeGen::generate(const ast::Module &astModule, ModuleOp module) {
|
||||
|
||||
// Emit function to add the generated matchers to the pattern list.
|
||||
os << "template <typename... ConfigsT>\n"
|
||||
"static void LLVM_ATTRIBUTE_UNUSED populateGeneratedPDLLPatterns("
|
||||
"[[maybe_unused]] static void populateGeneratedPDLLPatterns("
|
||||
"::mlir::RewritePatternSet &patterns, ConfigsT &&...configs) {\n";
|
||||
for (const auto &name : patternNames)
|
||||
os << " patterns.add<" << name
|
||||
|
||||
@@ -938,10 +938,10 @@ public:
|
||||
|
||||
// These are automatically generated by ODS but are not used as the Transform
|
||||
// dialect uses a different dispatch mechanism to support dialect extensions.
|
||||
LLVM_ATTRIBUTE_UNUSED static OptionalParseResult
|
||||
[[maybe_unused]] static OptionalParseResult
|
||||
generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value);
|
||||
LLVM_ATTRIBUTE_UNUSED static LogicalResult
|
||||
generatedTypePrinter(Type def, AsmPrinter &printer);
|
||||
[[maybe_unused]] static LogicalResult generatedTypePrinter(Type def,
|
||||
AsmPrinter &printer);
|
||||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "TestTransformDialectExtensionTypes.cpp.inc"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// CHECK: operation "test.op3"
|
||||
// CHECK: )mlir", context), std::forward<ConfigsT>(configs)...)
|
||||
|
||||
// CHECK: static void LLVM_ATTRIBUTE_UNUSED populateGeneratedPDLLPatterns(::mlir::RewritePatternSet &patterns, ConfigsT &&...configs) {
|
||||
// CHECK{LITERAL}: [[maybe_unused]] static void populateGeneratedPDLLPatterns(::mlir::RewritePatternSet &patterns, ConfigsT &&...configs) {
|
||||
// CHECK-NEXT: patterns.add<GeneratedPDLLPattern0>(patterns.getContext(), configs...);
|
||||
// CHECK-NEXT: patterns.add<NamedPattern>(patterns.getContext(), configs...);
|
||||
// CHECK-NEXT: patterns.add<GeneratedPDLLPattern1>(patterns.getContext(), configs...);
|
||||
|
||||
@@ -416,7 +416,7 @@ static void emitOneEnumToConversion(const Record *record, raw_ostream &os) {
|
||||
|
||||
// Emit the function converting the enum attribute to its LLVM counterpart.
|
||||
os << formatv(
|
||||
"static LLVM_ATTRIBUTE_UNUSED {0} convert{1}ToLLVM({2}::{1} value) {{\n",
|
||||
"[[maybe_unused]] static {0} convert{1}ToLLVM({2}::{1} value) {{\n",
|
||||
llvmClass, cppClassName, cppNamespace);
|
||||
os << " switch (value) {\n";
|
||||
|
||||
@@ -444,7 +444,7 @@ static void emitOneCEnumToConversion(const Record *record, raw_ostream &os) {
|
||||
StringRef cppNamespace = enumAttr.getCppNamespace();
|
||||
|
||||
// Emit the function converting the enum attribute to its LLVM counterpart.
|
||||
os << formatv("static LLVM_ATTRIBUTE_UNUSED int64_t "
|
||||
os << formatv("[[maybe_unused]] static int64_t "
|
||||
"convert{0}ToLLVM({1}::{0} value) {{\n",
|
||||
cppClassName, cppNamespace);
|
||||
os << " switch (value) {\n";
|
||||
@@ -474,7 +474,7 @@ static void emitOneEnumFromConversion(const Record *record, raw_ostream &os) {
|
||||
StringRef cppNamespace = enumInfo.getCppNamespace();
|
||||
|
||||
// Emit the function converting the enum attribute from its LLVM counterpart.
|
||||
os << formatv("inline LLVM_ATTRIBUTE_UNUSED {0}::{1} convert{1}FromLLVM({2} "
|
||||
os << formatv("[[maybe_unused]] inline {0}::{1} convert{1}FromLLVM({2} "
|
||||
"value) {{\n",
|
||||
cppNamespace, cppClassName, llvmClass);
|
||||
os << " switch (value) {\n";
|
||||
@@ -509,10 +509,9 @@ static void emitOneCEnumFromConversion(const Record *record, raw_ostream &os) {
|
||||
StringRef cppNamespace = enumInfo.getCppNamespace();
|
||||
|
||||
// Emit the function converting the enum attribute from its LLVM counterpart.
|
||||
os << formatv(
|
||||
"inline LLVM_ATTRIBUTE_UNUSED {0}::{1} convert{1}FromLLVM(int64_t "
|
||||
"value) {{\n",
|
||||
cppNamespace, cppClassName);
|
||||
os << formatv("[[maybe_unused]] inline {0}::{1} convert{1}FromLLVM(int64_t "
|
||||
"value) {{\n",
|
||||
cppNamespace, cppClassName);
|
||||
os << " switch (value) {\n";
|
||||
|
||||
for (const auto &enumerant : enumInfo.getAllCases()) {
|
||||
|
||||
@@ -2120,7 +2120,7 @@ static void emitRewriters(const RecordKeeper &records, raw_ostream &os) {
|
||||
}
|
||||
|
||||
// Emit function to add the generated matchers to the pattern list.
|
||||
os << "void LLVM_ATTRIBUTE_UNUSED populateWithGenerated("
|
||||
os << "[[maybe_unused]] void populateWithGenerated("
|
||||
"::mlir::RewritePatternSet &patterns) {\n";
|
||||
for (const auto &name : rewriterNames) {
|
||||
os << " patterns.add<" << name << ">(patterns.getContext());\n";
|
||||
|
||||
@@ -113,8 +113,7 @@ static Match tensorMatch(TensorId tid) { return Match(tid); }
|
||||
static Match synZeroMatch() { return Match(); }
|
||||
|
||||
#define IMPL_BINOP_PATTERN(OP, KIND) \
|
||||
LLVM_ATTRIBUTE_UNUSED static Match OP##Match(const Match &e0, \
|
||||
const Match &e1) { \
|
||||
[[maybe_unused]] static Match OP##Match(const Match &e0, const Match &e1) { \
|
||||
return Match(KIND, e0, e1); \
|
||||
}
|
||||
FOREVERY_BINOP(IMPL_BINOP_PATTERN)
|
||||
|
||||
Reference in New Issue
Block a user