mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sil] Add a new CastConsumptionKind called BorrowAlways.
This means that: 1. SILGenPattern always borrows the object before it emits a case. 2. Any cast with this cast has a +0 result. NOTE: That one can not use this with address types (so we assert if you pass this checked_cast_addr_br). NOTE: Once we have opaque values, checked_cast_br of a guaranteed value will lower to a copy + checked_cast_addr_br (assuming the operation is a consuming cast). To make sure this does not become a problem in terms of performance, we will need a pass that can transform SILGenPattern +0 cases to +1 cases. This is something that we have talked about in the past and I think it is reasonable to implement. This is an incremental commit towards fixing SILGenPattern for ownership. rdar://29791263
This commit is contained in:
@@ -85,6 +85,8 @@ static unsigned toStableCastConsumptionKind(CastConsumptionKind kind) {
|
||||
return SIL_CAST_CONSUMPTION_TAKE_ON_SUCCESS;
|
||||
case CastConsumptionKind::CopyOnSuccess:
|
||||
return SIL_CAST_CONSUMPTION_COPY_ON_SUCCESS;
|
||||
case CastConsumptionKind::BorrowAlways:
|
||||
return SIL_CAST_CONSUMPTION_BORROW_ALWAYS;
|
||||
}
|
||||
llvm_unreachable("bad cast consumption kind");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user