mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ownership] Loosen restrictions around what we specialize and add generic specialization tests behind a flag.
The idea is that this will let me remove these assertions that were in place to make sure we were really conservative around specializing ownership code. For me to remove that I need to be able to actually test out this code (since I think there are some code paths where this will trigger in other parts of the compiler now). So to work out the kinks, I added a flag that allows for the generic specializer to process ownership code and translated most of the .sil test cases/fixed any bugs that I found. This hopefully will expose anything that is missing. NOTE: I have not enabled the generic specializer running in ownership in the pipeline. This is just a step in that direction by adding tests/etc.
This commit is contained in:
@@ -726,7 +726,8 @@ public:
|
||||
}
|
||||
|
||||
LoadBorrowInst *createLoadBorrow(SILLocation Loc, SILValue LV) {
|
||||
assert(isLoadableOrOpaque(LV->getType()));
|
||||
assert(isLoadableOrOpaque(LV->getType()) &&
|
||||
!LV->getType().isTrivial(getFunction()));
|
||||
return insert(new (getModule())
|
||||
LoadBorrowInst(getSILDebugLocation(Loc), LV));
|
||||
}
|
||||
@@ -737,11 +738,19 @@ public:
|
||||
BeginBorrowInst(getSILDebugLocation(Loc), LV));
|
||||
}
|
||||
|
||||
/// Convenience function for creating a load_borrow on non-trivial values and
|
||||
/// load [trivial] on trivial values. Becomes load unqualified in non-ossa
|
||||
/// functions.
|
||||
SILValue emitLoadBorrowOperation(SILLocation loc, SILValue v) {
|
||||
if (!hasOwnership()) {
|
||||
return emitLoadValueOperation(loc, v,
|
||||
LoadOwnershipQualifier::Unqualified);
|
||||
}
|
||||
|
||||
if (v->getType().isTrivial(getFunction())) {
|
||||
return emitLoadValueOperation(loc, v, LoadOwnershipQualifier::Trivial);
|
||||
}
|
||||
|
||||
return createLoadBorrow(loc, v);
|
||||
}
|
||||
|
||||
@@ -877,6 +886,33 @@ public:
|
||||
StoreBorrowInst(getSILDebugLocation(Loc), Src, DestAddr));
|
||||
}
|
||||
|
||||
/// A helper function for emitting store_borrow in operations where one must
|
||||
/// handle both ossa and non-ossa code.
|
||||
///
|
||||
/// In words:
|
||||
///
|
||||
/// * If the function does not have ownership, this just emits an unqualified
|
||||
/// store.
|
||||
///
|
||||
/// * If the function has ownership, but the type is trivial, use store
|
||||
/// [trivial].
|
||||
///
|
||||
/// * Otherwise, emit an actual store_borrow.
|
||||
void emitStoreBorrowOperation(SILLocation loc, SILValue src,
|
||||
SILValue destAddr) {
|
||||
if (!hasOwnership()) {
|
||||
return emitStoreValueOperation(loc, src, destAddr,
|
||||
StoreOwnershipQualifier::Unqualified);
|
||||
}
|
||||
|
||||
if (src->getType().isTrivial(getFunction())) {
|
||||
return emitStoreValueOperation(loc, src, destAddr,
|
||||
StoreOwnershipQualifier::Trivial);
|
||||
}
|
||||
|
||||
createStoreBorrow(loc, src, destAddr);
|
||||
}
|
||||
|
||||
MarkUninitializedInst *
|
||||
createMarkUninitialized(SILLocation Loc, SILValue src,
|
||||
MarkUninitializedInst::Kind k) {
|
||||
|
||||
Reference in New Issue
Block a user