Skip to content

Commit 2fd4de4

Browse files
committed
[SIL-opaque] Removed [Unconditional]CheckedCastValue
1 parent 1c07c50 commit 2fd4de4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+24
-788
lines changed

include/swift/SIL/DynamicCasts.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,10 @@ struct SILDynamicCastInst {
187187
// checked_cast_value_br yet. Should we ever support it, please
188188
// review this code.
189189
case SILDynamicCastKind::CheckedCastBranchInst:
190-
case SILDynamicCastKind::CheckedCastValueBranchInst:
191-
return CastConsumptionKind::CopyOnSuccess;
192190
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
193191
return CastConsumptionKind::TakeAlways;
194192
case SILDynamicCastKind::UnconditionalCheckedCastInst:
195193
return CastConsumptionKind::CopyOnSuccess;
196-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
197-
llvm_unreachable("unsupported");
198194
}
199195
llvm_unreachable("covered switch");
200196
}
@@ -203,10 +199,8 @@ struct SILDynamicCastInst {
203199
switch (getKind()) {
204200
case SILDynamicCastKind::CheckedCastAddrBranchInst:
205201
case SILDynamicCastKind::CheckedCastBranchInst:
206-
case SILDynamicCastKind::CheckedCastValueBranchInst:
207202
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
208203
case SILDynamicCastKind::UnconditionalCheckedCastInst:
209-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
210204
llvm_unreachable("unsupported");
211205
}
212206
}
@@ -217,13 +211,9 @@ struct SILDynamicCastInst {
217211
return cast<CheckedCastAddrBranchInst>(inst)->getSuccessBB();
218212
case SILDynamicCastKind::CheckedCastBranchInst:
219213
return cast<CheckedCastBranchInst>(inst)->getSuccessBB();
220-
case SILDynamicCastKind::CheckedCastValueBranchInst:
221-
return cast<CheckedCastValueBranchInst>(inst)->getSuccessBB();
222214
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
223215
case SILDynamicCastKind::UnconditionalCheckedCastInst:
224216
return nullptr;
225-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
226-
llvm_unreachable("unsupported");
227217
}
228218
llvm_unreachable("covered switch");
229219
}
@@ -234,13 +224,9 @@ struct SILDynamicCastInst {
234224
llvm_unreachable("unsupported");
235225
case SILDynamicCastKind::CheckedCastBranchInst:
236226
return cast<CheckedCastBranchInst>(inst)->getTrueBBCount();
237-
case SILDynamicCastKind::CheckedCastValueBranchInst:
238-
llvm_unreachable("unsupported");
239227
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
240228
case SILDynamicCastKind::UnconditionalCheckedCastInst:
241229
return None;
242-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
243-
llvm_unreachable("unsupported");
244230
}
245231
llvm_unreachable("covered switch");
246232
}
@@ -255,13 +241,9 @@ struct SILDynamicCastInst {
255241
return cast<CheckedCastAddrBranchInst>(inst)->getFailureBB();
256242
case SILDynamicCastKind::CheckedCastBranchInst:
257243
return cast<CheckedCastBranchInst>(inst)->getFailureBB();
258-
case SILDynamicCastKind::CheckedCastValueBranchInst:
259-
return cast<CheckedCastValueBranchInst>(inst)->getFailureBB();
260244
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
261245
case SILDynamicCastKind::UnconditionalCheckedCastInst:
262246
return nullptr;
263-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
264-
llvm_unreachable("unsupported");
265247
}
266248
llvm_unreachable("covered switch");
267249
}
@@ -272,13 +254,9 @@ struct SILDynamicCastInst {
272254
llvm_unreachable("unsupported");
273255
case SILDynamicCastKind::CheckedCastBranchInst:
274256
return cast<CheckedCastBranchInst>(inst)->getFalseBBCount();
275-
case SILDynamicCastKind::CheckedCastValueBranchInst:
276-
llvm_unreachable("unsupported");
277257
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
278258
case SILDynamicCastKind::UnconditionalCheckedCastInst:
279259
return None;
280-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
281-
llvm_unreachable("unsupported");
282260
}
283261
llvm_unreachable("covered switch");
284262
}
@@ -293,14 +271,10 @@ struct SILDynamicCastInst {
293271
return cast<CheckedCastAddrBranchInst>(inst)->getSrc();
294272
case SILDynamicCastKind::CheckedCastBranchInst:
295273
return cast<CheckedCastBranchInst>(inst)->getOperand();
296-
case SILDynamicCastKind::CheckedCastValueBranchInst:
297-
return cast<CheckedCastValueBranchInst>(inst)->getOperand();
298274
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
299275
return cast<UnconditionalCheckedCastAddrInst>(inst)->getSrc();
300276
case SILDynamicCastKind::UnconditionalCheckedCastInst:
301277
return cast<UnconditionalCheckedCastInst>(inst)->getOperand();
302-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
303-
llvm_unreachable("unsupported");
304278
}
305279
llvm_unreachable("covered switch");
306280
}
@@ -311,7 +285,6 @@ struct SILDynamicCastInst {
311285
case SILDynamicCastKind::CheckedCastAddrBranchInst:
312286
return cast<CheckedCastAddrBranchInst>(inst)->getDest();
313287
case SILDynamicCastKind::CheckedCastBranchInst:
314-
case SILDynamicCastKind::CheckedCastValueBranchInst:
315288
// TODO: Shouldn't this return getSuccessBlock()->getArgument(0)?
316289
return SILValue();
317290
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
@@ -321,8 +294,6 @@ struct SILDynamicCastInst {
321294
//
322295
// return cast<UnconditionalCheckedCastInst>(inst);
323296
return SILValue();
324-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
325-
llvm_unreachable("unimplemented");
326297
}
327298
llvm_unreachable("covered switch");
328299
}
@@ -333,14 +304,10 @@ struct SILDynamicCastInst {
333304
return cast<CheckedCastAddrBranchInst>(inst)->getSourceFormalType();
334305
case SILDynamicCastKind::CheckedCastBranchInst:
335306
return cast<CheckedCastBranchInst>(inst)->getSourceFormalType();
336-
case SILDynamicCastKind::CheckedCastValueBranchInst:
337-
return cast<CheckedCastValueBranchInst>(inst)->getSourceFormalType();
338307
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
339308
return cast<UnconditionalCheckedCastAddrInst>(inst)->getSourceFormalType();
340309
case SILDynamicCastKind::UnconditionalCheckedCastInst:
341310
return cast<UnconditionalCheckedCastInst>(inst)->getSourceFormalType();
342-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
343-
return cast<UnconditionalCheckedCastValueInst>(inst)->getSourceFormalType();
344311
}
345312
llvm_unreachable("covered switch");
346313
}
@@ -351,14 +318,10 @@ struct SILDynamicCastInst {
351318
return cast<CheckedCastAddrBranchInst>(inst)->getSourceLoweredType();
352319
case SILDynamicCastKind::CheckedCastBranchInst:
353320
return cast<CheckedCastBranchInst>(inst)->getSourceLoweredType();
354-
case SILDynamicCastKind::CheckedCastValueBranchInst:
355-
return cast<CheckedCastValueBranchInst>(inst)->getSourceLoweredType();
356321
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
357322
return cast<UnconditionalCheckedCastAddrInst>(inst)->getSourceLoweredType();
358323
case SILDynamicCastKind::UnconditionalCheckedCastInst:
359324
return cast<UnconditionalCheckedCastInst>(inst)->getSourceLoweredType();
360-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
361-
return cast<UnconditionalCheckedCastValueInst>(inst)->getSourceLoweredType();
362325
}
363326
llvm_unreachable("covered switch");
364327
}
@@ -369,14 +332,10 @@ struct SILDynamicCastInst {
369332
return cast<CheckedCastAddrBranchInst>(inst)->getTargetFormalType();
370333
case SILDynamicCastKind::CheckedCastBranchInst:
371334
return cast<CheckedCastBranchInst>(inst)->getTargetFormalType();
372-
case SILDynamicCastKind::CheckedCastValueBranchInst:
373-
return cast<CheckedCastValueBranchInst>(inst)->getTargetFormalType();
374335
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
375336
return cast<UnconditionalCheckedCastAddrInst>(inst)->getTargetFormalType();
376337
case SILDynamicCastKind::UnconditionalCheckedCastInst:
377338
return cast<UnconditionalCheckedCastInst>(inst)->getTargetFormalType();
378-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
379-
return cast<UnconditionalCheckedCastValueInst>(inst)->getTargetFormalType();
380339
}
381340
llvm_unreachable("covered switch");
382341
}
@@ -387,28 +346,21 @@ struct SILDynamicCastInst {
387346
return cast<CheckedCastAddrBranchInst>(inst)->getDest()->getType();
388347
case SILDynamicCastKind::CheckedCastBranchInst:
389348
return cast<CheckedCastBranchInst>(inst)->getTargetLoweredType();
390-
case SILDynamicCastKind::CheckedCastValueBranchInst:
391-
return cast<CheckedCastValueBranchInst>(inst)->getTargetLoweredType();
392349
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
393350
return cast<UnconditionalCheckedCastAddrInst>(inst)->getDest()->getType();
394351
case SILDynamicCastKind::UnconditionalCheckedCastInst:
395352
return cast<UnconditionalCheckedCastInst>(inst)->getTargetLoweredType();
396-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
397-
return cast<UnconditionalCheckedCastValueInst>(inst)->getTargetLoweredType();
398353
}
399354
llvm_unreachable("covered switch");
400355
}
401356

