Skip to content

Commit c5bd8ab

Browse files
authored
Merge pull request #7583 from gottesmm/formal_access_rename
2 parents 48ba095 + 78a514c commit c5bd8ab

File tree

6 files changed

+46
-43
lines changed

6 files changed

+46
-43
lines changed

lib/SILGen/Cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Lowering {
3232
class JumpDest;
3333
class SILGenFunction;
3434
class ManagedValue;
35-
class SharedBorrowFormalEvaluation;
35+
class SharedBorrowFormalAccess;
3636

3737
/// The valid states that a cleanup can be in.
3838
enum class CleanupState {

lib/SILGen/FormalEvaluation.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ using namespace swift;
1818
using namespace Lowering;
1919

2020
//===----------------------------------------------------------------------===//
21-
// Formal Evaluation
21+
// Formal Access
2222
//===----------------------------------------------------------------------===//
2323

24-
void FormalEvaluation::_anchor() {}
24+
void FormalAccess::_anchor() {}
2525

2626
//===----------------------------------------------------------------------===//
2727
// Shared Borrow Formal Evaluation
2828
//===----------------------------------------------------------------------===//
2929

30-
void SharedBorrowFormalEvaluation::finish(SILGenFunction &gen) {
30+
void SharedBorrowFormalAccess::finish(SILGenFunction &gen) {
3131
gen.B.createEndBorrow(CleanupLocation::get(loc), borrowedValue,
3232
originalValue);
3333
}
@@ -74,24 +74,24 @@ void FormalEvaluationScope::popImpl() {
7474
// Then working down the stack until we visit unwrappedSavedDepth...
7575
for (; iter != unwrappedSavedDepth; ++iter) {
7676
// Grab the next evaluation...
77-
FormalEvaluation &evaluation = *iter;
77+
FormalAccess &access = *iter;
7878

7979
// and deactivate the cleanup.
80-
gen.Cleanups.setCleanupState(evaluation.getCleanup(), CleanupState::Dead);
80+
gen.Cleanups.setCleanupState(access.getCleanup(), CleanupState::Dead);
8181

8282
// Attempt to diagnose problems where obvious aliasing introduces illegal
8383
// code. We do a simple N^2 comparison here to detect this because it is
8484
// extremely unlikely more than a few writebacks are active at once.
85-
if (evaluation.getKind() == FormalEvaluation::Exclusive) {
85+
if (access.getKind() == FormalAccess::Exclusive) {
8686
iterator j = iter;
8787
++j;
8888

8989
for (; j != unwrappedSavedDepth; ++j) {
90-
FormalEvaluation &other = *j;
91-
if (other.getKind() != FormalEvaluation::Exclusive)
90+
FormalAccess &other = *j;
91+
if (other.getKind() != FormalAccess::Exclusive)
9292
continue;
93-
auto &lhs = static_cast<LValueWriteback &>(evaluation);
94-
auto &rhs = static_cast<LValueWriteback &>(other);
93+
auto &lhs = static_cast<ExclusiveBorrowFormalAccess &>(access);
94+
auto &rhs = static_cast<ExclusiveBorrowFormalAccess &>(other);
9595
lhs.diagnoseConflict(rhs, gen);
9696
}
9797
}
@@ -101,7 +101,7 @@ void FormalEvaluationScope::popImpl() {
101101
//
102102
// This evaluates arbitrary code, so it's best to be paranoid
103103
// about iterators on the context.
104-
evaluation.finish(gen);
104+
access.finish(gen);
105105
}
106106

107107
// Then check that we did not add any additional cleanups to the beginning of

lib/SILGen/FormalEvaluation.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Lowering {
2424
class SILGenFunction;
2525
class LogicalPathComponent;
2626

27-
class FormalEvaluation {
27+
class FormalAccess {
2828
public:
2929
enum Kind { Shared, Exclusive };
3030

@@ -36,12 +36,12 @@ class FormalEvaluation {
3636
SILLocation loc;
3737
CleanupHandle cleanup;
3838

39-
FormalEvaluation(unsigned allocatedSize, Kind kind, SILLocation loc,
40-
CleanupHandle cleanup)
39+
FormalAccess(unsigned allocatedSize, Kind kind, SILLocation loc,
40+
CleanupHandle cleanup)
4141
: allocatedSize(allocatedSize), kind(kind), loc(loc), cleanup(cleanup) {}
4242

4343
public:
44-
virtual ~FormalEvaluation() {}
44+
virtual ~FormalAccess() {}
4545

4646
// This anchor method serves three purposes: it aligns the class to
4747
// a pointer boundary, it makes the class a primary base so that
@@ -60,14 +60,14 @@ class FormalEvaluation {
6060
virtual void finish(SILGenFunction &gen) = 0;
6161
};
6262

63-
class SharedBorrowFormalEvaluation : public FormalEvaluation {
63+
class SharedBorrowFormalAccess : public FormalAccess {
6464
SILValue originalValue;
6565
SILValue borrowedValue;
6666

6767
public:
68-
SharedBorrowFormalEvaluation(SILLocation loc, CleanupHandle cleanup,
69-
SILValue originalValue, SILValue borrowedValue)
70-
: FormalEvaluation(sizeof(*this), FormalEvaluation::Shared, loc, cleanup),
68+
SharedBorrowFormalAccess(SILLocation loc, CleanupHandle cleanup,
69+
SILValue originalValue, SILValue borrowedValue)
70+
: FormalAccess(sizeof(*this), FormalAccess::Shared, loc, cleanup),
7171
originalValue(originalValue), borrowedValue(borrowedValue) {}
7272
void finish(SILGenFunction &gen) override;
7373

@@ -76,7 +76,7 @@ class SharedBorrowFormalEvaluation : public FormalEvaluation {
7676
};
7777

7878
class FormalEvaluationContext {
79-
DiverseStack<FormalEvaluation, 128> stack;
79+
DiverseStack<FormalAccess, 128> stack;
8080

8181
public:
8282
using stable_iterator = decltype(stack)::stable_iterator;

lib/SILGen/LValue.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,24 +466,27 @@ class InOutConversionScope {
466466
~InOutConversionScope();
467467
};
468468

469-
struct LLVM_LIBRARY_VISIBILITY LValueWriteback : FormalEvaluation {
469+
struct LLVM_LIBRARY_VISIBILITY ExclusiveBorrowFormalAccess : FormalAccess {
470470
std::unique_ptr<LogicalPathComponent> component;
471471
ManagedValue base;
472472
MaterializedLValue materialized;
473473

474-
~LValueWriteback() {}
475-
LValueWriteback(LValueWriteback &&) = default;
476-
LValueWriteback &operator=(LValueWriteback &&) = default;
474+
~ExclusiveBorrowFormalAccess() {}
475+
ExclusiveBorrowFormalAccess(ExclusiveBorrowFormalAccess &&) = default;
476+
ExclusiveBorrowFormalAccess &
477+
operator=(ExclusiveBorrowFormalAccess &&) = default;
477478

478-
LValueWriteback() = default;
479-
LValueWriteback(SILLocation loc, std::unique_ptr<LogicalPathComponent> &&comp,
480-
ManagedValue base, MaterializedLValue materialized,
481-
CleanupHandle cleanup)
482-
: FormalEvaluation(sizeof(*this), FormalEvaluation::Exclusive, loc,
483-
cleanup),
479+
ExclusiveBorrowFormalAccess() = default;
480+
ExclusiveBorrowFormalAccess(SILLocation loc,
481+
std::unique_ptr<LogicalPathComponent> &&comp,
482+
ManagedValue base,
483+
MaterializedLValue materialized,
484+
CleanupHandle cleanup)
485+
: FormalAccess(sizeof(*this), FormalAccess::Exclusive, loc, cleanup),
484486
component(std::move(comp)), base(base), materialized(materialized) {}
485487

486-
void diagnoseConflict(const LValueWriteback &rhs, SILGenFunction &SGF) const {
488+
void diagnoseConflict(const ExclusiveBorrowFormalAccess &rhs,
489+
SILGenFunction &SGF) const {
487490
// If the two writebacks we're comparing are of different kinds (e.g.
488491
// ownership conversion vs a computed property) then they aren't the
489492
// same and thus cannot conflict.

lib/SILGen/SILGenExpr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ struct FormalEvaluationEndBorrowCleanup : Cleanup {
178178
#endif
179179
}
180180

181-
SharedBorrowFormalEvaluation &getEvaluation(SILGenFunction &gen) const {
181+
SharedBorrowFormalAccess &getEvaluation(SILGenFunction &gen) const {
182182
auto &evaluation = *gen.FormalEvalContext.find(Depth);
183-
assert(evaluation.getKind() == FormalEvaluation::Shared);
184-
return static_cast<SharedBorrowFormalEvaluation &>(evaluation);
183+
assert(evaluation.getKind() == FormalAccess::Shared);
184+
return static_cast<SharedBorrowFormalAccess &>(evaluation);
185185
}
186186

187187
SILValue getOriginalValue(SILGenFunction &gen) const {
@@ -239,11 +239,11 @@ SILGenFunction::emitFormalEvaluationManagedBorrowedRValueWithCleanup(
239239
}
240240

241241
assert(InWritebackScope && "Must be in formal evaluation scope");
242-
Cleanups.pushCleanup<FormalEvaluationEndBorrowCleanup>();
242+
auto &cleanup = Cleanups.pushCleanup<FormalEvaluationEndBorrowCleanup>();
243243
CleanupHandle handle = Cleanups.getTopCleanup();
244-
FormalEvalContext.push<SharedBorrowFormalEvaluation>(loc, handle, original,
245-
borrowed);
246-
244+
FormalEvalContext.push<SharedBorrowFormalAccess>(loc, handle, original,
245+
borrowed);
246+
cleanup.Depth = FormalEvalContext.stable_begin();
247247
return ManagedValue(borrowed, CleanupHandle::invalid());
248248
}
249249

lib/SILGen/SILGenLValue.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ struct LValueWritebackCleanup : Cleanup {
4545

4646
void emit(SILGenFunction &gen, CleanupLocation loc) override {
4747
auto &evaluation = *gen.FormalEvalContext.find(Depth);
48-
assert(evaluation.getKind() == FormalEvaluation::Exclusive);
49-
auto &lvalue = static_cast<LValueWriteback &>(evaluation);
48+
assert(evaluation.getKind() == FormalAccess::Exclusive);
49+
auto &lvalue = static_cast<ExclusiveBorrowFormalAccess &>(evaluation);
5050
lvalue.performWriteback(gen, /*isFinal*/ false);
5151
}
5252

@@ -75,8 +75,8 @@ static void pushWriteback(SILGenFunction &gen,
7575
gen.Cleanups.pushCleanup<LValueWritebackCleanup>();
7676
CleanupHandle handle = gen.Cleanups.getTopCleanup();
7777

78-
context.push<LValueWriteback>(loc, std::move(comp), base, materialized,
79-
handle);
78+
context.push<ExclusiveBorrowFormalAccess>(loc, std::move(comp), base,
79+
materialized, handle);
8080
cleanup.Depth = context.stable_begin();
8181
}
8282

0 commit comments

Comments
 (0)