Skip to content

Commit 44fc7a5

Browse files
committed
Merge branch 'master' into cmark-checkout
2 parents 54c3ab9 + 6bace09 commit 44fc7a5

File tree

6 files changed

+43
-49
lines changed

6 files changed

+43
-49
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ compiler for C++14 support and create a symlink:
6666

6767
### Getting Sources for Swift and Related Projects
6868

69-
git clone [email protected]:/apple/swift.git swift
70-
git clone [email protected]:/apple/swift-llvm.git llvm
71-
git clone [email protected]:/apple/swift-clang.git clang
72-
git clone [email protected]:/apple/swift-lldb.git lldb
73-
git clone [email protected]:/apple/swift-cmark.git cmark
74-
git clone [email protected]:/apple/swift-llbuild.git llbuild
75-
git clone [email protected]:/apple/swift-package-manager.git swiftpm
76-
git clone [email protected]:/apple/swift-corelibs-xctest.git
77-
git clone [email protected]:/apple/swift-corelibs-foundation.git
69+
git clone [email protected]:apple/swift.git swift
70+
git clone [email protected]:apple/swift-llvm.git llvm
71+
git clone [email protected]:apple/swift-clang.git clang
72+
git clone [email protected]:apple/swift-lldb.git lldb
73+
git clone [email protected]:apple/swift-cmark.git cmark
74+
git clone [email protected]:apple/swift-llbuild.git llbuild
75+
git clone [email protected]:apple/swift-package-manager.git swiftpm
76+
git clone [email protected]:apple/swift-corelibs-xctest.git
77+
git clone [email protected]:apple/swift-corelibs-foundation.git
7878

7979

