Skip to content

Commit 4014407

Browse files
committed
[NFC] SIL: Typed alloc_box's hasPointerEscape.
1 parent 7db84f2 commit 4014407

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ class SILBuilder {
481481
bool reflection = false,
482482
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
483483
DoesNotUseMoveableValueDebugInfo,
484-
bool hasPointerEscape = false) {
484+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape) {
485485
return createAllocBox(loc, SILBoxType::get(fieldType.getASTType()), Var,
486486
hasDynamicLifetime, reflection,
487487
usesMoveableValueDebugInfo,
@@ -496,7 +496,8 @@ class SILBuilder {
496496
bool reflection = false,
497497
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
498498
DoesNotUseMoveableValueDebugInfo,
499-
bool skipVarDeclAssert = false, bool hasPointerEscape = false) {
499+
bool skipVarDeclAssert = false,
500+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape) {
500501
#if NDEBUG
501502
(void)skipVarDeclAssert;
502503
#endif

include/swift/SIL/SILInstruction.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,11 @@ enum IsLexical_t : bool {
19781978
IsLexical = true,
19791979
};
19801980

1981+
enum HasPointerEscape_t : bool {
1982+
DoesNotHavePointerEscape = false,
1983+
HasPointerEscape = true,
1984+
};
1985+
19811986
/// AllocStackInst - This represents the allocation of an unboxed (i.e., no
19821987
/// reference count) stack memory. The memory is provided uninitialized.
19831988
class AllocStackInst final
@@ -2448,14 +2453,14 @@ class AllocBoxInst final
24482453
HasDynamicLifetime_t hasDynamicLifetime, bool reflection = false,
24492454
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
24502455
DoesNotUseMoveableValueDebugInfo,
2451-
bool hasPointerEscape = false);
2456+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape);
24522457

24532458
static AllocBoxInst *create(
24542459
SILDebugLocation Loc, CanSILBoxType boxType, SILFunction &F,
24552460
std::optional<SILDebugVariable> Var,
24562461
HasDynamicLifetime_t hasDynamicLifetime, bool reflection = false,
24572462
UsesMoveableValueDebugInfo_t wasMoved = DoesNotUseMoveableValueDebugInfo,
2458-
bool hasPointerEscape = false);
2463+
HasPointerEscape_t hasPointerEscape = DoesNotHavePointerEscape);
24592464

24602465
public:
24612466
CanSILBoxType getBoxType() const {
@@ -2474,8 +2479,8 @@ class AllocBoxInst final
24742479
sharedUInt8().AllocBoxInst.pointerEscape = pointerEscape;
24752480
}
24762481

2477-
bool hasPointerEscape() const {
2478-
return sharedUInt8().AllocBoxInst.pointerEscape;
2482+
HasPointerEscape_t hasPointerEscape() const {
2483+
return HasPointerEscape_t(sharedUInt8().AllocBoxInst.pointerEscape);
24792484
}
24802485

24812486
/// True if the box should be emitted with reflection metadata for its

lib/SIL/IR/SILInstructions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ AllocBoxInst::AllocBoxInst(
397397
std::optional<SILDebugVariable> Var,
398398
HasDynamicLifetime_t hasDynamicLifetime, bool reflection,
399399
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo,
400-
bool hasPointerEscape)
400+
HasPointerEscape_t hasPointerEscape)
401401
: NullaryInstructionWithTypeDependentOperandsBase(
402402
Loc, TypeDependentOperands, SILType::getPrimitiveObjectType(BoxType)),
403403
VarInfo(Var, getTrailingObjects<char>()) {
@@ -414,15 +414,15 @@ AllocBoxInst::AllocBoxInst(
414414
sharedUInt8().AllocBoxInst.usesMoveableValueDebugInfo =
415415
(bool)usesMoveableValueDebugInfo;
416416

417-
sharedUInt8().AllocBoxInst.pointerEscape = hasPointerEscape;
417+
sharedUInt8().AllocBoxInst.pointerEscape = (bool)hasPointerEscape;
418418
}
419419

420420
AllocBoxInst *
421421
AllocBoxInst::create(SILDebugLocation Loc, CanSILBoxType BoxType,
422422
SILFunction &F, std::optional<SILDebugVariable> Var,
423423
HasDynamicLifetime_t hasDynamicLifetime, bool reflection,
424424
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo,
425-
bool hasPointerEscape) {
425+
HasPointerEscape_t hasPointerEscape) {
426426
SmallVector<SILValue, 8> TypeDependentOperands;
427427
collectTypeDependentOperands(TypeDependentOperands, F, BoxType);
428428
auto Sz = totalSizeToAlloc<swift::Operand, char>(TypeDependentOperands.size(),

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
26082608
bool hasReflection = false;
26092609
UsesMoveableValueDebugInfo_t usesMoveableValueDebugInfo =
26102610
DoesNotUseMoveableValueDebugInfo;
2611-
bool hasPointerEscape = false;
2611+
auto hasPointerEscape = DoesNotHavePointerEscape;
26122612
StringRef attrName;
26132613
SourceLoc attrLoc;
26142614
while (parseSILOptional(attrName, attrLoc, *this)) {
@@ -2619,7 +2619,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
26192619
} else if (attrName.equals("moveable_value_debuginfo")) {
26202620
usesMoveableValueDebugInfo = UsesMoveableValueDebugInfo;
26212621
} else if (attrName.equals("pointer_escape")) {
2622-
hasPointerEscape = true;
2622+
hasPointerEscape = HasPointerEscape;
26232623
} else {
26242624
P.diagnose(attrLoc, diag::sil_invalid_attribute_for_expected, attrName,
26252625
"dynamic_lifetime, reflection, pointer_escape or "

lib/Serialization/DeserializeSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
13821382
bool reflection = (Attr >> 1) & 0x1;
13831383
auto usesMoveableValueDebugInfo =
13841384
UsesMoveableValueDebugInfo_t((Attr >> 2) & 0x1);
1385-
bool pointerEscape = (Attr >> 3) & 0x1;
1385+
auto pointerEscape = HasPointerEscape_t((Attr >> 3) & 0x1);
13861386
ResultInst = Builder.createAllocBox(
13871387
Loc, cast<SILBoxType>(MF->getType(TyID)->getCanonicalType()),
13881388
std::nullopt, hasDynamicLifetime, reflection,

0 commit comments

Comments
 (0)