402357
bool isSourceTypeExact() const {
403358
switch (getKind()) {
404-
case SILDynamicCastKind::CheckedCastValueBranchInst:
405359
case SILDynamicCastKind::CheckedCastBranchInst:
406360
case SILDynamicCastKind::CheckedCastAddrBranchInst:
407361
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
408362
case SILDynamicCastKind::UnconditionalCheckedCastInst:
409363
return isa<MetatypeInst>(getSource());
410-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
411-
llvm_unreachable("unsupported");
412364
}
413365
llvm_unreachable("covered switch");
414366
}
@@ -476,15 +428,9 @@ struct SILDynamicCastInst {
476428
auto f = classifyFeasibility(false /*allow wmo*/);
477429
return f == DynamicCastFeasibility::MaySucceed;
478430
}
479-
case SILDynamicCastKind::CheckedCastValueBranchInst: {
480-
auto f = classifyFeasibility(false /*allow wmo opts*/);
481-
return f == DynamicCastFeasibility::MaySucceed;
482-
}
483431
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
484432
case SILDynamicCastKind::UnconditionalCheckedCastInst:
485433
return false;
486-
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
487-
llvm_unreachable("unsupported");
488434
}
489435
llvm_unreachable("covered switch");
490436
}

include/swift/SIL/SILBuilder.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,16 +1314,6 @@ class SILBuilder {
13141314
dest, targetFormalType, getFunction()));
13151315
}
13161316

