Skip to content

Commit 5d79c41

Browse files
committed
SIL: Remove unnecessary isObject() assertions from ValueBuffer instructions.
SILGen is used to passing in lowered types without getting their object types specifically, and the object type may not be a legal SIL type for address-only types. Fixes rdar://problem/21408736. Swift SVN r29436
1 parent 636e5a1 commit 5d79c41

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ class AllocValueBufferInst :
390390
AllocValueBufferInst(SILLocation loc, SILType valueType,
391391
SILValue operand)
392392
: UnaryInstructionBase(loc, operand, valueType.getAddressType()) {
393-
assert(valueType.isObject());
394393
}
395394

396395
SILType getValueType() const { return getType().getObjectType(); }
@@ -2981,7 +2980,6 @@ class DeallocValueBufferInst :
29812980
DeallocValueBufferInst(SILLocation loc, SILType valueType,
29822981
SILValue operand)
29832982
: UnaryInstructionBase(loc, operand), ValueType(valueType) {
2984-
assert(valueType.isObject());
29852983
}
29862984

29872985
SILType getValueType() const { return ValueType; }
@@ -3050,7 +3048,6 @@ class ProjectValueBufferInst :
30503048
ProjectValueBufferInst(SILLocation loc, SILType valueType,
30513049
SILValue operand)
30523050
: UnaryInstructionBase(loc, operand, valueType.getAddressType()) {
3053-
assert(valueType.isObject());
30543051
}
30553052

30563053
SILType getValueType() const { return getType().getObjectType(); }

test/SILGen/materializeForSet.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,16 @@ struct Bill : Totalled {
145145
// SILGEN: method #Totalled.total!setter.1: @_TTWV17materializeForSet4BillS_8TotalledS_FS1_s5totalSi
146146
// SILGEN: method #Totalled.total!materializeForSet.1: @_TTWV17materializeForSet4BillS_8TotalledS_FS1_m5totalSi
147147
// SILGEN: }
148+
149+
protocol AddressOnlySubscript {
150+
typealias Index
151+
subscript(i: Index) -> Index { get set }
152+
}
153+
154+
struct Foo<T>: AddressOnlySubscript {
155+
subscript(i: T) -> T {
156+
get { return i }
157+
set { print("\(i) = \(newValue)") }
158+
}
159+
}
160+

0 commit comments

Comments
 (0)