Skip to content

Commit c343ab6

Browse files
committed
ArrayElementValuePropagation: fix a wrong substituted function type for the generated reserveCapacity function call
1 parent 2e6bdbc commit c343ab6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/SILOptimizer/Analysis/ArraySemantic.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ bool swift::ArraySemanticsCall::replaceByAppendingValues(
734734
Builder.createIntegerLiteral(Loc, BuiltinIntTy, Vals.size());
735735
StructInst *Capacity = Builder.createStruct(Loc,
736736
SILType::getPrimitiveObjectType(CanType(IntType)), {CapacityLiteral});
737-
Builder.createApply(Loc, ReserveFnRef, FnTy.substGenericArgs(M, Subs),
737+
Builder.createApply(Loc, ReserveFnRef,
738+
ReserveFnRef->getType().substGenericArgs(M, Subs),
738739
ReserveFnTy->getAllResultsType(), Subs,
739740
{Capacity, ArrRef}, false);
740741
}

test/SILOptimizer/array_contentof_opt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil %s | %FileCheck %s
22
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
33

44
// This is an end-to-end test of the array(contentsOf) -> array(Element) optimization

0 commit comments

Comments
 (0)