Skip to content

Commit 6870f68

Browse files
[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.
1 parent 96cf206 commit 6870f68

File tree

16 files changed

+38
-40
lines changed

16 files changed

+38
-40
lines changed

mlir/include/mlir/Dialect/Affine/LoopUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ LogicalResult loopUnrollUpToFactor(AffineForOp forOp, uint64_t unrollFactor);
6161

6262
/// Returns true if `loops` is a perfectly nested loop nest, where loops appear
6363
/// in it from outermost to innermost.
64-
bool LLVM_ATTRIBUTE_UNUSED isPerfectlyNested(ArrayRef<AffineForOp> loops);
64+
[[maybe_unused]] bool isPerfectlyNested(ArrayRef<AffineForOp> loops);
6565

6666
/// Get perfectly nested sequence of loops starting at root of loop nest
6767
/// (the first op being another AffineFor, and the second op - a terminator).

mlir/lib/Analysis/FlatLinearValueConstraints.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,9 @@ bool FlatLinearValueConstraints::areVarsAlignedWithOther(
12441244

12451245
/// Checks if the SSA values associated with `cst`'s variables in range
12461246
/// [start, end) are unique.
1247-
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique(
1248-
const FlatLinearValueConstraints &cst, unsigned start, unsigned end) {
1247+
[[maybe_unused]] static bool
1248+
areVarsUnique(const FlatLinearValueConstraints &cst, unsigned start,
1249+
unsigned end) {
12491250

12501251
assert(start <= cst.getNumDimAndSymbolVars() &&
12511252
"Start position out of bounds");
@@ -1267,14 +1268,14 @@ static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique(
12671268
}
12681269

12691270
/// Checks if the SSA values associated with `cst`'s variables are unique.
1270-
static bool LLVM_ATTRIBUTE_UNUSED
1271+
[[maybe_unused]] static bool
12711272
areVarsUnique(const FlatLinearValueConstraints &cst) {
12721273
return areVarsUnique(cst, 0, cst.getNumDimAndSymbolVars());
12731274
}
12741275

12751276
/// Checks if the SSA values associated with `cst`'s variables of kind `kind`
12761277
/// are unique.
1277-
static bool LLVM_ATTRIBUTE_UNUSED
1278+
[[maybe_unused]] static bool
12781279
areVarsUnique(const FlatLinearValueConstraints &cst, VarKind kind) {
12791280

12801281
if (kind == VarKind::SetDim)

mlir/lib/Analysis/Presburger/Simplex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using Direction = Simplex::Direction;
3434
const int nullIndex = std::numeric_limits<int>::max();
3535

3636
// Return a + scale*b;
37-
LLVM_ATTRIBUTE_UNUSED
37+
[[maybe_unused]]
3838
static SmallVector<DynamicAPInt, 8>
3939
scaleAndAddForAssert(ArrayRef<DynamicAPInt> a, const DynamicAPInt &scale,
4040
ArrayRef<DynamicAPInt> b) {

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ static bool remainsLegalAfterInline(OpTy op, Region *src, Region *dest,
125125
// Use "unused attribute" marker to silence clang-tidy warning stemming from
126126
// the inability to see through "llvm::TypeSwitch".
127127
template <>
128-
bool LLVM_ATTRIBUTE_UNUSED remainsLegalAfterInline(AffineApplyOp op,
129-
Region *src, Region *dest,
130-
const IRMapping &mapping) {
128+
[[maybe_unused]] bool remainsLegalAfterInline(AffineApplyOp op, Region *src,
129+
Region *dest,
130+
const IRMapping &mapping) {
131131
// If it's a valid dimension, we need to check that it remains so.
132132
if (isValidDim(op.getResult(), src))
133133
return remainsLegalAfterInline(
@@ -1032,8 +1032,8 @@ static void simplifyMinOrMaxExprWithOperands(AffineMap &map,
10321032
/// Simplify the map while exploiting information on the values in `operands`.
10331033
// Use "unused attribute" marker to silence warning stemming from the inability
10341034
// to see through the template expansion.
1035-
static void LLVM_ATTRIBUTE_UNUSED
1036-
simplifyMapWithOperands(AffineMap &map, ArrayRef<Value> operands) {
1035+
[[maybe_unused]] static void simplifyMapWithOperands(AffineMap &map,
1036+
ArrayRef<Value> operands) {
10371037
assert(map.getNumInputs() == operands.size() && "invalid operands for map");
10381038
SmallVector<AffineExpr> newResults;
10391039
newResults.reserve(map.getNumResults());

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ bool mlir::affine::isValidLoopInterchangePermutation(
13571357

13581358
/// Returns true if `loops` is a perfectly nested loop nest, where loops appear
13591359
/// in it from outermost to innermost.
1360-
bool LLVM_ATTRIBUTE_UNUSED
1360+
[[maybe_unused]] bool
13611361
mlir::affine::isPerfectlyNested(ArrayRef<AffineForOp> loops) {
13621362
assert(!loops.empty() && "no loops provided");
13631363

@@ -1920,8 +1920,7 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
19201920
return copyNestRoot;
19211921
}
19221922

1923-
static InFlightDiagnostic LLVM_ATTRIBUTE_UNUSED
1924-
emitRemarkForBlock(Block &block) {
1923+
[[maybe_unused]] static InFlightDiagnostic emitRemarkForBlock(Block &block) {
19251924
return block.getParentOp()->emitRemark();
19261925
}
19271926

mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ static void printExtTypeParams(AsmPrinter &p, ArrayRef<Type> typeParams,
134134

135135
/// These are unused for now.
136136
/// TODO: Move over to these once more types have been migrated to TypeDef.
137-
LLVM_ATTRIBUTE_UNUSED static OptionalParseResult
137+
[[maybe_unused]] static OptionalParseResult
138138
generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value);
139-
LLVM_ATTRIBUTE_UNUSED static LogicalResult
140-
generatedTypePrinter(Type def, AsmPrinter &printer);
139+
[[maybe_unused]] static LogicalResult generatedTypePrinter(Type def,
140+
AsmPrinter &printer);
141141

142142
#include "mlir/Dialect/LLVMIR/LLVMTypeInterfaces.cpp.inc"
143143

mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ void VarInfo::setNum(Var::Num n) {
143143

144144
/// Helper function for `assertUsageConsistency` to better handle SMLoc
145145
/// mismatches.
146-
LLVM_ATTRIBUTE_UNUSED static llvm::SMLoc
147-
minSMLoc(AsmParser &parser, llvm::SMLoc sm1, llvm::SMLoc sm2) {
146+
[[maybe_unused]] static llvm::SMLoc minSMLoc(AsmParser &parser, llvm::SMLoc sm1,
147+
llvm::SMLoc sm2) {
148148
const auto loc1 = dyn_cast<FileLineColLoc>(parser.getEncodedSourceLoc(sm1));
149149
assert(loc1 && "Could not get `FileLineColLoc` for first `SMLoc`");
150150
const auto loc2 = dyn_cast<FileLineColLoc>(parser.getEncodedSourceLoc(sm2));

mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ using namespace mlir::sparse_tensor;
4343
//===----------------------------------------------------------------------===//
4444

4545
#ifndef NDEBUG
46-
LLVM_ATTRIBUTE_UNUSED static void dumpIndexMemRef(OpBuilder &builder,
47-
Location loc, Value memref) {
46+
[[maybe_unused]] static void dumpIndexMemRef(OpBuilder &builder, Location loc,
47+
Value memref) {
4848
memref = memref::CastOp::create(
4949
builder, loc, UnrankedMemRefType::get(builder.getIndexType(), 0), memref);
5050
createFuncCall(builder, loc, "printMemrefInd", TypeRange{},

mlir/lib/Dialect/Transform/IR/TransformTypes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ using namespace mlir;
2121

2222
// These are automatically generated by ODS but are not used as the Transform
2323
// dialect uses a different dispatch mechanism to support dialect extensions.
24-
LLVM_ATTRIBUTE_UNUSED static OptionalParseResult
24+
[[maybe_unused]] static OptionalParseResult
2525
generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value);
26-
LLVM_ATTRIBUTE_UNUSED static LogicalResult
27-
generatedTypePrinter(Type def, AsmPrinter &printer);
26+
[[maybe_unused]] static LogicalResult generatedTypePrinter(Type def,
27+
AsmPrinter &printer);
2828

2929
#define GET_TYPEDEF_CLASSES
3030
#include "mlir/Dialect/Transform/IR/TransformTypes.cpp.inc"

mlir/lib/IR/MLIRContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ AffineMap AffineMap::getImpl(unsigned dimCount, unsigned symbolCount,
12041204
/// present in result expressions is less than `dimCount` and the highest index
12051205
/// of symbolic identifier present in result expressions is less than
12061206
/// `symbolCount`.
1207-
LLVM_ATTRIBUTE_UNUSED static bool
1207+
[[maybe_unused]] static bool
12081208
willBeValidAffineMap(unsigned dimCount, unsigned symbolCount,
12091209
ArrayRef<AffineExpr> results) {
12101210
int64_t maxDimPosition = -1;

0 commit comments

Comments
 (0)