Skip to content

Commit c996601

Browse files
committed
SIL: object instruction is not a forwarding instruction
Because it can only appear in the initializer list of a global variable.
1 parent 68cc6c8 commit c996601

File tree

7 files changed

+20
-38
lines changed

7 files changed

+20
-38
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,19 +1615,8 @@ class SILBuilder {
16151615
ObjectInst *createObject(SILLocation Loc, SILType Ty,
16161616
ArrayRef<SILValue> Elements,
16171617
unsigned NumBaseElements) {
1618-
return createObject(Loc, Ty, Elements, NumBaseElements,
1619-
hasOwnership()
1620-
? mergeSILValueOwnership(Elements)
1621-
: ValueOwnershipKind(OwnershipKind::None));
1622-
}
1623-
1624-
ObjectInst *createObject(SILLocation Loc, SILType Ty,
1625-
ArrayRef<SILValue> Elements,
1626-
unsigned NumBaseElements,
1627-
ValueOwnershipKind forwardingOwnershipKind) {
16281618
return insert(ObjectInst::create(getSILDebugLocation(Loc), Ty, Elements,
1629-
NumBaseElements, getModule(),
1630-
forwardingOwnershipKind));
1619+
NumBaseElements, getModule()));
16311620
}
16321621

16331622
VectorInst *createVector(SILLocation Loc, ArrayRef<SILValue> Elements) {

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,10 +2163,7 @@ SILCloner<ImplClass>::visitObjectInst(ObjectInst *Inst) {
21632163
recordClonedInstruction(
21642164
Inst,
21652165
getBuilder().createObject(getOpLocation(Inst->getLoc()), Inst->getType(),
2166-
Elements, Inst->getBaseElements().size(),
2167-
getBuilder().hasOwnership()
2168-
? Inst->getForwardingOwnershipKind()
2169-
: ValueOwnershipKind(OwnershipKind::None)));
2166+
Elements, Inst->getBaseElements().size()));
21702167
}
21712168

21722169
template<typename ImplClass>

include/swift/SIL/SILInstruction.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6375,25 +6375,22 @@ class EndInitLetRefInst
63756375
/// static initializer list.
63766376
class ObjectInst final : public InstructionBaseWithTrailingOperands<
63776377
SILInstructionKind::ObjectInst, ObjectInst,
6378-
OwnershipForwardingSingleValueInstruction> {
6378+
SingleValueInstruction> {
63796379
friend SILBuilder;
63806380

63816381
unsigned numBaseElements;
63826382

63836383
/// Because of the storage requirements of ObjectInst, object
63846384
/// creation goes through 'create()'.
63856385
ObjectInst(SILDebugLocation DebugLoc, SILType Ty, ArrayRef<SILValue> Elements,
6386-
unsigned NumBaseElements,
6387-
ValueOwnershipKind forwardingOwnershipKind)
6388-
: InstructionBaseWithTrailingOperands(Elements, DebugLoc, Ty,
6389-
forwardingOwnershipKind),
6386+
unsigned NumBaseElements)
6387+
: InstructionBaseWithTrailingOperands(Elements, DebugLoc, Ty),
63906388
numBaseElements(NumBaseElements) {}
63916389

63926390
/// Construct an ObjectInst.
63936391
static ObjectInst *create(SILDebugLocation DebugLoc, SILType Ty,
63946392
ArrayRef<SILValue> Elements,
6395-
unsigned NumBaseElements, SILModule &M,
6396-
ValueOwnershipKind forwardingOwnershipKind);
6393+
unsigned NumBaseElements, SILModule &M);
63976394

