Skip to content

Commit 8364eca

Browse files
committed
SIL: Fix liveness check for the thrown error result
1 parent 5482bbf commit 8364eca

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ class SILFunctionArgument : public SILArgument {
433433

434434
bool isIndirectResult() const;
435435

436+
bool isIndirectErrorResult() const;
437+
436438
SILArgumentConvention getArgumentConvention() const;
437439

438440
/// Given that this is an entry block argument, and given that it does

lib/SIL/IR/SILArgument.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ bool SILFunctionArgument::isIndirectResult() const {
6464
return getIndex() < numIndirectResults;
6565
}
6666

67+
bool SILFunctionArgument::isIndirectErrorResult() const {
68+
auto numIndirectResults =
69+
getFunction()->getConventions().getNumIndirectSILResults();
70+
auto numIndirectErrorResults =
71+
getFunction()->getConventions().getNumIndirectSILErrorResults();
72+
return getIndex() < numIndirectResults + numIndirectErrorResults;
73+
}
74+
6775
SILArgumentConvention SILFunctionArgument::getArgumentConvention() const {
6876
return getFunction()->getConventions().getSILArgumentConvention(getIndex());
6977
}

lib/SIL/Verifier/MemoryLifetimeVerifier.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,12 @@ void MemoryLifetimeVerifier::checkFunction(BitDataflow &dataFlow) {
563563
locations.setBits(expectedThrowBits, funcArg);
564564
break;
565565
case SILArgumentConvention::Indirect_Out:
566-
locations.setBits(expectedReturnBits, funcArg);
566+
if (funcArg->isIndirectErrorResult()) {
567+
locations.setBits(expectedThrowBits, funcArg);
568+
} else {
569+
assert(funcArg->isIndirectResult());
570+
locations.setBits(expectedReturnBits, funcArg);
571+
}
567572
break;
568573
default:
569574
break;

0 commit comments

Comments
 (0)