Skip to content

Commit 17fbcb5

Browse files
committed
Swift SIL: fix SIL.Type.builtinVectorElementType
The element type must be lowered. Otherwise it would crash for e.g. function types as element types.
1 parent ff2341e commit 17fbcb5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extension Instruction {
387387
case let bi as BuiltinInst:
388388
switch bi.id {
389389
case .ZeroInitializer:
390-
let type = bi.type.isBuiltinVector ? bi.type.builtinVectorElementType : bi.type
390+
let type = bi.type.isBuiltinVector ? bi.type.builtinVectorElementType(in: parentFunction) : bi.type
391391
return type.isBuiltinInteger || type.isBuiltinFloat
392392
case .PtrToInt:
393393
return bi.operands[0].value is StringLiteralInst

SwiftCompilerSources/Sources/SIL/Type.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
8080
!isNoEscapeFunction && isEscapable(in: function)
8181
}
8282

83-
public var builtinVectorElementType: Type { canonicalType.builtinVectorElementType.silType! }
83+
public func builtinVectorElementType(in function: Function) -> Type {
84+
canonicalType.builtinVectorElementType.loweredType(in: function)
85+
}
8486

8587
public func builtinFixedArrayElementType(in function: Function, maximallyAbstracted: Bool = false) -> Type {
8688
canonicalType.builtinFixedArrayElementType.loweredType(in: function, maximallyAbstracted: maximallyAbstracted)

0 commit comments

Comments
 (0)