mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SimplifyBuiltin: support metatype and function types when optimizing Builtin.sizeof/alignof/strideof/destroyArray
Get the maximally abstracted lowered type instead of bailing if the ast type isn't equal to the lowered SIL type.
This commit is contained in:
@@ -33,9 +33,8 @@ extension BuiltinInst : OnoneSimplifyable {
|
||||
.Alignof:
|
||||
optimizeTargetTypeConst(context)
|
||||
case .DestroyArray:
|
||||
if let elementType = substitutionMap.replacementTypes[0].canonical.silType,
|
||||
elementType.isTrivial(in: parentFunction)
|
||||
{
|
||||
let elementType = substitutionMap.replacementType.loweredType(in: parentFunction, maximallyAbstracted: true)
|
||||
if elementType.isTrivial(in: parentFunction) {
|
||||
context.erase(instruction: self)
|
||||
return
|
||||
}
|
||||
@@ -161,10 +160,7 @@ private extension BuiltinInst {
|
||||
}
|
||||
|
||||
func optimizeTargetTypeConst(_ context: SimplifyContext) {
|
||||
guard let ty = substitutionMap.replacementTypes[0].canonical.silType else {
|
||||
return
|
||||
}
|
||||
|
||||
let ty = substitutionMap.replacementType.loweredType(in: parentFunction, maximallyAbstracted: true)
|
||||
let value: Int?
|
||||
switch id {
|
||||
case .Sizeof:
|
||||
|
||||
Reference in New Issue
Block a user