1317-
UnconditionalCheckedCastValueInst *
1318-
createUnconditionalCheckedCastValue(SILLocation Loc,
1319-
SILValue op, CanType srcFormalTy,
1320-
SILType destLoweredTy,
1321-
CanType destFormalTy) {
1322-
return insert(UnconditionalCheckedCastValueInst::create(
1323-
getSILDebugLocation(Loc), op, srcFormalTy,
1324-
destLoweredTy, destFormalTy, getFunction()));
1325-
}
1326-
13271317
RetainValueInst *createRetainValue(SILLocation Loc, SILValue operand,
13281318
Atomicity atomicity) {
13291319
assert(!hasOwnership());
@@ -2324,18 +2314,6 @@ class SILBuilder {
23242314
ProfileCounter Target1Count = ProfileCounter(),
23252315
ProfileCounter Target2Count = ProfileCounter());
23262316

2327-
CheckedCastValueBranchInst *
2328-
createCheckedCastValueBranch(SILLocation Loc,
2329-
SILValue op, CanType srcFormalTy,
2330-
SILType destLoweredTy,
2331-
CanType destFormalTy,
2332-
SILBasicBlock *successBB,
2333-
SILBasicBlock *failureBB) {
2334-
return insertTerminator(CheckedCastValueBranchInst::create(
2335-
getSILDebugLocation(Loc), op, srcFormalTy,
2336-
destLoweredTy, destFormalTy, successBB, failureBB, getFunction()));
2337-
}
2338-
23392317
CheckedCastAddrBranchInst *
23402318
createCheckedCastAddrBranch(SILLocation Loc, CastConsumptionKind consumption,
23412319
SILValue src, CanType sourceFormalType,

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,24 +1706,6 @@ SILCloner<ImplClass>::visitUnconditionalCheckedCastAddrInst(
17061706
OpLoc, SrcValue, SrcType, DestValue, TargetType));
17071707
}
17081708

