Skip to content

Commit b65cfed

Browse files
committed
---
yaml --- r: 319399 b: refs/heads/master-rebranch c: fef9eea h: refs/heads/master i: 319397: 540d38b 319395: a609752 319391: be1ea5e
1 parent 5e0c89c commit b65cfed

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 9e87e491c68a514f48741d9ba249f677ef83eace
1460+
refs/heads/master-rebranch: fef9eeab4a8f64f91ece7261fd3f4a629e2abd5b

branches/master-rebranch/lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
406406
if (auto *bai = dyn_cast<BeginAccessInst>(value))
407407
return getConstantValue(bai->getOperand());
408408

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+
409414
LLVM_DEBUG(llvm::dbgs() << "ConstExpr Unknown simple: " << *value << "\n");
410415

411416
// Otherwise, we don't know how to handle this.
@@ -1292,7 +1297,8 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
12921297
// skip them.
12931298
isa<DestroyAddrInst>(inst) || isa<RetainValueInst>(inst) ||
12941299
isa<ReleaseValueInst>(inst) || isa<StrongRetainInst>(inst) ||
1295-
isa<StrongReleaseInst>(inst))
1300+
isa<StrongReleaseInst>(inst) || isa<DestroyValueInst>(inst) ||
1301+
isa<EndBorrowInst>(inst))
12961302
return None;
12971303

12981304
// If this is a special flow-sensitive instruction like a stack allocation,
@@ -1302,6 +1308,15 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
13021308
return None;
13031309
}
13041310

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+
13051320
// If this is a deallocation of a memory object that we are tracking, then
13061321
// don't do anything. The memory is allocated in a BumpPtrAllocator so there
13071322
// is no useful way to free it.

0 commit comments

Comments
 (0)