Skip to content

Commit 67aab42

Browse files
Merge pull request swiftlang#39303 from nate-chandler/lexical_lifetimes/respell_defined_as_lexical
[SIL] Changed spelling of lifetime flags.
2 parents b223e9d + f833b68 commit 67aab42

File tree

16 files changed

+66
-63
lines changed

16 files changed

+66
-63
lines changed

docs/SIL.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,7 +3671,7 @@ begin_borrow
36713671

36723672
::
36733673

3674-
sil-instruction ::= 'begin_borrow' '[defined]'? sil-operand
3674+
sil-instruction ::= 'begin_borrow' '[lexical]'? sil-operand
36753675

36763676
%1 = begin_borrow %0 : $T
36773677

@@ -3684,7 +3684,7 @@ region in between this borrow and its lifetime ending use, ``%0`` must be
36843684
live. This makes sense semantically since ``%1`` is modeling a new value with a
36853685
dependent lifetime on ``%0``.
36863686

3687-
The optional ``defined`` attribute specifies that the operand corresponds to a
3687+
The optional ``lexical`` attribute specifies that the operand corresponds to a
36883688
local variable in the Swift source, so special care must be taken when moving
36893689
the end_borrow.
36903690

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ namespace swift {
305305
bool EnableExperimentalConcurrency = false;
306306

307307
/// Enable experimental support for emitting defined borrow scopes.
308-
bool EnableExperimentalDefinedLifetimes = false;
308+
bool EnableExperimentalLexicalLifetimes = false;
309309

310310
/// Enable experimental support for named opaque result types, e.g.
311311
/// `func f() -> <T> T`.

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ def enable_experimental_concurrency :
247247
Flag<["-"], "enable-experimental-concurrency">,
248248
HelpText<"Enable experimental concurrency model">;
249249

250-
def enable_experimental_defined_lifetimes :
251-
Flag<["-"], "enable-experimental-defined-lifetimes">,
252-
HelpText<"Enable experimental defined lifetimes">;
250+
def enable_experimental_lexical_lifetimes :
251+
Flag<["-"], "enable-experimental-lexical-lifetimes">,
252+
HelpText<"Enable experimental lexical lifetimes">;
253253

254254
def enable_experimental_distributed :
255255
Flag<["-"], "enable-experimental-distributed">,

include/swift/SIL/SILBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,10 @@ class SILBuilder {
715715
}
716716

717717
BeginBorrowInst *createBeginBorrow(SILLocation Loc, SILValue LV,
718-
bool defined = false) {
718+
bool isLexical = false) {
719719
assert(!LV->getType().isAddress());
720720
return insert(new (getModule())
721-
BeginBorrowInst(getSILDebugLocation(Loc), LV, defined));
721+
BeginBorrowInst(getSILDebugLocation(Loc), LV, isLexical));
722722
}
723723

724724
/// Convenience function for creating a load_borrow on non-trivial values and

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ void SILCloner<ImplClass>::visitBeginBorrowInst(BeginBorrowInst *Inst) {
10841084
recordClonedInstruction(
10851085
Inst, getBuilder().createBeginBorrow(getOpLocation(Inst->getLoc()),
10861086
getOpValue(Inst->getOperand()),
1087-
Inst->isDefined()));
1087+
Inst->isLexical()));
10881088
}
10891089

10901090
template <typename ImplClass>

include/swift/SIL/SILInstruction.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4030,20 +4030,20 @@ class BeginBorrowInst
40304030
SingleValueInstruction> {
40314031
friend class SILBuilder;
40324032

4033-
bool defined;
4033+
bool lexical;
40344034

4035-
BeginBorrowInst(SILDebugLocation DebugLoc, SILValue LValue, bool defined)
4035+
BeginBorrowInst(SILDebugLocation DebugLoc, SILValue LValue, bool isLexical)
40364036
: UnaryInstructionBase(DebugLoc, LValue,
40374037
LValue->getType().getObjectType()),
4038-
defined(defined) {}
4038+
lexical(isLexical) {}
40394039

40404040
public:
40414041
using EndBorrowRange =
40424042
decltype(std::declval<ValueBase>().getUsersOfType<EndBorrowInst>());
40434043

4044-
/// Whether the borrow scope defined by this instruction corresponds to a
4045-
/// source-level VarDecl.
4046-
bool isDefined() const { return defined; }
4044+
/// Whether the borrow scope introduced by this instruction corresponds to a
4045+
/// source-level lexical scope.
4046+
bool isLexical() const { return lexical; }
40474047

40484048
/// Return a range over all EndBorrow instructions for this BeginBorrow.
40494049
EndBorrowRange getEndBorrows() const;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
429429
Opts.EnableExperimentalConcurrency |=
430430
Args.hasArg(OPT_enable_experimental_concurrency);
431431

432-
Opts.EnableExperimentalDefinedLifetimes |=
433-
Args.hasArg(OPT_enable_experimental_defined_lifetimes);
432+
Opts.EnableExperimentalLexicalLifetimes |=
433+
Args.hasArg(OPT_enable_experimental_lexical_lifetimes);
434434

435435
Opts.EnableExperimentalNamedOpaqueTypes |=
436436
Args.hasArg(OPT_enable_experimental_named_opaque_types);

lib/SIL/IR/SILPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
15081508
}
15091509

