Skip to content

Commit 70d90b4

Browse files
committed
[NFC] SIL: Typed begin_borrow's hasPointerEscape.
1 parent 4014407 commit 70d90b4

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

include/swift/SIL/SILBuilder.h

+8-9
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,10 @@ class SILBuilder {
823823
LoadBorrowInst(getSILDebugLocation(Loc), LV));
824824
}
825825

826-
BeginBorrowInst *createBeginBorrow(SILLocation Loc, SILValue LV,
827-
IsLexical_t isLexical = IsNotLexical,
828-
bool hasPointerEscape = false,
829-
bool fromVarDecl = false,
830-
bool fixed = false) {
826+
BeginBorrowInst *createBeginBorrow(
827+
SILLocation Loc, SILValue LV, IsLexical_t isLexical = IsNotLexical,
828+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
829+
bool fromVarDecl = false, bool fixed = false) {
831830
assert(getFunction().hasOwnership());
832831
assert(!LV->getType().isAddress());
833832
return insert(new (getModule())
@@ -851,10 +850,10 @@ class SILBuilder {
851850
return createLoadBorrow(loc, v);
852851
}
853852

854-
SILValue emitBeginBorrowOperation(SILLocation loc, SILValue v,
855-
IsLexical_t isLexical = IsNotLexical,
856-
bool hasPointerEscape = false,
857-
bool fromVarDecl = false) {
853+
SILValue emitBeginBorrowOperation(
854+
SILLocation loc, SILValue v, IsLexical_t isLexical = IsNotLexical,
855+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
856+
bool fromVarDecl = false) {
858857
if (!hasOwnership() ||
859858
v->getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
860859
return v;

include/swift/SIL/SILInstruction.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ class BeginBorrowInst
45644564
USE_SHARED_UINT8;
45654565

45664566
BeginBorrowInst(SILDebugLocation DebugLoc, SILValue LValue,
4567-
IsLexical_t isLexical, bool hasPointerEscape,
4567+
IsLexical_t isLexical, HasPointerEscape_t hasPointerEscape,
45684568
bool fromVarDecl, bool fixed)
45694569
: UnaryInstructionBase(DebugLoc, LValue,
45704570
LValue->getType().getObjectType()) {
@@ -4597,8 +4597,8 @@ class BeginBorrowInst
45974597
}
45984598

45994599
/// WARNING: this flag is not yet implemented!
4600-
bool hasPointerEscape() const {
4601-
return sharedUInt8().BeginBorrowInst.pointerEscape;
4600+
HasPointerEscape_t hasPointerEscape() const {
4601+
return HasPointerEscape_t(sharedUInt8().BeginBorrowInst.pointerEscape);
46024602
}
46034603
void setHasPointerEscape(bool pointerEscape) {
46044604
sharedUInt8().BeginBorrowInst.pointerEscape = pointerEscape;

lib/SIL/Parser/ParseSIL.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3741,7 +3741,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
37413741
SourceLoc AddrLoc;
37423742

37433743
auto isLexical = IsNotLexical;
3744-
bool hasPointerEscape = false;
3744+
auto hasPointerEscape = DoesNotHavePointerEscape;
37453745
bool fromVarDecl = false;
37463746
bool fixed = false;
37473747

@@ -3751,7 +3751,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
37513751
if (AttrName == "lexical")
37523752
isLexical = IsLexical;
37533753
else if (AttrName == "pointer_escape")
3754-
hasPointerEscape = true;
3754+
hasPointerEscape = HasPointerEscape;
37553755
else if (AttrName == "var_decl")
37563756
fromVarDecl = true;
37573757
else if (AttrName == "fixed")

lib/SILGen/SILGenBuilder.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ ManagedValue SILGenBuilder::createBeginBorrow(SILLocation loc,
11071107
IsLexical_t isLexical,
11081108
bool isFixed) {
11091109
auto *newValue =
1110-
SILBuilder::createBeginBorrow(loc, value.getValue(),
1111-
isLexical, false, false, isFixed);
1110+
SILBuilder::createBeginBorrow(loc, value.getValue(), isLexical,
1111+
DoesNotHavePointerEscape, false, isFixed);
11121112
SGF.emitManagedBorrowedRValueWithCleanup(newValue);
11131113
return ManagedValue::forBorrowedObjectRValue(newValue);
11141114
}
@@ -1118,8 +1118,8 @@ ManagedValue SILGenBuilder::createFormalAccessBeginBorrow(SILLocation loc,
11181118
IsLexical_t isLexical,
11191119
bool isFixed) {
11201120
auto *newValue =
1121-
SILBuilder::createBeginBorrow(loc, value.getValue(),
1122-
isLexical, false, false, isFixed);
1121+
SILBuilder::createBeginBorrow(loc, value.getValue(), isLexical,
1122+
DoesNotHavePointerEscape, false, isFixed);
11231123
return SGF.emitFormalEvaluationManagedBorrowedRValueWithCleanup(loc,
11241124
value.getValue(), newValue);
11251125
}

lib/SILGen/SILGenDecl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class LocalVariableInitialization : public SingleBufferInitialization {
573573
// requires one.
574574
Box = SGF.B.createBeginBorrow(
575575
decl, Box, IsLexical_t(lifetime.isLexical()),
576-
/*hasPointerEscape=*/false, /*fromVarDecl=*/true);
576+
DoesNotHavePointerEscape, /*fromVarDecl=*/true);
577577
}
578578

579579
Addr = SGF.B.createProjectBox(decl, Box, 0);
@@ -864,7 +864,7 @@ class LetValueInitialization : public Initialization {
864864
/*fromVarDecl=*/true);
865865

866866
return SGF.B.createBeginBorrow(PrologueLoc, value, isLexical,
867-
/*hasPointerEscape=*/false,
867+
DoesNotHavePointerEscape,
868868
/*fromVarDecl=*/true);
869869
}
870870

lib/SILGen/SILGenLValue.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,8 @@ namespace {
984984
case ExistentialRepresentation::Opaque:
985985
if (!base.getValue()->getType().isAddress()) {
986986
assert(!SGF.useLoweredAddresses());
987-
auto borrow =
988-
SGF.B.createBeginBorrow(loc, base.getValue(), IsNotLexical,
989-
/*hasPointerEscape=*/false);
987+
auto borrow = SGF.B.createBeginBorrow(
988+
loc, base.getValue(), IsNotLexical, DoesNotHavePointerEscape);
990989
auto value =
991990
SGF.B.createOpenExistentialValue(loc, borrow, getTypeOfRValue());
992991

lib/Serialization/DeserializeSIL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
22702270
case SILInstructionKind::BeginBorrowInst: {
22712271
assert(RecordKind == SIL_ONE_OPERAND && "Layout should be OneOperand.");
22722272
auto isLexical = IsLexical_t(Attr & 0x1);
2273-
bool hasPointerEscape = (Attr >> 1) & 0x1;
2273+
auto hasPointerEscape = HasPointerEscape_t((Attr >> 1) & 0x1);
22742274
bool fromVarDecl = (Attr >> 2) & 0x1;
22752275
bool isFixed = (Attr >> 3) & 0x1;
22762276
ResultInst = Builder.createBeginBorrow(

0 commit comments

Comments
 (0)