Skip to content

Commit e0b4f71

Browse files
committed
SIL: remove the alloc_vector instruction
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
1 parent 6407f9a commit e0b4f71

31 files changed

+5
-264
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ extension Instruction {
424424
is FloatLiteralInst,
425425
is ObjectInst,
426426
is VectorInst,
427-
is AllocVectorInst,
428427
is UncheckedRefCastInst,
429428
is UpcastInst,
430429
is ValueToBridgeObjectInst,

SwiftCompilerSources/Sources/SIL/Builder.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ public struct Builder {
130130
return notifyNew(dr.getAs(AllocStackInst.self))
131131
}
132132

133-
public func createAllocVector(capacity: Value, elementType: Type) -> AllocVectorInst {
134-
let dr = bridged.createAllocVector(capacity.bridged, elementType.bridged)
135-
return notifyNew(dr.getAs(AllocVectorInst.self))
136-
}
137-
138133
@discardableResult
139134
public func createDeallocStack(_ operand: Value) -> DeallocStackInst {
140135
let dr = bridged.createDeallocStack(operand.bridged)

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,10 +1275,6 @@ final public class AllocStackInst : SingleValueInstruction, Allocation, DebugVar
12751275
}
12761276
}
12771277

1278-
final public class AllocVectorInst : SingleValueInstruction, Allocation, UnaryInstruction {
1279-
public var capacity: Value { operand.value }
1280-
}
1281-
12821278
public class AllocRefInstBase : SingleValueInstruction, Allocation {
12831279
final public var isObjC: Bool { bridged.AllocRefInstBase_isObjc() }
12841280

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ public func registerSILClasses() {
226226
register(IsUniqueInst.self)
227227
register(DestroyNotEscapedClosureInst.self)
228228
register(AllocStackInst.self)
229-
register(AllocVectorInst.self)
230229
register(AllocPackInst.self)
231230
register(AllocPackMetadataInst.self)
232231
register(AllocRefInst.self)

docs/SIL/Instructions.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,6 @@ type, use `alloc_box`.
5555

5656
`T` must not be a pack type. To allocate a pack, use `alloc_pack`.
5757

58-
### alloc_vector
59-
60-
```
61-
sil-instruction ::= 'alloc_vector' sil-type, sil-operand
62-
63-
%1 = alloc_vector $T, %0 : $Builtin.Word
64-
// %1 has type $*T
65-
```
66-
67-
Allocates uninitialized memory that is sufficiently aligned on the stack
68-
to contain a vector of values of type `T`. The result of the instruction
69-
is the address of the allocated memory. The number of vector elements is
70-
specified by the operand, which must be a builtin integer value.
71-
72-
`alloc_vector` either allocates memory on the stack or - if contained in
73-
a global variable static initializer list - in the data section.
74-
75-
`alloc_vector` is a stack allocation instruction, unless it's contained
76-
in a global initializer list. See the section above on stack discipline.
77-
The corresponding stack deallocation instruction is `dealloc_stack`.
78-
7958
### alloc_pack
8059

8160
```

include/swift/SIL/SILBridgingImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,10 +2003,6 @@ BridgedInstruction BridgedBuilder::createAllocStack(BridgedType type,
20032003
swift::UsesMoveableValueDebugInfo_t(wasMoved), /*skipVarDeclAssert=*/ true)};
20042004
}
20052005

2006-
BridgedInstruction BridgedBuilder::createAllocVector(BridgedValue capacity, BridgedType type) const {
2007-
return {unbridged().createAllocVector(regularLoc(), capacity.getSILValue(), type.unbridged())};
2008-
}
2009-
20102006
BridgedInstruction BridgedBuilder::createDeallocStack(BridgedValue operand) const {
20112007
return {unbridged().createDeallocStack(regularLoc(), operand.getSILValue())};
20122008
}

include/swift/SIL/SILBuilder.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,6 @@ class SILBuilder {
437437
isFromVarDecl, wasMoved));
438438
}
439439

440-
AllocVectorInst *
441-
createAllocVector(SILLocation loc, SILValue capacity, SILType elementType) {
442-
if (isInsertingIntoGlobal()) {
443-
return insert(AllocVectorInst::createInInitializer(
444-
getSILDebugLocation(loc, true), capacity, elementType, getModule()));
445-
}
446-
return insert(AllocVectorInst::create(
447-
getSILDebugLocation(loc, true), capacity, elementType, getFunction()));
448-
}
449-
450440
AllocPackInst *createAllocPack(SILLocation loc, SILType packType) {
451441
return insert(AllocPackInst::create(getSILDebugLocation(loc), packType,
452442
getFunction()));

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,17 +1052,6 @@ SILCloner<ImplClass>::visitAllocStackInst(AllocStackInst *Inst) {
10521052
recordClonedInstruction(Inst, NewInst);
10531053
}
10541054

1055-
template <typename ImplClass>
1056-
void SILCloner<ImplClass>::visitAllocVectorInst(
1057-
AllocVectorInst *Inst) {
1058-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1059-
recordClonedInstruction(Inst, getBuilder().createAllocVector(
1060-
getOpLocation(Inst->getLoc()),
1061-
getOpValue(Inst->getCapacity()),
1062-
getOpType(Inst->getElementType())));
1063-
}
1064-
1065-
10661055
template <typename ImplClass>
10671056
void SILCloner<ImplClass>::visitAllocPackMetadataInst(
10681057
AllocPackMetadataInst *Inst) {

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,35 +2213,6 @@ class AllocStackInst final
22132213
DeallocStackInst *getSingleDeallocStack() const;
22142214
};
22152215

2216-
/// AllocVectorInst - Like AllocStackInst, but allocates a vector of elements.
2217-
class AllocVectorInst final
2218-
: public UnaryInstructionWithTypeDependentOperandsBase<
2219-
SILInstructionKind::AllocVectorInst, AllocVectorInst, AllocationInst> {
2220-
friend SILBuilder;
2221-
2222-
AllocVectorInst(SILDebugLocation loc, SILValue capacity, SILType resultType,
2223-
ArrayRef<SILValue> typeDependentOperands)
2224-
: UnaryInstructionWithTypeDependentOperandsBase(loc, capacity,
2225-
typeDependentOperands,
2226-
resultType) {
2227-
}
2228-
2229-
static AllocVectorInst *create(SILDebugLocation Loc, SILValue capacity,
2230-
SILType elementType, SILFunction &F);
2231-
2232-
static AllocVectorInst *createInInitializer(SILDebugLocation Loc,
2233-
SILValue capacity, SILType elementType, SILModule &M);
2234-
2235-
public:
2236-
/// getElementType - Get the type of the allocated memory (as opposed to the
2237-
/// type of the instruction itself, which will be an address type).
2238-
SILType getElementType() const {
2239-
return getType().getObjectType();
2240-
}
2241-
2242-
SILValue getCapacity() const { return getOperand(); }
2243-
};
2244-
22452216
/// AllocPackInst - This represents the allocation of a value pack
22462217
/// in stack memory. The memory is provided uninitialized.
22472218
class AllocPackInst final

include/swift/SIL/SILNodes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)
313313
ABSTRACT_SINGLE_VALUE_INST(AllocationInst, SingleValueInstruction)
314314
SINGLE_VALUE_INST(AllocStackInst, alloc_stack,
315315
AllocationInst, None, DoesNotRelease)
316-
SINGLE_VALUE_INST(AllocVectorInst, alloc_vector,
317-
AllocationInst, None, DoesNotRelease)
318316
SINGLE_VALUE_INST(AllocPackInst, alloc_pack,
319317
AllocationInst, None, DoesNotRelease)
320318
SINGLE_VALUE_INST(AllocPackMetadataInst, alloc_pack_metadata,

0 commit comments

Comments
 (0)