File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,9 @@ SILValue InstSimplifier::visitEnumInst(EnumInst *EI) {
292
292
}
293
293
294
294
SILValue InstSimplifier::visitAddressToPointerInst (AddressToPointerInst *ATPI) {
295
+ if (ATPI->getFunction ()->hasOwnership ()) {
296
+ return SILValue ();
297
+ }
295
298
// (address_to_pointer (pointer_to_address x [strict])) -> x
296
299
// The 'strict' flag is only relevant for instructions that access memory;
297
300
// the moment the address is cast back to a pointer, it no longer matters.
@@ -303,6 +306,9 @@ SILValue InstSimplifier::visitAddressToPointerInst(AddressToPointerInst *ATPI) {
303
306
}
304
307
305
308
SILValue InstSimplifier::visitPointerToAddressInst (PointerToAddressInst *PTAI) {
309
+ if (PTAI->getFunction ()->hasOwnership ()) {
310
+ return SILValue ();
311
+ }
306
312
// If this address is not strict, then it cannot be replaced by an address
307
313
// that may be strict.
308
314
if (auto *ATPI = dyn_cast<AddressToPointerInst>(PTAI->getOperand ()))
@@ -313,6 +319,10 @@ SILValue InstSimplifier::visitPointerToAddressInst(PointerToAddressInst *PTAI) {
313
319
}
314
320
315
321
SILValue InstSimplifier::visitRefToRawPointerInst (RefToRawPointerInst *RefToRaw) {
322
+ if (RefToRaw->getFunction ()->hasOwnership ()) {
323
+ return SILValue ();
324
+ }
325
+
316
326
// Perform the following simplification:
317
327
//
318
328
// (ref_to_raw_pointer (raw_pointer_to_ref x)) -> x
Original file line number Diff line number Diff line change @@ -333,16 +333,7 @@ visitPointerToAddressInst(PointerToAddressInst *PTAI) {
333
333
ATPI->getOperand (),
334
334
PTAI->getType ());
335
335
}
336
-
337
- OwnershipRAUWHelper helper (ownershipFixupContext, PTAI,
338
- ATPI->getOperand ());
339
- if (helper) {
340
- auto replacement = helper.prepareReplacement ();
341
- auto *newInst = Builder.createUncheckedAddrCast (
342
- PTAI->getLoc (), replacement, PTAI->getType ());
343
- helper.perform (newInst);
344
- return nullptr ;
345
- }
336
+ return nullptr ;
346
337
}
347
338
}
348
339
You can’t perform that action at this time.
0 commit comments