File tree Expand file tree Collapse file tree 2 files changed +505
-1
lines changed Expand file tree Collapse file tree 2 files changed +505
-1
lines changed Original file line number Diff line number Diff line change @@ -213,11 +213,26 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
213
213
return val;
214
214
}
215
215
216
+ // If this is a destructure_result, then we can return the element being
217
+ // extracted.
218
+ if (isa<DestructureStructResult>(value) ||
219
+ isa<DestructureTupleResult>(value)) {
220
+ auto *result = cast<MultipleValueInstructionResult>(value);
221
+ SILValue aggValue = result->getParent ()->getOperand (0 );
222
+ auto val = getConstantValue (aggValue);
223
+ if (val.isConstant ()) {
224
+ assert (val.getKind () == SymbolicValue::Aggregate);
225
+ return val.getAggregateValue ()[result->getIndex ()];
226
+ }
227
+ // Not a const.
228
+ return val;
229
+ }
230
+
216
231
// TODO: If this is a single element struct, we can avoid creating an
217
232
// aggregate to reduce # allocations. This is extra silly in the case of zero
218
233
// element tuples.
219
234
if (isa<StructInst>(value) || isa<TupleInst>(value)) {
220
- auto inst = cast<SingleValueInstruction>(value);
235
+ auto * inst = cast<SingleValueInstruction>(value);
221
236
SmallVector<SymbolicValue, 4 > elts;
222
237
223
238
for (unsigned i = 0 , e = inst->getNumOperands (); i != e; ++i) {
You can’t perform that action at this time.
0 commit comments