Skip to content

Commit 069653d

Browse files
authored
Merge pull request #42030 from eeckstein/remove-unused-instructions
SIL: remove unused instructions thin_function_to_pointer and pointer_ to_thin_function
2 parents 7fccd25 + 6b7ae41 commit 069653d

33 files changed

+23
-310
lines changed

docs/SIL.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6632,16 +6632,6 @@ passed to a function (materializeForSet) which escapes the closure in a way not
66326632
expressed by the convert's users. The mandatory pass must ensure the lifetime
66336633
in a conservative way.
66346634

6635-
thin_function_to_pointer
6636-
````````````````````````
6637-
6638-
TODO
6639-
6640-
pointer_to_thin_function
6641-
````````````````````````
6642-
6643-
TODO
6644-
66456635
classify_bridge_object
66466636
``````````````````````
66476637
::

include/swift/SIL/SILBuilder.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,18 +1060,6 @@ class SILBuilder {
10601060
lifetimeGuaranteed));
10611061
}
10621062

1063-
ThinFunctionToPointerInst *
1064-
createThinFunctionToPointer(SILLocation Loc, SILValue Op, SILType Ty) {
1065-
return insert(new (getModule()) ThinFunctionToPointerInst(
1066-
getSILDebugLocation(Loc), Op, Ty));
1067-
}
1068-
1069-
PointerToThinFunctionInst *
1070-
createPointerToThinFunction(SILLocation Loc, SILValue Op, SILType Ty) {
1071-
return insert(PointerToThinFunctionInst::create(
1072-
getSILDebugLocation(Loc), Op, Ty, getFunction()));
1073-
}
1074-
10751063
UpcastInst *createUpcast(SILLocation Loc, SILValue Op, SILType Ty) {
10761064
return createUpcast(Loc, Op, Ty, Op.getOwnershipKind());
10771065
}

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,26 +1434,6 @@ void SILCloner<ImplClass>::visitConvertEscapeToNoEscapeInst(
14341434
getOpType(Inst->getType()), Inst->isLifetimeGuaranteed()));
14351435
}
14361436

1437-
template<typename ImplClass>
1438-
void SILCloner<ImplClass>::visitThinFunctionToPointerInst(
1439-
ThinFunctionToPointerInst *Inst) {
1440-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1441-
recordClonedInstruction(Inst, getBuilder().createThinFunctionToPointer(
1442-
getOpLocation(Inst->getLoc()),
1443-
getOpValue(Inst->getOperand()),
1444-
getOpType(Inst->getType())));
1445-
}
1446-
1447-
template<typename ImplClass>
1448-
void SILCloner<ImplClass>::visitPointerToThinFunctionInst(
1449-
PointerToThinFunctionInst *Inst) {
1450-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1451-
recordClonedInstruction(Inst, getBuilder().createPointerToThinFunction(
1452-
getOpLocation(Inst->getLoc()),
1453-
getOpValue(Inst->getOperand()),
1454-
getOpType(Inst->getType())));
1455-
}
1456-
14571437
template<typename ImplClass>
14581438
void
14591439
SILCloner<ImplClass>::visitUpcastInst(UpcastInst *Inst) {

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5241,39 +5241,6 @@ class ConvertEscapeToNoEscapeInst final
52415241
void setLifetimeGuaranteed() { lifetimeGuaranteed = true; }
52425242
};
52435243

5244-
/// ThinFunctionToPointerInst - Convert a thin function pointer to a
5245-
/// Builtin.RawPointer.
5246-
class ThinFunctionToPointerInst
5247-
: public UnaryInstructionBase<SILInstructionKind::ThinFunctionToPointerInst,
5248-
ConversionInst>
5249-
{
5250-
friend SILBuilder;
5251-
5252-
ThinFunctionToPointerInst(SILDebugLocation DebugLoc, SILValue operand,
5253-
SILType ty)
5254-
: UnaryInstructionBase(DebugLoc, operand, ty) {}
5255-
};
5256-
5257-
/// PointerToThinFunctionInst - Convert a Builtin.RawPointer to a thin
5258-
/// function pointer.
5259-
class PointerToThinFunctionInst final
5260-
: public UnaryInstructionWithTypeDependentOperandsBase<
5261-
SILInstructionKind::PointerToThinFunctionInst,
5262-
PointerToThinFunctionInst,
5263-
ConversionInst> {
5264-
friend SILBuilder;
5265-
5266-
PointerToThinFunctionInst(SILDebugLocation DebugLoc, SILValue operand,
5267-
ArrayRef<SILValue> TypeDependentOperands,
5268-
SILType ty)
5269-
: UnaryInstructionWithTypeDependentOperandsBase(
5270-
DebugLoc, operand, TypeDependentOperands, ty) {}
5271-
5272-
static PointerToThinFunctionInst *
5273-
create(SILDebugLocation DebugLoc, SILValue Operand, SILType Ty,
5274-
SILFunction &F);
5275-
};
5276-
52775244
/// UpcastInst - Perform a conversion of a class instance to a supertype.
52785245
class UpcastInst final : public UnaryInstructionWithTypeDependentOperandsBase<
52795246
SILInstructionKind::UpcastInst, UpcastInst,

