Skip to content

Commit b197db8

Browse files
committed
[ConstExpr] Relax expectations in ArrayAppendElement to allow direct-passed element
1 parent 052cc2e commit b197db8

File tree

3 files changed

+757
-2
lines changed

3 files changed

+757
-2
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,12 @@ ConstExprFunctionState::computeWellKnownCallResult(ApplyInst *apply,
10111011
conventions.getNumDirectSILResults() == 0 &&
10121012
conventions.getNumIndirectSILResults() == 0 &&
10131013
"unexpected Array.append(_:) signature");
1014-
// Get the element to be appended which is passed indirectly (@in).
1015-
SymbolicValue element = getConstAddrAndLoadResult(apply->getOperand(1));
1014+
// Get the element to be appended which is usually passed indirectly (@in),
1015+
// or directly (in Embedded Swift where Array.append can be specialized).
1016+
SymbolicValue element = getConstantValue(apply->getOperand(1));
1017+
if (element.getKind() == SymbolicValue::Address) {
1018+
element = getConstAddrAndLoadResult(apply->getOperand(1));
1019+
}
10161020
if (!element.isConstant())
10171021
return element;
10181022

0 commit comments

Comments
 (0)