mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -152,12 +152,10 @@ static SILArgumentConvention getAddressArgConvention(ApplyInst *Apply,
|
||||
Operand *&Oper) {
|
||||
Oper = nullptr;
|
||||
auto Args = Apply->getArgumentOperands();
|
||||
llvm::Optional<unsigned> FoundArgIdx;
|
||||
for (auto ArgIdx : indices(Args)) {
|
||||
if (Args[ArgIdx].get() != Address)
|
||||
continue;
|
||||
|
||||
FoundArgIdx = ArgIdx;
|
||||
assert(!Oper && "Address can only be passed once as an indirection.");
|
||||
Oper = &Args[ArgIdx];
|
||||
#ifdef NDEBUG
|
||||
@@ -165,7 +163,7 @@ static SILArgumentConvention getAddressArgConvention(ApplyInst *Apply,
|
||||
#endif
|
||||
}
|
||||
assert(Oper && "Address value not passed as an argument to this call.");
|
||||
return Apply->getArgumentConvention(FoundArgIdx.getValue());
|
||||
return ApplySite(Apply).getArgumentConvention(*Oper);
|
||||
}
|
||||
|
||||
/// If the given instruction is a store, return the stored value.
|
||||
@@ -1633,10 +1631,10 @@ bool TempRValueOptPass::collectLoads(
|
||||
return false;
|
||||
|
||||
case SILInstructionKind::ApplyInst: {
|
||||
auto *AI = cast<ApplyInst>(user);
|
||||
auto Convention = AI->getArgumentConvention(userOp->getOperandNumber() - 1);
|
||||
ApplySite apply(user);
|
||||
auto Convention = apply.getArgumentConvention(*userOp);
|
||||
if (Convention.isGuaranteedConvention()) {
|
||||
loadInsts.insert(AI);
|
||||
loadInsts.insert(user);
|
||||
return true;
|
||||
}
|
||||
LLVM_DEBUG(llvm::dbgs() << " Temp consuming use may write/destroy "
|
||||
|
||||
Reference in New Issue
Block a user