include/swift/SIL/SILNode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ class alignas(8) SILNode :
367367

368368
UIWTDOB_BITFIELD(ConvertFunctionInst, ConversionInst, 1,
369369
WithoutActuallyEscaping : 1);
370-
UIWTDOB_BITFIELD_EMPTY(PointerToThinFunctionInst, ConversionInst);
371370
UIWTDOB_BITFIELD_EMPTY(UnconditionalCheckedCastInst, ConversionInst);
372371
UIWTDOB_BITFIELD_EMPTY(UpcastInst, ConversionInst);
373372
UIWTDOB_BITFIELD_EMPTY(UncheckedRefCastInst, ConversionInst);

include/swift/SIL/SILNodes.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,6 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)
405405
ConversionInst, None, DoesNotRelease)
406406
SINGLE_VALUE_INST(ConvertEscapeToNoEscapeInst, convert_escape_to_noescape,
407407
ConversionInst, None, DoesNotRelease)
408-
SINGLE_VALUE_INST(ThinFunctionToPointerInst, thin_function_to_pointer,
409-
ConversionInst, None, DoesNotRelease)
410-
SINGLE_VALUE_INST(PointerToThinFunctionInst, pointer_to_thin_function,
411-
ConversionInst, None, DoesNotRelease)
412408
SINGLE_VALUE_INST(RefToBridgeObjectInst, ref_to_bridge_object,
413409
ConversionInst, None, DoesNotRelease)
414410
BRIDGED_SINGLE_VALUE_INST(BridgeObjectToRefInst, bridge_object_to_ref,

include/swift/SIL/SILNodes.def.rej

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
***************
2+
*** 405,414 ****
3+
ConversionInst, None, DoesNotRelease)
4+
SINGLE_VALUE_INST(ConvertEscapeToNoEscapeInst, convert_escape_to_noescape,
5+
ConversionInst, None, DoesNotRelease)
6+
- SINGLE_VALUE_INST(ThinFunctionToPointerInst, thin_function_to_pointer,
7+
- ConversionInst, None, DoesNotRelease)
8+
- SINGLE_VALUE_INST(PointerToThinFunctionInst, pointer_to_thin_function,
9+
- ConversionInst, None, DoesNotRelease)
10+
BRIDGED_SINGLE_VALUE_INST(RefToBridgeObjectInst, ref_to_bridge_object,
11+
ConversionInst, None, DoesNotRelease)
12+
BRIDGED_SINGLE_VALUE_INST(BridgeObjectToRefInst, bridge_object_to_ref,
13+
--- 405,410 ----
14+
ConversionInst, None, DoesNotRelease)
15+
SINGLE_VALUE_INST(ConvertEscapeToNoEscapeInst, convert_escape_to_noescape,
16+
ConversionInst, None, DoesNotRelease)
17+
BRIDGED_SINGLE_VALUE_INST(RefToBridgeObjectInst, ref_to_bridge_object,
18+
ConversionInst, None, DoesNotRelease)
19+
BRIDGED_SINGLE_VALUE_INST(BridgeObjectToRefInst, bridge_object_to_ref,

lib/IRGen/IRGenSIL.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,6 @@ class IRGenSILFunction :
13111311

13121312
void visitConvertFunctionInst(ConvertFunctionInst *i);
13131313
void visitConvertEscapeToNoEscapeInst(ConvertEscapeToNoEscapeInst *i);
1314-
void visitThinFunctionToPointerInst(ThinFunctionToPointerInst *i);
1315-
void visitPointerToThinFunctionInst(PointerToThinFunctionInst *i);
13161314
void visitUpcastInst(UpcastInst *i);
13171315
void visitAddressToPointerInst(AddressToPointerInst *i);
13181316
void visitPointerToAddressInst(PointerToAddressInst *i);
@@ -5856,26 +5854,6 @@ void IRGenSILFunction::visitConvertEscapeToNoEscapeInst(
58565854
setLoweredExplosion(i, out);
58575855
}
58585856

5859-
void IRGenSILFunction::visitThinFunctionToPointerInst(
5860-
swift::ThinFunctionToPointerInst *i) {
5861-
Explosion in = getLoweredExplosion(i->getOperand());
5862-
llvm::Value *fn = in.claimNext();
5863-
fn = Builder.CreateBitCast(fn, IGM.Int8PtrTy);
5864-
Explosion out;
5865-
out.add(fn);
5866-
setLoweredExplosion(i, out);
5867-
}
5868-
5869-
void IRGenSILFunction::visitPointerToThinFunctionInst(
5870-
swift::PointerToThinFunctionInst *i) {
5871-
Explosion in = getLoweredExplosion(i->getOperand());
5872-
llvm::Value *fn = in.claimNext();
5873-
fn = Builder.CreateBitCast(fn, IGM.FunctionPtrTy);
5874-
Explosion out;
5875-
out.add(fn);
5876-
setLoweredExplosion(i, out);
5877-
}
5878-
58795857
void IRGenSILFunction::visitAddressToPointerInst(swift::AddressToPointerInst *i)
58805858
{
58815859
Explosion to;

lib/IRGen/LoadableByAddress.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,9 +2782,6 @@ bool LoadableByAddress::recreateConvInstr(SILInstruction &I,
27822782
IRGenModule *currIRMod =
27832783
getIRGenModule()->IRGen.getGenModule(convInstr->getFunction());
27842784
SILType currSILType = convInstr->getType();
2785-
if (auto *thinToPointer = dyn_cast<ThinFunctionToPointerInst>(convInstr)) {
2786-
currSILType = thinToPointer->getOperand()->getType();
2787-
}
27882785
auto currSILFunctionType = currSILType.castTo<SILFunctionType>();
27892786
GenericEnvironment *genEnv =
27902787
getSubstGenericEnvironment(convInstr->getFunction());
@@ -2813,14 +2810,6 @@ bool LoadableByAddress::recreateConvInstr(SILInstruction &I,
28132810
instr->getLoc(), instr->getOperand(), newType);
28142811
break;
28152812
}
2816-
case SILInstructionKind::ThinFunctionToPointerInst: {
2817-
auto instr = cast<ThinFunctionToPointerInst>(convInstr);
2818-
newType =
2819-
MapperCache.getNewSILType(genEnv, instr->getType(), *getIRGenModule());
2820-
newInstr = convBuilder.createThinFunctionToPointer(
2821-
instr->getLoc(), instr->getOperand(), newType);
2822-
break;
2823-
}
28242813
case SILInstructionKind::ConvertFunctionInst: {
28252814
auto instr = cast<ConvertFunctionInst>(convInstr);
28262815
newInstr = convBuilder.createConvertFunction(
@@ -2956,7 +2945,6 @@ void LoadableByAddress::run() {
29562945
case SILInstructionKind::ConvertFunctionInst:
29572946
case SILInstructionKind::ConvertEscapeToNoEscapeInst:
29582947
case SILInstructionKind::MarkDependenceInst:
2959-
case SILInstructionKind::ThinFunctionToPointerInst:
29602948
case SILInstructionKind::ThinToThickFunctionInst:
29612949
case SILInstructionKind::DifferentiableFunctionInst:
29622950
case SILInstructionKind::LinearFunctionInst:

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ OPERAND_OWNERSHIP(TrivialUse, ObjCToThickMetatype)
171171
OPERAND_OWNERSHIP(TrivialUse, OpenExistentialAddr)
172172
OPERAND_OWNERSHIP(TrivialUse, OpenExistentialMetatype)
173173
OPERAND_OWNERSHIP(TrivialUse, PointerToAddress)
174-
OPERAND_OWNERSHIP(TrivialUse, PointerToThinFunction)
175174
OPERAND_OWNERSHIP(TrivialUse, ProjectBlockStorage)
176175
OPERAND_OWNERSHIP(TrivialUse, RawPointerToRef)
177176
OPERAND_OWNERSHIP(TrivialUse, SelectEnumAddr)
@@ -180,7 +179,6 @@ OPERAND_OWNERSHIP(TrivialUse, SwitchEnumAddr)
180179
OPERAND_OWNERSHIP(TrivialUse, SwitchValue)
181180
OPERAND_OWNERSHIP(TrivialUse, TailAddr)
182181
OPERAND_OWNERSHIP(TrivialUse, ThickToObjCMetatype)
183-
OPERAND_OWNERSHIP(TrivialUse, ThinFunctionToPointer)
184182
OPERAND_OWNERSHIP(TrivialUse, ThinToThickFunction)
185183
OPERAND_OWNERSHIP(TrivialUse, TupleElementAddr)
186184
OPERAND_OWNERSHIP(TrivialUse, UncheckedAddrCast)

0 commit comments

Comments
 (0)