63986395
public:
63996396
unsigned getNumBaseElements() const { return numBaseElements; }
@@ -11016,7 +11013,6 @@ class LinearFunctionExtractInst
1101611013
inline bool
1101711014
OwnershipForwardingSingleValueInstruction::classof(SILInstructionKind kind) {
1101811015
switch (kind) {
11019-
case SILInstructionKind::ObjectInst:
1102011016
case SILInstructionKind::EnumInst:
1102111017
case SILInstructionKind::UncheckedEnumDataInst:
1102211018
case SILInstructionKind::OpenExistentialRefInst:

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ SHOULD_NEVER_VISIT_INST(HasSymbol)
113113
SHOULD_NEVER_VISIT_INST(IntegerLiteral)
114114
SHOULD_NEVER_VISIT_INST(Metatype)
115115
SHOULD_NEVER_VISIT_INST(ObjCProtocol)
116+
SHOULD_NEVER_VISIT_INST(Object)
116117
SHOULD_NEVER_VISIT_INST(RetainValue)
117118
SHOULD_NEVER_VISIT_INST(RetainValueAddr)
118119
SHOULD_NEVER_VISIT_INST(StringLiteral)
@@ -362,7 +363,6 @@ OPERAND_OWNERSHIP(EndBorrow, AbortApply)
362363
return i->getForwardingOwnershipKind().getForwardingOperandOwnership( \
363364
/*allowUnowned*/ false); \
364365
}
365-
FORWARDING_OWNERSHIP(Object)
366366
FORWARDING_OWNERSHIP(OpenExistentialRef)
367367
FORWARDING_OWNERSHIP(ConvertFunction)
368368
FORWARDING_OWNERSHIP(RefToBridgeObject)

lib/SIL/IR/SILInstructions.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,12 +1475,11 @@ StructInst::StructInst(SILDebugLocation Loc, SILType Ty,
14751475

14761476
ObjectInst *ObjectInst::create(SILDebugLocation Loc, SILType Ty,
14771477
ArrayRef<SILValue> Elements,
1478-
unsigned NumBaseElements, SILModule &M,
1479-
ValueOwnershipKind forwardingOwnershipKind) {
1478+
unsigned NumBaseElements, SILModule &M) {
14801479
auto Size = totalSizeToAlloc<swift::Operand>(Elements.size());
14811480
auto Buffer = M.allocateInst(Size, alignof(ObjectInst));
14821481
return ::new (Buffer)
1483-
ObjectInst(Loc, Ty, Elements, NumBaseElements, forwardingOwnershipKind);
1482+
ObjectInst(Loc, Ty, Elements, NumBaseElements);
14841483
}
14851484

14861485
VectorInst *VectorInst::create(SILDebugLocation Loc,

lib/SIL/IR/ValueOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ CONSTANT_OWNERSHIP_INST(None, PackPackIndex)
174174
CONSTANT_OWNERSHIP_INST(None, ScalarPackIndex)
175175
CONSTANT_OWNERSHIP_INST(None, PackElementGet)
176176
CONSTANT_OWNERSHIP_INST(None, TuplePackElementAddr)
177+
CONSTANT_OWNERSHIP_INST(None, Object)
177178
CONSTANT_OWNERSHIP_INST(None, Vector)
178179

179180
#undef CONSTANT_OWNERSHIP_INST
@@ -270,7 +271,6 @@ FORWARDING_OWNERSHIP_INST(BridgeObjectToRef)
270271
FORWARDING_OWNERSHIP_INST(ConvertFunction)
271272
FORWARDING_OWNERSHIP_INST(OpenExistentialRef)
272273
FORWARDING_OWNERSHIP_INST(RefToBridgeObject)
273-
FORWARDING_OWNERSHIP_INST(Object)
274274
FORWARDING_OWNERSHIP_INST(Struct)
275275
FORWARDING_OWNERSHIP_INST(Tuple)
276276
FORWARDING_OWNERSHIP_INST(UncheckedRefCast)

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5496,18 +5496,19 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
54965496
if (P.parseToken(tok::r_paren, diag::expected_tok_in_sil_instr, ")"))
54975497
return true;
54985498

5499-
ValueOwnershipKind forwardingOwnership =
5500-
F && F->hasOwnership() ? mergeSILValueOwnership(OpList)
5501-
: ValueOwnershipKind(OwnershipKind::None);
5502-
if (parseForwardingOwnershipKind(forwardingOwnership)
5503-
|| parseSILDebugLocation(InstLoc, B)) {
5504-
return true;
5505-
}
55065499
if (Opcode == SILInstructionKind::StructInst) {
5500+
ValueOwnershipKind forwardingOwnership =
5501+
F && F->hasOwnership() ? mergeSILValueOwnership(OpList)
5502+
: ValueOwnershipKind(OwnershipKind::None);
5503+
if (parseForwardingOwnershipKind(forwardingOwnership)
5504+
|| parseSILDebugLocation(InstLoc, B)) {
5505+
return true;
5506+
}
55075507
ResultVal = B.createStruct(InstLoc, Ty, OpList, forwardingOwnership);
55085508
} else {
5509-
ResultVal = B.createObject(InstLoc, Ty, OpList, NumBaseElems,
5510-
forwardingOwnership);
5509+
if (parseSILDebugLocation(InstLoc, B))
5510+
return true;
5511+
ResultVal = B.createObject(InstLoc, Ty, OpList, NumBaseElems );
55115512
}
55125513
break;
55135514
}

0 commit comments

Comments
 (0)