1709-
template <typename ImplClass>
1710-
void SILCloner<ImplClass>::visitUnconditionalCheckedCastValueInst(
1711-
UnconditionalCheckedCastValueInst *Inst) {
1712-
SILLocation OpLoc = getOpLocation(Inst->getLoc());
1713-
SILValue OpValue = getOpValue(Inst->getOperand());
1714-
CanType SrcFormalType = getOpASTType(Inst->getSourceFormalType());
1715-
SILType OpLoweredType = getOpType(Inst->getTargetLoweredType());
1716-
CanType OpFormalType = getOpASTType(Inst->getTargetFormalType());
1717-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1718-
recordClonedInstruction(
1719-
Inst,
1720-
getBuilder().createUnconditionalCheckedCastValue(OpLoc,
1721-
OpValue,
1722-
SrcFormalType,
1723-
OpLoweredType,
1724-
OpFormalType));
1725-
}
1726-
17271709
template <typename ImplClass>
17281710
void SILCloner<ImplClass>::visitRetainValueInst(RetainValueInst *Inst) {
17291711
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
@@ -2737,22 +2719,6 @@ SILCloner<ImplClass>::visitCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
27372719
Inst->getForwardingOwnershipKind(), TrueCount, FalseCount));
27382720
}
27392721

2740-
template <typename ImplClass>
2741-
void SILCloner<ImplClass>::visitCheckedCastValueBranchInst(
2742-
CheckedCastValueBranchInst *Inst) {
2743-
SILBasicBlock *OpSuccBB = getOpBasicBlock(Inst->getSuccessBB());
2744-
SILBasicBlock *OpFailBB = getOpBasicBlock(Inst->getFailureBB());
2745-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
2746-
recordClonedInstruction(
2747-
Inst, getBuilder().createCheckedCastValueBranch(
2748-
getOpLocation(Inst->getLoc()),
2749-
getOpValue(Inst->getOperand()),
2750-
getOpASTType(Inst->getSourceFormalType()),
2751-
getOpType(Inst->getTargetLoweredType()),
2752-
getOpASTType(Inst->getTargetFormalType()),
2753-
OpSuccBB, OpFailBB));
2754-
}
2755-
27562722
template<typename ImplClass>
27572723
void SILCloner<ImplClass>::visitCheckedCastAddrBranchInst(
27582724
CheckedCastAddrBranchInst *Inst) {

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5664,39 +5664,6 @@ class UnconditionalCheckedCastInst final
56645664
SILType getTargetLoweredType() const { return getType(); }
56655665
};
56665666

5667-
/// Perform an unconditional checked cast that aborts if the cast fails.
5668-
/// The result of the checked cast is left in the destination.
5669-
class UnconditionalCheckedCastValueInst final
5670-
: public UnaryInstructionWithTypeDependentOperandsBase<
5671-
SILInstructionKind::UnconditionalCheckedCastValueInst,
5672-
UnconditionalCheckedCastValueInst, ConversionInst> {
5673-
CanType SourceFormalTy;
5674-
CanType DestFormalTy;
5675-
friend SILBuilder;
5676-
5677-
UnconditionalCheckedCastValueInst(SILDebugLocation DebugLoc,
5678-
SILValue Operand, CanType SourceFormalTy,
5679-
ArrayRef<SILValue> TypeDependentOperands,
5680-
SILType DestLoweredTy, CanType DestFormalTy)
5681-
: UnaryInstructionWithTypeDependentOperandsBase(
5682-
DebugLoc, Operand, TypeDependentOperands,
5683-
DestLoweredTy),
5684-
SourceFormalTy(SourceFormalTy),
5685-
DestFormalTy(DestFormalTy) {}
5686-
5687-
static UnconditionalCheckedCastValueInst *
5688-
create(SILDebugLocation DebugLoc,
5689-
SILValue Operand, CanType SourceFormalTy,
5690-
SILType DestLoweredTy, CanType DestFormalTy, SILFunction &F);
5691-
5692-
public:
5693-
SILType getSourceLoweredType() const { return getOperand()->getType(); }
5694-
CanType getSourceFormalType() const { return SourceFormalTy; }
5695-
5696-
SILType getTargetLoweredType() const { return getType(); }
5697-
CanType getTargetFormalType() const { return DestFormalTy; }
5698-
};
5699-
57005667
/// StructInst - Represents a constructed loadable struct.
57015668
class StructInst final : public InstructionBaseWithTrailingOperands<
57025669
SILInstructionKind::StructInst, StructInst,
@@ -8132,7 +8099,6 @@ class TermInst : public NonValueInstruction {
81328099
case TermKind::SwitchEnumAddrInst:
81338100
case TermKind::DynamicMethodBranchInst:
81348101
case TermKind::CheckedCastAddrBranchInst:
8135-
case TermKind::CheckedCastValueBranchInst:
81368102
case TermKind::AwaitAsyncContinuationInst:
81378103
return false;
81388104
case TermKind::SwitchEnumInst:
@@ -9159,45 +9125,6 @@ class CheckedCastBranchInst final
91599125
CanType getTargetFormalType() const { return DestFormalTy; }
91609126
};
91619127