8080
[CMake](http://cmake.org) is the core infrastructure used to configure builds of
@@ -137,8 +137,8 @@ picking up new targets, file removals, or file additions.
137137

138138
## Testing Swift
139139

140-
See docs/Testing.rst.
140+
See [docs/Testing.rst](docs/Testing.rst).
141141

142142
## Contributing to Swift
143143

144-
Contributions to Swift are welcomed and encouraged! Please see the [Contributing to Swift guide](https://swift.org/contributing/).
144+
Contributions to Swift are welcomed and encouraged! Please see the [Contributing to Swift guide](https://swift.org/contributing/).

docs/ARCOptimization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ is_unique performs depends on the argument type:
194194
dynamic object type uses native swift reference counting:
195195
(Builtin.UnknownObject, unknown class reference, class existential)
196196

197-
- Bridged object types allow the dymanic object type check to be
197+
- Bridged object types allow the dynamic object type check to be
198198
bypassed based on the pointer encoding:
199199
(Builtin.BridgeObject)
200200

docs/Pattern Matching.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ pattern-specific production. I believe it should be true that, in
732732
general, match patterns for a production accept a strict superset of
733733
valid expressions, so that (e.g.) we do not need to disambiguate
734734
whether an open paren starts a tuple expression or a tuple pattern,
735-
but can instaed just aggressively parse as a pattern. Note that
735+
but can instead just aggressively parse as a pattern. Note that
736736
binary operators can mean that, using this strategy, we sometimes have
737737
to retroactively rewrite a pattern as an expression.
738738

include/swift/AST/Builtins.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ BUILTIN_SIL_OPERATION(FixLifetime, "fixLifetime", Special)
306306
/// dynamic object type uses native swift reference counting:
307307
/// (Builtin.UnknownObject, unknown class reference, class existential)
308308
///
309-
/// - Bridged object types allow the dymanic object type check to be
309+
/// - Bridged object types allow the dynamic object type check to be
310310
/// passed based on their pointer encoding:
311311
/// (Builtin.BridgeObject)
312312
///

lib/SILPasses/Scalar/DeadStoreElimination.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class DSEContext {
278278
llvm::BumpPtrAllocator BPA;
279279

280280
/// Map every basic block to its location state.
281-
llvm::SmallDenseMap<SILBasicBlock *, BBState, 4> BBToLocState;
281+
llvm::DenseMap<SILBasicBlock *, BBState *> BBToLocState;
282282

283283
/// Keeps the actual BBStates.
284284
std::vector<BBState> BBStates;
@@ -295,7 +295,7 @@ class DSEContext {
295295
MemLocationIndexMap LocToBitIndex;
296296

297297
/// Return the BBState for the basic block this basic block belongs to.
298-
BBState *getBBLocState(SILBasicBlock *B) { return &BBToLocState[B]; }
298+
BBState *getBBLocState(SILBasicBlock *B) { return BBToLocState[B]; }
299299

300300
/// Return the BBState for the basic block this instruction belongs to.
301301
BBState *getBBLocState(SILInstruction *I) {
@@ -854,8 +854,13 @@ void DSEContext::run() {
854854
// than 64 basic blocks. Therefore, allocate the BBState in a vector and use
855855
// pointer in BBToLocState to access them.
856856
for (auto &B : *F) {
857-
BBToLocState[&B] = BBState(&B);
858-
BBToLocState[&B].init(MemLocationVault.size());
857+
BBStates.push_back(BBState(&B));
858+
BBStates.back().init(MemLocationVault.size());
859+
}
860+
861+
// Initialize the BBToLocState mapping.
862+
for (auto &S : BBStates) {
863+
BBToLocState[S.getBB()] = &S;
859864
}
860865

861866
// Generate the genset and killset for each basic block.

lib/SILPasses/Scalar/RedundantLoadElimination.cpp

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/// 4. An optimistic iterative intersection-based dataflow is performed on the
3939
/// gen sets until convergence.
4040
///
41-
/// At the core of RLE, there is the MemLocation class. a MemLocation is an
41+
/// At the core of RLE, there is the MemLocation class. A MemLocation is an
4242
/// abstraction of an object field in program. It consists of a base and a
4343
/// projection path to the field accessed.
4444
///
@@ -48,12 +48,12 @@
4848
/// keeps their available LoadStoreValues. We call it *indivisible* because it
4949
/// can not be broken down to more MemLocations.
5050
///
51-
/// LoadStoreValues consists of a base - a SILValue from the load or store inst,
51+
/// LoadStoreValue consists of a base - a SILValue from the load or store inst,
5252
/// as well as a projection path to which the field it represents. So, a
5353
/// store to an 2-field struct as mentioned above will generate 2 MemLocations
5454
/// and 2 LoadStoreValues.
5555
///
56-
/// Every basic block keeps a map between MemLocation <-> LoadStoreValue. By
56+
/// Every basic block keeps a map between MemLocation and LoadStoreValue. By
5757
/// keeping the MemLocation and LoadStoreValue in their indivisible form, one
5858
/// can easily find which part of the load is redundant and how to compute its
5959
/// forwarding value.
@@ -74,7 +74,6 @@
7474
//===----------------------------------------------------------------------===//
7575

7676
#define DEBUG_TYPE "sil-redundant-load-elim"
77-
#include "swift/SILPasses/Passes.h"
7877
#include "swift/SIL/MemLocation.h"
7978
#include "swift/SIL/Projection.h"
8079
#include "swift/SIL/SILArgument.h"
@@ -83,17 +82,18 @@
8382
#include "swift/SILAnalysis/DominanceAnalysis.h"
8483
#include "swift/SILAnalysis/PostOrderAnalysis.h"
8584
#include "swift/SILAnalysis/ValueTracking.h"
85+
#include "swift/SILPasses/Passes.h"
86+
#include "swift/SILPasses/Transforms.h"
8687
#include "swift/SILPasses/Utils/CFG.h"
8788
#include "swift/SILPasses/Utils/Local.h"
8889
#include "swift/SILPasses/Utils/SILSSAUpdater.h"
89-
#include "swift/SILPasses/Transforms.h"
9090
#include "llvm/ADT/BitVector.h"
91-
#include "llvm/Support/CommandLine.h"
92-
#include "llvm/Support/Debug.h"
9391
#include "llvm/ADT/MapVector.h"
9492
#include "llvm/ADT/None.h"
9593
#include "llvm/ADT/Statistic.h"
9694
#include "llvm/ADT/TinyPtrVector.h"
95+
#include "llvm/Support/CommandLine.h"
96+
#include "llvm/Support/Debug.h"
9797

9898
using namespace swift;
9999

@@ -169,19 +169,14 @@ class BBState {
169169
/// A bit vector for which the ith bit represents the ith MemLocation in
170170
/// MemLocationVault. If the bit is set, then the location currently has an
171171
/// downward visible value.
172-
llvm::BitVector ForwardSetOut;
173-
174-
/// If ForwardSetIn changes while processing a basicblock, then all its
175-
/// predecessors needs to be rerun.
176172
llvm::BitVector ForwardSetIn;
177173

178-
/// This is a list of MemLocations and their LoadStoreValues.
179-
///
180-
/// TODO: can we create a LoadStoreValue vault so that we do not need to keep
181-
/// them per basic block. This would also give ForwardValIn more symmetry.
182-
/// i.e. MemLocation and LoadStoreValue both represented as bit vector
183-
/// indices.
184-
///
174+
/// If ForwardSetOut changes while processing a basicblock, then all its
175+
/// successors need to be rerun.
176+
llvm::BitVector ForwardSetOut;
177+
178+
/// This is map between MemLocations and their available values at the
179+
/// beginning of this basic block.
185180
ValueTableMap ForwardValIn;
186181

187182
/// This is map between MemLocations and their available values at the end of
@@ -255,15 +250,17 @@ class BBState {
255250
ForwardSetOut.resize(bitcnt, reachable);
256251
}
257252

253+
/// Returns the current basic block we are processing.
254+
SILBasicBlock *getBB() const { return BB; }
255+
258256
/// Returns the ForwardValIn for the current basic block.
259257
ValueTableMap &getForwardValIn() { return ForwardValIn; }
260258

261259
/// Returns the ForwardValOut for the current basic block.
262260
ValueTableMap &getForwardValOut() { return ForwardValOut; }
263261

264-
/// Returns the current basic block we are processing.
265-
SILBasicBlock *getBB() const { return BB; }
266-
262+
/// Returns the redundant loads and their replacement in the currently basic
263+
/// block.
267264
llvm::DenseMap<SILInstruction *, SILValue> &getRL() { return RedundantLoads; }
268265

269266
bool optimize(RLEContext &Ctx, bool PF);
@@ -299,9 +296,8 @@ class BBState {
299296

300297
namespace {
301298

302-
/// This class stores global state that we use when processing and also drives
303-
/// the computation. We put its interface at the top for use in other parts of
304-
/// the pass which may want to use this global information.
299+
/// This class stores global state that we use when computing redudant load and
300+
/// their replacement in each basic block.
305301
class RLEContext {
306302
/// The alias analysis that we will use during all computations.
307303
AliasAnalysis *AA;
@@ -373,13 +369,6 @@ class RLEContext {
373369
/// collect forwarding values from their ForwardValOuts.
374370
bool gatherValues(SILBasicBlock *B, MemLocation &L, MemLocationValueMap &Vs,
375371
bool UseForwardValOut);
376-
377-
/// Dump all the MemLocations in the MemLocationVault.
378-
void printMemLocationVault() const {
379-
for (auto &X : MemLocationVault) {
380-
X.print();
381-
}
382-
}
383372
};
384373

385374
} // end anonymous namespace

0 commit comments

Comments
 (0)