Skip to content

Commit 33afd0e

Browse files
committed
MemoryLifetime: Make debug dump functions for bitsets usable from other optimizations
NFC
1 parent 07c0e2a commit 33afd0e

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

include/swift/SIL/MemoryLifetime.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222

2323
namespace swift {
2424

25+
void printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits);
26+
27+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
28+
const SmallBitVector &bits) {
29+
printBitsAsArray(OS, bits);
30+
return OS;
31+
}
32+
33+
void dumpBits(const SmallBitVector &bits);
34+
2535
/// The MemoryLocations utility provides functions to analyze memory locations.
2636
///
2737
/// Memory locations are limited to addresses which are guaranteed to

lib/SIL/MemoryLifetime.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,28 @@ llvm::cl::opt<bool> DontAbortOnMemoryLifetimeErrors(
2828
llvm::cl::desc("Don't abort compliation if the memory lifetime checker "
2929
"detects an error."));
3030

31-
namespace swift {
32-
namespace {
33-
34-
//===----------------------------------------------------------------------===//
35-
// Utility functions
36-
//===----------------------------------------------------------------------===//
37-
3831
/// Debug dump a location bit vector.
39-
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
40-
const SmallBitVector &bits) {
32+
void swift::printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits) {
4133
const char *separator = "";
4234
OS << '[';
4335
for (int idx = bits.find_first(); idx >= 0; idx = bits.find_next(idx)) {
4436
OS << separator << idx;
4537
separator = ",";
4638
}
4739
OS << ']';
48-
return OS;
4940
}
5041

42+
void swift::dumpBits(const SmallBitVector &bits) {
43+
llvm::dbgs() << bits << '\n';
44+
}
45+
46+
namespace swift {
47+
namespace {
48+
49+
//===----------------------------------------------------------------------===//
50+
// Utility functions
51+
//===----------------------------------------------------------------------===//
52+
5153
/// Enlarge the bitset if needed to set the bit with \p idx.
5254
static void setBitAndResize(SmallBitVector &bits, unsigned idx) {
5355
if (bits.size() <= idx)
@@ -240,10 +242,6 @@ void MemoryLocations::dump() const {
240242
}
241243
}
242244

243-
void MemoryLocations::dumpBits(const Bits &bits) {
244-
llvm::errs() << bits << '\n';
245-
}
246-
247245
void MemoryLocations::clear() {
248246
locations.clear();
249247
addr2LocIdx.clear();

0 commit comments

Comments
 (0)