Skip to content

Commit 37d8984

Browse files
committed
[NFC] SIL: Typed move_value's isFromVarDecl.
1 parent 83bc56f commit 37d8984

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ class SILBuilder {
14291429
MoveValueInst *createMoveValue(
14301430
SILLocation loc, SILValue operand, IsLexical_t isLexical = IsNotLexical,
14311431
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
1432-
bool fromVarDecl = false) {
1432+
IsFromVarDecl_t fromVarDecl = IsNotFromVarDecl) {
14331433
assert(getFunction().hasOwnership());
14341434
assert(!operand->getType().isTrivial(getFunction()) &&
14351435
"Should not be passing trivial values to this api. Use instead "
@@ -2852,7 +2852,7 @@ class SILBuilder {
28522852
SILValue emitMoveValueOperation(
28532853
SILLocation Loc, SILValue v, IsLexical_t isLexical = IsNotLexical,
28542854
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape,
2855-
bool fromVarDecl = false) {
2855+
IsFromVarDecl_t fromVarDecl = IsNotFromVarDecl) {
28562856
assert(!v->getType().isAddress());
28572857
if (v->getType().isTrivial(*getInsertionBB()->getParent()))
28582858
return v;

include/swift/SIL/SILInstruction.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8693,11 +8693,11 @@ class MoveValueInst
86938693

86948694
MoveValueInst(SILDebugLocation DebugLoc, SILValue operand,
86958695
IsLexical_t isLexical, HasPointerEscape_t hasPointerEscape,
8696-
bool fromVarDecl)
8696+
IsFromVarDecl_t fromVarDecl)
86978697
: UnaryInstructionBase(DebugLoc, operand, operand->getType()) {
86988698
sharedUInt8().MoveValueInst.lexical = (bool)isLexical;
86998699
sharedUInt8().MoveValueInst.pointerEscape = (bool)hasPointerEscape;
8700-
sharedUInt8().MoveValueInst.fromVarDecl = fromVarDecl;
8700+
sharedUInt8().MoveValueInst.fromVarDecl = (bool)fromVarDecl;
87018701
}
87028702

87038703
public:
@@ -8725,7 +8725,9 @@ class MoveValueInst
87258725
sharedUInt8().MoveValueInst.pointerEscape = pointerEscape;
87268726
}
87278727

8728-
bool isFromVarDecl() const { return sharedUInt8().MoveValueInst.fromVarDecl; }
8728+
IsFromVarDecl_t isFromVarDecl() const {
8729+
return IsFromVarDecl_t(sharedUInt8().MoveValueInst.fromVarDecl);
8730+
}
87298731
};
87308732

87318733
/// Drop the user-defined deinitializer from a struct or enum. Takes either an

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
34963496
bool allowsDiagnostics = false;
34973497
auto isLexical = IsNotLexical;
34983498
auto hasPointerEscape = DoesNotHavePointerEscape;
3499-
bool fromVarDecl = false;
3499+
auto fromVarDecl = IsNotFromVarDecl;
35003500

35013501
StringRef AttrName;
35023502
SourceLoc AttrLoc;
@@ -3508,7 +3508,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
35083508
else if (AttrName == "pointer_escape")
35093509
hasPointerEscape = HasPointerEscape;
35103510
else if (AttrName == "var_decl")
3511-
fromVarDecl = true;
3511+
fromVarDecl = IsFromVarDecl;
35123512
else {
35133513
P.diagnose(InstLoc.getSourceLoc(),
35143514
diag::sil_invalid_attribute_for_instruction, AttrName,

lib/SILGen/SILGenDecl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +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-
DoesNotHavePointerEscape,
846-
/*fromVarDecl=*/true);
845+
DoesNotHavePointerEscape, IsFromVarDecl);
847846
value =
848847
SGF.B.createOwnedCopyableToMoveOnlyWrapperValue(PrologueLoc, value);
849848
return SGF.B.createMarkUnresolvedNonCopyableValueInst(
@@ -860,8 +859,7 @@ class LetValueInitialization : public Initialization {
860859

861860
if (value->getOwnershipKind() == OwnershipKind::Owned)
862861
return SGF.B.createMoveValue(PrologueLoc, value, isLexical,
863-
DoesNotHavePointerEscape,
864-
/*fromVarDecl=*/true);
862+
DoesNotHavePointerEscape, IsFromVarDecl);
865863

866864
return SGF.B.createBeginBorrow(PrologueLoc, value, isLexical,
867865
DoesNotHavePointerEscape, IsFromVarDecl);

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,12 +2373,12 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
23732373
bool AllowsDiagnostics = Attr & 0x1;
23742374
IsLexical_t isLexical = IsLexical_t((Attr >> 1) & 0x1);
23752375
auto isEscaping = HasPointerEscape_t((Attr >> 2) & 0x1);
2376-
bool IsFromVarDecl = (Attr >> 3) & 0x1;
2376+
auto isFromVarDecl = IsFromVarDecl_t((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)