Fix several incorrect uses of ApplySite::getArgumentConvention.

At least most of these were latent bugs since the code was
unreachable in the PartialApply case. But that's no excuse to misuse
the API.

Also, whenever referring to an integer index, be explicit about
whether it is an applied argument or callee argument.
This commit is contained in:
Andrew Trick
2018-07-20 14:25:53 -07:00
parent 401be14483
commit 89ed064808
7 changed files with 19 additions and 39 deletions

View File

@@ -284,7 +284,7 @@ static bool partialApplyEscapes(SILValue V, bool examineApply) {
SILModuleConventions ModConv(*V->getModule());
llvm::SmallVector<Operand *, 32> Worklist(V->use_begin(), V->use_end());
while (!Worklist.empty()) {
auto *Op = Worklist.pop_back_val();
Operand *Op = Worklist.pop_back_val();
// These instructions do not cause the address to escape.
if (!useCaptured(Op))
@@ -300,15 +300,14 @@ static bool partialApplyEscapes(SILValue V, bool examineApply) {
continue;
}
if (auto *Apply = dyn_cast<ApplyInst>(User)) {
if (auto Apply = FullApplySite::isa(User)) {
// Applying a function does not cause the function to escape.
if (Op->getOperandNumber() == 0)
if (!Apply.isArgumentOperand(*Op))
continue;
// apply instructions do not capture the pointer when it is passed
// indirectly
if (Apply->getArgumentConvention(Op->getOperandNumber() - 1)
.isIndirectConvention())
if (Apply.getArgumentConvention(*Op).isIndirectConvention())
continue;
// Optionally drill down into an apply to see if the operand is