Skip to content

Commit 46b08bd

Browse files
committed
[SIL] NFC: Typed move_value's hasPointerEscape.
1 parent 70d90b4 commit 46b08bd

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,10 +1425,10 @@ class SILBuilder {
14251425
operand, poisonRefs));
14261426
}
14271427

1428-
MoveValueInst *createMoveValue(SILLocation loc, SILValue operand,
1429-
IsLexical_t isLexical = IsNotLexical,
1430-
bool hasPointerEscape = false,
1431-
bool fromVarDecl = false) {
1428+
MoveValueInst *createMoveValue(
1429+
SILLocation loc, SILValue operand, IsLexical_t isLexical = IsNotLexical,
1430+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
1431+
bool fromVarDecl = false) {
14321432
assert(getFunction().hasOwnership());
14331433
assert(!operand->getType().isTrivial(getFunction()) &&
14341434
"Should not be passing trivial values to this api. Use instead "
@@ -2848,10 +2848,10 @@ class SILBuilder {
28482848

28492849
/// Convenience function that is a no-op for trivial values and inserts a
28502850
/// move_value on non-trivial instructions.
2851-
SILValue emitMoveValueOperation(SILLocation Loc, SILValue v,
2852-
IsLexical_t isLexical = IsNotLexical,
2853-
bool hasPointerEscape = false,
2854-
bool fromVarDecl = false) {
2851+
SILValue emitMoveValueOperation(
2852+
SILLocation Loc, SILValue v, IsLexical_t isLexical = IsNotLexical,
2853+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
2854+
bool fromVarDecl = false) {
28552855
assert(!v->getType().isAddress());
28562856
if (v->getType().isTrivial(*getInsertionBB()->getParent()))
28572857
return v;

include/swift/SIL/SILInstruction.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8680,10 +8680,11 @@ class MoveValueInst
86808680
USE_SHARED_UINT8;
86818681

86828682
MoveValueInst(SILDebugLocation DebugLoc, SILValue operand,
8683-
IsLexical_t isLexical, bool hasPointerEscape, bool fromVarDecl)
8683+
IsLexical_t isLexical, HasPointerEscape_t hasPointerEscape,
8684+
bool fromVarDecl)
86848685
: UnaryInstructionBase(DebugLoc, operand, operand->getType()) {
86858686
sharedUInt8().MoveValueInst.lexical = (bool)isLexical;
8686-
sharedUInt8().MoveValueInst.pointerEscape = hasPointerEscape;
8687+
sharedUInt8().MoveValueInst.pointerEscape = (bool)hasPointerEscape;
86878688
sharedUInt8().MoveValueInst.fromVarDecl = fromVarDecl;
86888689
}
86898690

@@ -8705,8 +8706,8 @@ class MoveValueInst
87058706
sharedUInt8().MoveValueInst.lexical = (bool)IsNotLexical;
87068707
}
87078708

8708-
bool hasPointerEscape() const {
8709-
return sharedUInt8().MoveValueInst.pointerEscape;
8709+
HasPointerEscape_t hasPointerEscape() const {
8710+
return HasPointerEscape_t(sharedUInt8().MoveValueInst.pointerEscape);
87108711
}
87118712
void setHasPointerEscape(bool pointerEscape) {
87128713
sharedUInt8().MoveValueInst.pointerEscape = pointerEscape;

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,7 +3495,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
34953495
case SILInstructionKind::MoveValueInst: {
34963496
bool allowsDiagnostics = false;
34973497
auto isLexical = IsNotLexical;
3498-
bool hasPointerEscape = false;
3498+
auto hasPointerEscape = DoesNotHavePointerEscape;
34993499
bool fromVarDecl = false;
35003500

35013501
StringRef AttrName;
@@ -3506,7 +3506,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
35063506
else if (AttrName == "lexical")
35073507
isLexical = IsLexical;
35083508
else if (AttrName == "pointer_escape")
3509-
hasPointerEscape = true;
3509+
hasPointerEscape = HasPointerEscape;
35103510
else if (AttrName == "var_decl")
35113511
fromVarDecl = true;
35123512
else {

lib/SILGen/SILGenDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ class LetValueInitialization : public Initialization {
842842
// that the move checker knows to check this variable.
843843
if (vd->isNoImplicitCopy()) {
844844
value = SGF.B.createMoveValue(PrologueLoc, value, IsLexical,
845-
/*hasPointerEscape=*/false,
845+
DoesNotHavePointerEscape,
846846
/*fromVarDecl=*/true);
847847
value =
848848
SGF.B.createOwnedCopyableToMoveOnlyWrapperValue(PrologueLoc, value);
@@ -860,7 +860,7 @@ class LetValueInitialization : public Initialization {
860860

861861
if (value->getOwnershipKind() == OwnershipKind::Owned)
862862
return SGF.B.createMoveValue(PrologueLoc, value, isLexical,
863-
/*hasPointerEscape=*/false,
863+
DoesNotHavePointerEscape,
864864
/*fromVarDecl=*/true);
865865

866866
return SGF.B.createBeginBorrow(PrologueLoc, value, isLexical,

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,13 +2372,13 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
23722372
auto Ty = MF->getType(TyID);
23732373
bool AllowsDiagnostics = Attr & 0x1;
23742374
IsLexical_t isLexical = IsLexical_t((Attr >> 1) & 0x1);
2375-
bool IsEscaping = (Attr >> 2) & 0x1;
2375+
auto isEscaping = HasPointerEscape_t((Attr >> 2) & 0x1);
23762376
bool IsFromVarDecl = (Attr >> 3) & 0x1;
23772377
auto *MVI = Builder.createMoveValue(
23782378
Loc,
23792379
getLocalValue(Builder.maybeGetFunction(), ValID,
23802380
getSILType(Ty, (SILValueCategory)TyCategory, Fn)),
2381-
isLexical, IsEscaping, IsFromVarDecl);
2381+
isLexical, isEscaping, IsFromVarDecl);
23822382
MVI->setAllowsDiagnostics(AllowsDiagnostics);
23832383
ResultInst = MVI;
23842384
break;

0 commit comments

Comments
 (0)