@@ -406,6 +406,11 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
406
406
if (auto *bai = dyn_cast<BeginAccessInst>(value))
407
407
return getConstantValue (bai->getOperand ());
408
408
409
+ // Look through copy_value and begin_borrow since the interpreter doesn't
410
+ // model these memory management instructions.
411
+ if (isa<CopyValueInst>(value) || isa<BeginBorrowInst>(value))
412
+ return getConstantValue (cast<SingleValueInstruction>(value)->getOperand (0 ));
413
+
409
414
LLVM_DEBUG (llvm::dbgs () << " ConstExpr Unknown simple: " << *value << " \n " );
410
415
411
416
// Otherwise, we don't know how to handle this.
@@ -1292,7 +1297,8 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
1292
1297
// skip them.
1293
1298
isa<DestroyAddrInst>(inst) || isa<RetainValueInst>(inst) ||
1294
1299
isa<ReleaseValueInst>(inst) || isa<StrongRetainInst>(inst) ||
1295
- isa<StrongReleaseInst>(inst))
1300
+ isa<StrongReleaseInst>(inst) || isa<DestroyValueInst>(inst) ||
1301
+ isa<EndBorrowInst>(inst))
1296
1302
return None;
1297
1303
1298
1304
// If this is a special flow-sensitive instruction like a stack allocation,
@@ -1302,6 +1308,15 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
1302
1308
return None;
1303
1309
}
1304
1310
1311
+ // Make sure that our copy_value, begin_borrow form constants. Otherwise,
1312
+ // return why.
1313
+ if (isa<CopyValueInst>(inst) || isa<BeginBorrowInst>(inst)) {
1314
+ auto result = getConstantValue (inst->getOperand (0 ));
1315
+ if (!result.isConstant ())
1316
+ return result;
1317
+ return None;
1318
+ }
1319
+
1305
1320
// If this is a deallocation of a memory object that we are tracking, then
1306
1321
// don't do anything. The memory is allocated in a BumpPtrAllocator so there
1307
1322
// is no useful way to free it.
0 commit comments