Skip to content

Commit d0cd8ac

Browse files
committed
[ODL] Visit autorelease_value insts.
No update is needed for the values they produce. This pass should really be refactored not to crash on instructions that aren't explicitly listed or at least not to compile if not every instruction is listed. rdar://161371112
1 parent 715abbe commit d0cd8ac

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ struct SILMoveOnlyWrappedTypeEliminatorVisitor
208208
NO_UPDATE_NEEDED(AddressToPointer)
209209
NO_UPDATE_NEEDED(AllocBox)
210210
NO_UPDATE_NEEDED(AllocStack)
211+
NO_UPDATE_NEEDED(AutoreleaseValue)
211212
NO_UPDATE_NEEDED(BeginAccess)
212213
NO_UPDATE_NEEDED(Branch)
213214
NO_UPDATE_NEEDED(BridgeObjectToRef)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
// RUN: %target-swift-frontend \
4+
// RUN: %t/Library.swift \
5+
// RUN: -enable-experimental-feature Lifetimes \
6+
// RUN: -sil-verify-all \
7+
// RUN: -verify \
8+
// RUN: -emit-sil \
9+
// RUN: -import-objc-header %t/Header.h \
10+
// RUN: > /dev/null
11+
12+
// REQUIRES: objc_interop
13+
14+
// REQUIRES: swift_feature_Lifetimes
15+
16+
//--- Header.h
17+
18+
@import Foundation;
19+
20+
@interface Foo : NSObject
21+
@property (nonatomic, readwrite) NSInteger length;
22+
- (const unichar *)_fastCharacterContents NS_RETURNS_INNER_POINTER;
23+
@end
24+
25+
//--- Library.swift
26+
27+
extension Foo {
28+
var utf16Span: Span<UInt16>? {
29+
@_lifetime(borrow self)
30+
borrowing get {
31+
// FIXME: This error shouldn't be here.
32+
guard let ptr = self._fastCharacterContents() else { // expected-error{{copy of noncopyable typed value}}
33+
return nil
34+
}
35+
let length = self.length
36+
let buffer = UnsafeBufferPointer(start: ptr, count: length)
37+
let span = unsafe Span<UInt16>(_unsafeElements: buffer)
38+
return _overrideLifetime(span, borrowing: self)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)