15101510
void visitBeginBorrowInst(BeginBorrowInst *LBI) {
1511-
if (LBI->isDefined()) {
1512-
*this << "[defined] ";
1511+
if (LBI->isLexical()) {
1512+
*this << "[lexical] ";
15131513
}
15141514
*this << getIDAndType(LBI->getOperand());
15151515
}

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,12 +3278,12 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
32783278
case SILInstructionKind::BeginBorrowInst: {
32793279
SourceLoc AddrLoc;
32803280

3281-
bool defined = false;
3281+
bool isLexical = false;
32823282
StringRef attributeName;
32833283

32843284
if (parseSILOptional(attributeName, *this)) {
3285-
if (attributeName.equals("defined"))
3286-
defined = true;
3285+
if (attributeName.equals("lexical"))
3286+
isLexical = true;
32873287
else
32883288
return true;
32893289
}
@@ -3292,7 +3292,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
32923292
parseSILDebugLocation(InstLoc, B))
32933293
return true;
32943294

3295-
ResultVal = B.createBeginBorrow(InstLoc, Val, defined);
3295+
ResultVal = B.createBeginBorrow(InstLoc, Val, isLexical);
32963296
break;
32973297
}
32983298

lib/SILGen/SILGenDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class DestroyLocalVariable : public Cleanup {
272272
void emit(SILGenFunction &SGF, CleanupLocation l,
273273
ForUnwind_t forUnwind) override {
274274
SILValue val = SGF.VarLocs[Var].value;
275-
if (SGF.getASTContext().LangOpts.EnableExperimentalDefinedLifetimes &&
275+
if (SGF.getASTContext().LangOpts.EnableExperimentalLexicalLifetimes &&
276276
val->getOwnershipKind() != OwnershipKind::None)
277277
SGF.B.createEndBorrow(l, val);
278278
SGF.destroyLocalVariable(l, Var);
@@ -543,10 +543,10 @@ class LetValueInitialization : public Initialization {
543543
address = value;
544544
SILLocation PrologueLoc(vd);
545545

546-
if (SGF.getASTContext().LangOpts.EnableExperimentalDefinedLifetimes &&
546+
if (SGF.getASTContext().LangOpts.EnableExperimentalLexicalLifetimes &&
547547
value->getOwnershipKind() != OwnershipKind::None)
548548
value = SILValue(
549-
SGF.B.createBeginBorrow(PrologueLoc, value, /*defined*/ true));
549+
SGF.B.createBeginBorrow(PrologueLoc, value, /*isLexical*/ true));
550550
SGF.VarLocs[vd] = SILGenFunction::VarLoc::get(value);
551551

552552
// Emit a debug_value[_addr] instruction to record the start of this value's
@@ -1734,7 +1734,7 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
17341734
SILValue Val = loc.value;
17351735
if (!Val->getType().isAddress()) {
17361736
SILValue valueToBeDestroyed;
1737-
if (getASTContext().LangOpts.EnableExperimentalDefinedLifetimes &&
1737+
if (getASTContext().LangOpts.EnableExperimentalLexicalLifetimes &&
17381738
Val->getOwnershipKind() != OwnershipKind::None) {
17391739
auto *inst = cast<BeginBorrowInst>(Val.getDefiningInstruction());
17401740
valueToBeDestroyed = inst->getOperand();

0 commit comments

Comments
 (0)