Skip to content

Commit 358513f

Browse files
[llvm] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163330)
This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] where we do not need to move the position of [[maybe_unused]] within declarations. Notes: - [[maybe_unused]] is a standard feature of C++17. - The compiler is far more lenient about the placement of __attribute__((unused)) than that of [[maybe_unused]]. I'll follow up with another patch to finish up the rest.
1 parent 6ca1f3b commit 358513f

File tree

18 files changed

+46
-49
lines changed

18 files changed

+46
-49
lines changed

llvm/include/llvm/CodeGen/LiveIntervals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ class LiveIntervals {
229229
/// doing something wrong if you call pruneValue directly on a
230230
/// LiveInterval. Indeed, you are supposed to call pruneValue on the main
231231
/// LiveRange and all the LiveRanges of the subranges if any.
232-
LLVM_ATTRIBUTE_UNUSED void pruneValue(LiveInterval &, SlotIndex,
233-
SmallVectorImpl<SlotIndex> *) {
232+
[[maybe_unused]] void pruneValue(LiveInterval &, SlotIndex,
233+
SmallVectorImpl<SlotIndex> *) {
234234
llvm_unreachable(
235235
"Use pruneValue on the main LiveRange and on each subrange");
236236
}

llvm/lib/Analysis/MemorySSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static bool isUseTriviallyOptimizableToLiveOnEntry(AliasAnalysisType &AA,
393393
/// \param AA The AliasAnalysis we used for our search.
394394
/// \param AllowImpreciseClobber Always false, unless we do relaxed verify.
395395

396-
LLVM_ATTRIBUTE_UNUSED static void
396+
[[maybe_unused]] static void
397397
checkClobberSanity(const MemoryAccess *Start, MemoryAccess *ClobberAt,
398398
const MemoryLocation &StartLoc, const MemorySSA &MSSA,
399399
const UpwardsMemoryQuery &Query, BatchAAResults &AA,

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ struct PartwordMaskValues {
770770
Value *Inv_Mask = nullptr;
771771
};
772772

773-
LLVM_ATTRIBUTE_UNUSED
773+
[[maybe_unused]]
774774
raw_ostream &operator<<(raw_ostream &O, const PartwordMaskValues &PMV) {
775775
auto PrintObj = [&O](auto *V) {
776776
if (V)

llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ APInt GISelValueTracking::getKnownOnes(Register R) {
112112
return getKnownBits(R).One;
113113
}
114114

115-
LLVM_ATTRIBUTE_UNUSED static void
115+
[[maybe_unused]] static void
116116
dumpResult(const MachineInstr &MI, const KnownBits &Known, unsigned Depth) {
117117
dbgs() << "[" << Depth << "] Compute known bits: " << MI << "[" << Depth
118118
<< "] Computed for: " << MI << "[" << Depth << "] Known: 0x"

llvm/lib/CodeGen/ScheduleDAGInstrs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ LLVM_DUMP_METHOD void ILPValue::dump() const {
15511551
dbgs() << *this << '\n';
15521552
}
15531553

1554-
LLVM_ATTRIBUTE_UNUSED
1554+
[[maybe_unused]]
15551555
raw_ostream &llvm::operator<<(raw_ostream &OS, const ILPValue &Val) {
15561556
Val.print(OS);
15571557
return OS;

llvm/lib/Support/TextEncoding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ static std::optional<TextEncoding> getKnownEncoding(StringRef Name) {
5454
return std::nullopt;
5555
}
5656

57-
LLVM_ATTRIBUTE_UNUSED static void
58-
HandleOverflow(size_t &Capacity, char *&Output, size_t &OutputLength,
59-
SmallVectorImpl<char> &Result) {
57+
[[maybe_unused]] static void HandleOverflow(size_t &Capacity, char *&Output,
58+
size_t &OutputLength,
59+
SmallVectorImpl<char> &Result) {
6060
// No space left in output buffer. Double the size of the underlying
6161
// memory in the SmallVectorImpl, adjust pointer and length and continue
6262
// the conversion.

llvm/lib/Support/UnicodeNameToCodepoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ nearestMatchesForCodepointName(StringRef Pattern, std::size_t MaxMatchesCount) {
476476
std::min(NormalizedName.size(), UnicodeNameToCodepointLargestNameSize) +
477477
1;
478478

479-
LLVM_ATTRIBUTE_UNUSED static std::size_t Rows =
479+
[[maybe_unused]] static std::size_t Rows =
480480
UnicodeNameToCodepointLargestNameSize + 1;
481481

482482
std::vector<char> Distances(

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18168,7 +18168,7 @@ Align SITargetLowering::getPrefLoopAlignment(MachineLoop *ML) const {
1816818168
return CacheLineAlign;
1816918169
}
1817018170

18171-
LLVM_ATTRIBUTE_UNUSED
18171+
[[maybe_unused]]
1817218172
static bool isCopyFromRegOfInlineAsm(const SDNode *N) {
1817318173
assert(N->getOpcode() == ISD::CopyFromReg);
1817418174
do {

llvm/lib/Target/CSKY/Disassembler/CSKYDisassembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static DecodeStatus DecodeFPR64RegisterClass(MCInst &Inst, uint64_t RegNo,
166166
}
167167

168168
// TODO
169-
LLVM_ATTRIBUTE_UNUSED
169+
[[maybe_unused]]
170170
static DecodeStatus DecodesFPR128RegisterClass(MCInst &Inst, uint64_t RegNo,
171171
uint64_t Address,
172172
const MCDisassembler *Decoder) {

llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,10 @@ static DecodeStatus DecodeHvxWRRegisterClass(MCInst &Inst, unsigned RegNo,
667667
return DecodeRegisterClass(Inst, RegNo, HvxWRDecoderTable);
668668
}
669669

670-
LLVM_ATTRIBUTE_UNUSED // Suppress warning temporarily.
671-
static DecodeStatus
672-
DecodeHvxVQRRegisterClass(MCInst &Inst, unsigned RegNo,
673-
uint64_t /*Address*/,
674-
const MCDisassembler *Decoder) {
670+
[[maybe_unused]] // Suppress warning temporarily.
671+
static DecodeStatus DecodeHvxVQRRegisterClass(MCInst &Inst, unsigned RegNo,
672+
uint64_t /*Address*/,
673+
const MCDisassembler *Decoder) {
675674
static const MCPhysReg HvxVQRDecoderTable[] = {
676675
Hexagon::VQ0, Hexagon::VQ1, Hexagon::VQ2, Hexagon::VQ3,
677676
Hexagon::VQ4, Hexagon::VQ5, Hexagon::VQ6, Hexagon::VQ7};

0 commit comments

Comments
 (0)