Skip to content

Commit 3c22407

Browse files
authored
Merge pull request #77471 from kubamracek/embedded-compeval2
[ConstExpr] Relax expectations in ArrayAppendElement to allow direct-passed element
2 parents f701309 + b197db8 commit 3c22407

File tree

3 files changed

+757
-2
lines changed

3 files changed

+757
-2
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 6 additions & 2 deletions
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)