Skip to content

Commit a1c32c2

Browse files
committed
[ConstExpr] Relax expectations in ArrayAppendElement to allow direct-passed element
1 parent db94dc7 commit a1c32c2

File tree

3 files changed

+758
-2
lines changed

3 files changed

+758
-2
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,14 @@ 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;
1017+
if (element.getKind() == SymbolicValue::Address) {
1018+
element = getConstAddrAndLoadResult(apply->getOperand(1));
1019+
} else {
1020+
element = getConstantValue(apply->getOperand(1));
1021+
}
10161022
if (!element.isConstant())
10171023
return element;
10181024

0 commit comments

Comments
 (0)