Skip to content

Commit b719a6a

Browse files
Merge pull request #71783 from nate-chandler/nfc/20240221/1
[NFC] Removed non-verifier uses of MemoryLocations.
2 parents d3d4bd2 + 5a6873b commit b719a6a

17 files changed

+60
-1309
lines changed

include/swift/Basic/SmallBitVector.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
#include "llvm/ADT/SmallBitVector.h"
1717
#include "llvm/Support/raw_ostream.h"
1818

19-
namespace llvm {
19+
namespace swift {
2020

21-
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
22-
const SmallBitVector &bv) {
23-
for (unsigned i = 0, e = bv.size(); i != e; ++i)
24-
os << (bv[i] ? '1' : '0');
25-
return os;
21+
void printBitsAsArray(llvm::raw_ostream &OS, const llvm::SmallBitVector &bits,
22+
bool bracketed);
23+
24+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
25+
const llvm::SmallBitVector &bits) {
26+
printBitsAsArray(OS, bits, /*bracketed=*/false);
27+
return OS;
2628
}
2729

28-
} // namespace llvm
30+
void dumpBits(const llvm::SmallBitVector &bits);
31+
32+
} // namespace swift
2933

3034
#endif

include/swift/SIL/MemoryLocations.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ class SILFunction;
2929
class SILBasicBlock;
3030
class SingleValueInstruction;
3131

32-
void printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits);
33-
34-
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
35-
const SmallBitVector &bits) {
36-
printBitsAsArray(OS, bits);
37-
return OS;
38-
}
39-
40-
void dumpBits(const SmallBitVector &bits);
41-
4232
/// The MemoryLocations utility provides functions to analyze memory locations.
4333
///
4434
/// Memory locations are limited to addresses which are guaranteed to

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ PASS(DeadObjectElimination, "deadobject-elim",
184184
"Dead Object Elimination for Classes with Trivial Destruction")
185185
PASS(DefiniteInitialization, "definite-init",
186186
"Definite Initialization for Diagnostics")
187-
PASS(DestroyHoisting, "destroy-hoisting",
188-
"Hoisting of value destroys")
189187
PASS(DestroyAddrHoisting, "destroy-addr-hoisting",
190188
"Hoist destroy_addr for uniquely identified values")
191189
PASS(Devirtualizer, "devirtualizer",

lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ add_swift_host_library(swiftBasic STATIC
6767
Program.cpp
6868
QuotedString.cpp
6969
Sandbox.cpp
70+
SmallBitVector.cpp
7071
SourceLoc.cpp
7172
StableHasher.cpp
7273
Statistic.cpp

lib/Basic/SmallBitVector.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===--- SmallBitVector.cpp -----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "swift/Basic/SmallBitVector.h"
14+
#include "llvm/Support/Debug.h"
15+
16+
using namespace llvm;
17+
18+
/// Debug dump a location bit vector.
19+
void swift::printBitsAsArray(raw_ostream &OS, const SmallBitVector &bits,
20+
bool bracketed) {
21+
if (!bracketed) {
22+
for (unsigned i = 0, e = bits.size(); i != e; ++i)
23+
OS << (bits[i] ? '1' : '0');
24+
}
25+
const char *separator = "";
26+
OS << '[';
27+
for (int idx = bits.find_first(); idx >= 0; idx = bits.find_next(idx)) {
28+
OS << separator << idx;
29+
separator = ",";
30+
}
31+
OS << ']';
32+
}
33+
34+
void swift::dumpBits(const SmallBitVector &bits) { dbgs() << bits << '\n'; }

lib/SIL/Utils/BitDataflow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
#define DEBUG_TYPE "bit-dataflow"
1414
#include "swift/SIL/BitDataflow.h"
15+
#include "swift/Basic/SmallBitVector.h"
16+
#include "swift/SIL/MemoryLocations.h"
1517
#include "swift/SIL/SILBasicBlock.h"
1618
#include "swift/SIL/SILFunction.h"
17-
#include "swift/SIL/MemoryLocations.h"
1819
#include "llvm/Support/raw_ostream.h"
1920

2021
using namespace swift;

lib/SIL/Utils/MemoryLocations.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,15 @@
1212

1313
#define DEBUG_TYPE "sil-memory-locations"
1414
#include "swift/SIL/MemoryLocations.h"
15+
#include "swift/Basic/SmallBitVector.h"
16+
#include "swift/SIL/ApplySite.h"
1517
#include "swift/SIL/SILBasicBlock.h"
1618
#include "swift/SIL/SILFunction.h"
17-
#include "swift/SIL/ApplySite.h"
1819
#include "swift/SIL/SILModule.h"
1920
#include "llvm/Support/raw_ostream.h"
2021

2122
using namespace swift;
2223

23-
/// Debug dump a location bit vector.
24-
void swift::printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits) {
25-
const char *separator = "";
26-
OS << '[';
27-
for (int idx = bits.find_first(); idx >= 0; idx = bits.find_next(idx)) {
28-
OS << separator << idx;
29-
separator = ",";
30-
}
31-
OS << ']';
32-
}
33-
34-
void swift::dumpBits(const SmallBitVector &bits) {
35-
llvm::dbgs() << bits << '\n';
36-
}
37-
3824
namespace swift {
3925
namespace {
4026

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#include "swift/AST/Type.h"
2121
#include "swift/Basic/FrozenMultiMap.h"
2222
#include "swift/Basic/ImmutablePointerSet.h"
23+
#include "swift/Basic/SmallBitVector.h"
2324
#include "swift/SIL/BasicBlockData.h"
2425
#include "swift/SIL/BasicBlockDatastructures.h"
2526
#include "swift/SIL/DynamicCasts.h"
2627
#include "swift/SIL/MemAccessUtils.h"
27-
#include "swift/SIL/MemoryLocations.h"
2828
#include "swift/SIL/NodeDatastructures.h"
2929
#include "swift/SIL/OperandDatastructures.h"
3030
#include "swift/SIL/OwnershipUtils.h"

lib/SILOptimizer/Mandatory/OptimizeHopToExecutor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#define DEBUG_TYPE "optimize-hop-to-executor"
14+
#include "swift/SIL/ApplySite.h"
15+
#include "swift/SIL/MemAccessUtils.h"
1416
#include "swift/SIL/SILBuilder.h"
1517
#include "swift/SIL/SILFunction.h"
16-
#include "swift/SIL/ApplySite.h"
17-
#include "swift/SIL/MemoryLocations.h"
1818
#include "swift/SILOptimizer/PassManager/Transforms.h"
19-
#include "swift/SIL/MemAccessUtils.h"
2019

2120
using namespace swift;
2221

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "swift/SIL/BasicBlockDatastructures.h"
2323
#include "swift/SIL/DynamicCasts.h"
2424
#include "swift/SIL/MemAccessUtils.h"
25-
#include "swift/SIL/MemoryLocations.h"
2625
#include "swift/SIL/NodeDatastructures.h"
2726
#include "swift/SIL/OperandDatastructures.h"
2827
#include "swift/SIL/OwnershipUtils.h"

0 commit comments

Comments
 (0)