Skip to content

Commit ec6b447

Browse files
committed
[NFC] SIL: Typed alloc_box's hasDynamicLifetime.
1 parent dfa5c98 commit ec6b447

File tree

9 files changed

+42
-42
lines changed

9 files changed

+42
-42
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -474,28 +474,29 @@ class SILBuilder {
474474

475475
/// Helper function that calls \p createAllocBox after constructing a
476476
/// SILBoxType for \p fieldType.
477-
AllocBoxInst *
478-
createAllocBox(SILLocation loc, SILType fieldType,
479-
std::optional<SILDebugVariable> Var = std::nullopt,
480-
bool hasDynamicLifetime = false, bool reflection = false,
481-
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
482-
DoesNotUseMoveableValueDebugInfo,
483-
bool hasPointerEscape = false) {
477+
AllocBoxInst *createAllocBox(
478+
SILLocation loc, SILType fieldType,
479+
std::optional<SILDebugVariable> Var = std::nullopt,
480+
HasDynamicLifetime_t hasDynamicLifetime = DoesNotHaveDynamicLifetime,
481+
bool reflection = false,
482+
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
483+
DoesNotUseMoveableValueDebugInfo,
484+
bool hasPointerEscape = false) {
484485
return createAllocBox(loc, SILBoxType::get(fieldType.getASTType()), Var,
485486
hasDynamicLifetime, reflection,
486487
usesMoveableValueDebugInfo,
487488
/*skipVarDeclAssert*/ false,
488489
hasPointerEscape);
489490
}
490491

491-
AllocBoxInst *
492-
createAllocBox(SILLocation Loc, CanSILBoxType BoxType,
493-
std::optional<SILDebugVariable> Var = std::nullopt,
494-
bool hasDynamicLifetime = false, bool reflection = false,
495-
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
496-
DoesNotUseMoveableValueDebugInfo,
497-
bool skipVarDeclAssert = false,
498-
bool hasPointerEscape = false) {
492+
AllocBoxInst *createAllocBox(
493+
SILLocation Loc, CanSILBoxType BoxType,
494+
std::optional<SILDebugVariable> Var = std::nullopt,
495+
HasDynamicLifetime_t hasDynamicLifetime = DoesNotHaveDynamicLifetime,
496+
bool reflection = false,
497+
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
498+
DoesNotUseMoveableValueDebugInfo,
499+
bool skipVarDeclAssert = false, bool hasPointerEscape = false) {
499500
#if NDEBUG
500501
(void)skipVarDeclAssert;
501502
#endif

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ SILCloner<ImplClass>::visitAllocBoxInst(AllocBoxInst *Inst) {
970970
Inst,
971971
getBuilder().createAllocBox(
972972
Loc, this->getOpType(Inst->getType()).template castTo<SILBoxType>(),
973-
VarInfo, /*hasDynamicLifetime*/ false,
973+
VarInfo, DoesNotHaveDynamicLifetime,
974974
/*reflection*/ false, DoesNotUseMoveableValueDebugInfo,
975975
/*skipVarDeclAssert*/ true));
976976
}

include/swift/SIL/SILInstruction.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,16 +2433,16 @@ class AllocBoxInst final
24332433

24342434
AllocBoxInst(SILDebugLocation DebugLoc, CanSILBoxType BoxType,
24352435
ArrayRef<SILValue> TypeDependentOperands, SILFunction &F,
2436-
std::optional<SILDebugVariable> Var, bool hasDynamicLifetime,
2437-
bool reflection = false,
2436+
std::optional<SILDebugVariable> Var,
2437+
HasDynamicLifetime_t hasDynamicLifetime, bool reflection = false,
24382438
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
24392439
DoesNotUseMoveableValueDebugInfo,
24402440
bool hasPointerEscape = false);
24412441

24422442
static AllocBoxInst *create(
24432443
SILDebugLocation Loc, CanSILBoxType boxType, SILFunction &F,
2444-
std::optional<SILDebugVariable> Var, bool hasDynamicLifetime,
2445-
bool reflection = false,
2444+
std::optional<SILDebugVariable> Var,
2445+
HasDynamicLifetime_t hasDynamicLifetime, bool reflection = false,
24462446
UsesMoveableValueDebugInfo_t wasMoved = DoesNotUseMoveableValueDebugInfo,
24472447
bool hasPointerEscape = false);
24482448

@@ -2452,11 +2452,11 @@ class AllocBoxInst final
24522452
}
24532453

24542454
void setDynamicLifetime() {
2455-
sharedUInt8().AllocBoxInst.dynamicLifetime = true;
2455+
sharedUInt8().AllocBoxInst.dynamicLifetime = (bool)HasDynamicLifetime;
24562456
}
24572457

2458-
bool hasDynamicLifetime() const {
2459-
return sharedUInt8().AllocBoxInst.dynamicLifetime;
2458+
HasDynamicLifetime_t hasDynamicLifetime() const {
2459+
return HasDynamicLifetime_t(sharedUInt8().AllocBoxInst.dynamicLifetime);
24602460
}
24612461

24622462
void setHasPointerEscape(bool pointerEscape) {

lib/SIL/IR/SILInstructions.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@ bool AllocRefDynamicInst::isDynamicTypeDeinitAndSizeKnownEquivalentToBaseType()
394394
AllocBoxInst::AllocBoxInst(
395395
SILDebugLocation Loc, CanSILBoxType BoxType,
396396
ArrayRef<SILValue> TypeDependentOperands, SILFunction &F,
397-
std::optional<SILDebugVariable> Var, bool hasDynamicLifetime,
398-
bool reflection, UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo,
397+
std::optional<SILDebugVariable> Var,
398+
HasDynamicLifetime_t hasDynamicLifetime, bool reflection,
399+
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo,
399400
bool hasPointerEscape)
400401
: NullaryInstructionWithTypeDependentOperandsBase(
401402
Loc, TypeDependentOperands, SILType::getPrimitiveObjectType(BoxType)),
@@ -419,7 +420,7 @@ AllocBoxInst::AllocBoxInst(
419420
AllocBoxInst *
420421
AllocBoxInst::create(SILDebugLocation Loc, CanSILBoxType BoxType,
421422
SILFunction &F, std::optional<SILDebugVariable> Var,
422-
bool hasDynamicLifetime, bool reflection,
423+
HasDynamicLifetime_t hasDynamicLifetime, bool reflection,
423424
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo,
424425
bool hasPointerEscape) {
425426
SmallVector<SILValue, 8> TypeDependentOperands;

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
26042604

26052605
switch (Opcode) {
26062606
case SILInstructionKind::AllocBoxInst: {
2607-
bool hasDynamicLifetime = false;
2607+
auto hasDynamicLifetime = DoesNotHaveDynamicLifetime;
26082608
bool hasReflection = false;
26092609
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
26102610
DoesNotUseMoveableValueDebugInfo;
@@ -2613,7 +2613,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
26132613
SourceLoc attrLoc;
26142614
while (parseSILOptional(attrName, attrLoc, *this)) {
26152615
if (attrName.equals("dynamic_lifetime")) {
2616-
hasDynamicLifetime = true;
2616+
hasDynamicLifetime = HasDynamicLifetime;
26172617
} else if (attrName.equals("reflection")) {
26182618
hasReflection = true;
26192619
} else if (attrName.equals("moveable_value_debuginfo")) {

lib/SILGen/SILGenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ class LocalVariableInitialization : public SingleBufferInitialization {
549549
if (generateDebugInfo)
550550
DbgVar = SILDebugVariable(decl->isLet(), ArgNo);
551551
Box = SGF.B.createAllocBox(
552-
decl, boxType, DbgVar, /*hasDynamicLifetime*/ false,
552+
decl, boxType, DbgVar, DoesNotHaveDynamicLifetime,
553553
/*reflection*/ false, DoesNotUseMoveableValueDebugInfo,
554554
!generateDebugInfo);
555555

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,15 +649,14 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
649649
}
650650
return false;
651651
};
652-
auto *ASI =
653-
Builder.createAllocStack(ABI->getLoc(), ty, ABI->getVarInfo(),
654-
HasDynamicLifetime_t(ABI->hasDynamicLifetime()),
655-
isLexical(), DoesNotUseMoveableValueDebugInfo
652+
auto *ASI = Builder.createAllocStack(ABI->getLoc(), ty, ABI->getVarInfo(),
653+
ABI->hasDynamicLifetime(), isLexical(),
654+
DoesNotUseMoveableValueDebugInfo
656655
#ifndef NDEBUG
657-
,
658-
true
656+
,
657+
true
659658
#endif
660-
);
659+
);
661660

662661
// Transfer a mark_uninitialized if we have one.
663662
SingleValueInstruction *StackBox = ASI;

lib/SILOptimizer/Transforms/PartialApplySimplification.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,10 @@ rewriteKnownCalleeWithExplicitContext(SILFunction *callee,
753753
// Continue emitting code to populate the context.
754754
B.setInsertionPoint(contextAlloc->getNextInstruction());
755755
} else {
756-
contextBuffer =
757-
B.createAllocBox(loc, contextStorageTy.castTo<SILBoxType>(),
758-
/*debug variable*/ std::nullopt,
759-
/*dynamic lifetime*/ false,
760-
/*reflection*/ true);
756+
contextBuffer = B.createAllocBox(
757+
loc, contextStorageTy.castTo<SILBoxType>(),
758+
/*debug variable*/ std::nullopt, DoesNotHaveDynamicLifetime,
759+
/*reflection*/ true);
761760
contextProj = B.createProjectBox(loc, contextBuffer, 0);
762761
}
763762

lib/Serialization/DeserializeSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
13781378

13791379
case SILInstructionKind::AllocBoxInst: {
13801380
assert(RecordKind == SIL_ONE_TYPE && "Layout should be OneType.");
1381-
bool hasDynamicLifetime = Attr & 0x1;
1381+
auto hasDynamicLifetime = HasDynamicLifetime_t(Attr & 0x1);
13821382
bool reflection = (Attr >> 1) & 0x1;
13831383
auto usesMoveableValueDebugInfo =
13841384
UsesMoveableValueDebugInfo_t((Attr >> 2) & 0x1);

0 commit comments

Comments
 (0)