9162-
/// Perform a checked cast operation and branch on whether the cast succeeds.
9163-
/// The success branch destination block receives the cast result as a BB
9164-
/// argument.
9165-
class CheckedCastValueBranchInst final
9166-
: public UnaryInstructionWithTypeDependentOperandsBase<
9167-
SILInstructionKind::CheckedCastValueBranchInst,
9168-
CheckedCastValueBranchInst, CastBranchInstBase<TermInst>> {
9169-
friend SILBuilder;
9170-
9171-
CanType SourceFormalTy;
9172-
SILType DestLoweredTy;
9173-
CanType DestFormalTy;
9174-
9175-
CheckedCastValueBranchInst(SILDebugLocation DebugLoc, SILValue Operand,
9176-
CanType SourceFormalTy,
9177-
ArrayRef<SILValue> TypeDependentOperands,
9178-
SILType DestLoweredTy, CanType DestFormalTy,
9179-
SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB)
9180-
: UnaryInstructionWithTypeDependentOperandsBase(
9181-
DebugLoc, Operand, TypeDependentOperands, SuccessBB, FailureBB,
9182-
ProfileCounter(), ProfileCounter()),
9183-
SourceFormalTy(SourceFormalTy), DestLoweredTy(DestLoweredTy),
9184-
DestFormalTy(DestFormalTy) {}
9185-
9186-
static CheckedCastValueBranchInst *
9187-
create(SILDebugLocation DebugLoc,
9188-
SILValue Operand, CanType SourceFormalTy,
9189-
SILType DestLoweredTy, CanType DestFormalTy,
9190-
SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB,
9191-
SILFunction &F);
9192-
9193-
public:
9194-
SILType getSourceLoweredType() const { return getOperand()->getType(); }
9195-
CanType getSourceFormalType() const { return SourceFormalTy; }
9196-
9197-
SILType getTargetLoweredType() const { return DestLoweredTy; }
9198-
CanType getTargetFormalType() const { return DestFormalTy; }
9199-
};
9200-
92019128
/// Perform a checked cast operation and branch on whether the cast succeeds.
92029129
/// The result of the checked cast is left in the destination address.
92039130
class CheckedCastAddrBranchInst final

include/swift/SIL/SILNode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,13 @@ class alignas(8) SILNode :
375375
UIWTDOB_BITFIELD_EMPTY(UncheckedTrivialBitCastInst, ConversionInst);
376376
UIWTDOB_BITFIELD_EMPTY(UncheckedBitwiseCastInst, ConversionInst);
377377
UIWTDOB_BITFIELD_EMPTY(ThinToThickFunctionInst, ConversionInst);
378-
UIWTDOB_BITFIELD_EMPTY(UnconditionalCheckedCastValueInst, ConversionInst);
379378
UIWTDOB_BITFIELD_EMPTY(InitExistentialAddrInst, SingleValueInstruction);
380379
UIWTDOB_BITFIELD_EMPTY(InitExistentialValueInst, SingleValueInstruction);
381380
UIWTDOB_BITFIELD_EMPTY(InitExistentialRefInst, SingleValueInstruction);
382381
UIWTDOB_BITFIELD_EMPTY(InitExistentialMetatypeInst, SingleValueInstruction);
383382

384383
SWIFT_INLINE_BITFIELD_EMPTY(TermInst, SILInstruction);
385384
UIWTDOB_BITFIELD_EMPTY(CheckedCastBranchInst, SingleValueInstruction);
386-
UIWTDOB_BITFIELD_EMPTY(CheckedCastValueBranchInst, SingleValueInstruction);
387385

388386
// Ensure that BranchInst bitfield does not overflow.
389387
IBWTO_BITFIELD_EMPTY(BranchInst, TermInst);

0 commit comments

Comments
 (0)