Skip to content

Commit c8af3b7

Browse files
committed
[ADT] BitVector: give subsetOf(RHS) name to !test(RHS) (NFC)
Define `LHS.subsetOf(RHS)` as a more descriptive name for `!LHS.test(RHS)` and update the existing callers to use that name.
1 parent 8b7a07a commit c8af3b7

File tree

8 files changed

+17
-12
lines changed

8 files changed

+17
-12
lines changed

bolt/lib/Passes/PAuthGadgetScanner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class SrcSafetyAnalysis {
547547

548548
// Being trusted is a strictly stronger property than being
549549
// safe-to-dereference.
550-
assert(!Next.TrustedRegs.test(Next.SafeToDerefRegs) &&
550+
assert(Next.TrustedRegs.subsetOf(Next.SafeToDerefRegs) &&
551551
"SafeToDerefRegs should contain all TrustedRegs");
552552

553553
return Next;

llvm/include/llvm/ADT/BitVector.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class BitVector {
550550
return *this;
551551
}
552552

553-
/// test - Check if (This - RHS) is zero.
553+
/// test - Check if (This - RHS) is non-zero.
554554
/// This is the same as reset(RHS) and any().
555555
bool test(const BitVector &RHS) const {
556556
unsigned ThisWords = Bits.size();
@@ -567,6 +567,9 @@ class BitVector {
567567
return false;
568568
}
569569

570+
/// subsetOf - Check if This is a subset of RHS.
571+
bool subsetOf(const BitVector &RHS) const { return !test(RHS); }
572+
570573
template <class F, class... ArgTys>
571574
static BitVector &apply(F &&f, BitVector &Out, BitVector const &Arg,
572575
ArgTys const &...Args) {

llvm/include/llvm/ADT/SmallBitVector.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ class SmallBitVector {
552552
return *this;
553553
}
554554

555-
/// Check if (This - RHS) is zero. This is the same as reset(RHS) and any().
555+
/// Check if (This - RHS) is non-zero.
556+
/// This is the same as reset(RHS) and any().
556557
bool test(const SmallBitVector &RHS) const {
557558
if (isSmall() && RHS.isSmall())
558559
return (getSmallBits() & ~RHS.getSmallBits()) != 0;
@@ -571,6 +572,9 @@ class SmallBitVector {
571572
return false;
572573
}
573574

575+
/// Check if This is a subset of RHS.
576+
bool subsetOf(const SmallBitVector &RHS) const { return !test(RHS); }
577+
574578
SmallBitVector &operator|=(const SmallBitVector &RHS) {
575579
resize(std::max(size(), RHS.size()));
576580
if (isSmall() && RHS.isSmall())

llvm/lib/Analysis/StackLifetime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void StackLifetime::calculateLocalLiveness() {
173173
BitsIn.resize(NumAllocas, true);
174174

175175
// Update block LiveIn set, noting whether it has changed.
176-
if (BitsIn.test(BlockInfo.LiveIn)) {
176+
if (!BitsIn.subsetOf(BlockInfo.LiveIn)) {
177177
BlockInfo.LiveIn |= BitsIn;
178178
}
179179

@@ -198,7 +198,7 @@ void StackLifetime::calculateLocalLiveness() {
198198
}
199199

200200
// Update block LiveOut set, noting whether it has changed.
201-
if (BitsIn.test(BlockInfo.LiveOut)) {
201+
if (!BitsIn.subsetOf(BlockInfo.LiveOut)) {
202202
Changed = true;
203203
BlockInfo.LiveOut |= BitsIn;
204204
}

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool DwarfExpression::addMachineReg(const TargetRegisterInfo &TRI,
164164

165165
// If this sub-register has a DWARF number and we haven't covered
166166
// its range, and its range covers the value, emit a DWARF piece for it.
167-
if (Offset < MaxSize && CurSubReg.test(Coverage)) {
167+
if (Offset < MaxSize && !CurSubReg.subsetOf(Coverage)) {
168168
// Emit a piece for any gap in the coverage.
169169
if (Offset > CurPos)
170170
DwarfRegs.push_back(Register::createSubRegister(

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,13 @@ void StackColoring::calculateLocalLiveness() {
815815
LocalLiveOut |= BlockInfo.Begin;
816816

817817
// Update block LiveIn set, noting whether it has changed.
818-
if (LocalLiveIn.test(BlockInfo.LiveIn)) {
818+
if (!LocalLiveIn.subsetOf(BlockInfo.LiveIn)) {
819819
changed = true;
820820
BlockInfo.LiveIn |= LocalLiveIn;
821821
}
822822

823823
// Update block LiveOut set, noting whether it has changed.
824-
if (LocalLiveOut.test(BlockInfo.LiveOut)) {
824+
if (!LocalLiveOut.subsetOf(BlockInfo.LiveOut)) {
825825
changed = true;
826826
BlockInfo.LiveOut |= LocalLiveOut;
827827
}

llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ namespace {
137137
return !Bits.any();
138138
}
139139
bool includes(const RegisterSet &Rs) const {
140-
// A.test(B) <=> A-B != {}
141-
return !Rs.Bits.test(Bits);
140+
return Rs.Bits.subsetOf(Bits);
142141
}
143142
bool intersects(const RegisterSet &Rs) const {
144143
return Bits.anyCommon(Rs.Bits);

llvm/lib/Target/Hexagon/HexagonGenInsert.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ namespace {
153153
return !BitVector::any();
154154
}
155155
bool includes(const RegisterSet &Rs) const {
156-
// A.BitVector::test(B) <=> A-B != {}
157-
return !Rs.BitVector::test(*this);
156+
return Rs.BitVector::subsetOf(*this);
158157
}
159158
bool intersects(const RegisterSet &Rs) const {
160159
return BitVector::anyCommon(Rs);

0 commit comments

Comments
 (0)