Update escape helpers with a few more cases.

No observable difference yet, but upcoming changes in the box-to-stack
promotion will require this change.

Swift SVN r15516
This commit is contained in:
Mark Lacey
2014-03-26 19:28:03 +00:00
parent cae8562ff7
commit 059a8bafcf

View File

@@ -215,7 +215,9 @@ static bool useCaptured(Operand *UI) {
// These instructions do not cause the address to escape.
if (isa<CopyAddrInst>(User) ||
isa<LoadInst>(User) ||
isa<ProtocolMethodInst>(User))
isa<ProtocolMethodInst>(User) ||
isa<DebugValueInst>(User) ||
isa<DebugValueAddrInst>(User))
return false;
if (auto *Store = dyn_cast<StoreInst>(User)) {
@@ -253,6 +255,10 @@ swift::canValueEscape(SILValue V) {
// apply instructions do not capture the pointer when it is passed
// indirectly
if (auto apply = dyn_cast<ApplyInst>(User)) {
// Applying a function does not cause the function to escape.
if (UI->getOperandNumber() == 0)
continue;
if (apply->getSubstCalleeType()
->getInterfaceParameters()[UI->getOperandNumber()-1].isIndirect()) {
continue;