mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
COWArrayOpts: fix a mis-compile related to owned function arguments
COWArrayOpts wrongly assumed that an 'owned' argument is released in the function. https://bugs.swift.org/browse/SR-12440 rdar://problem/62201043
This commit is contained in:
@@ -99,25 +99,6 @@ static bool isRelease(SILInstruction *Inst, SILValue RetainedValue,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto *AI = dyn_cast<ApplyInst>(Inst)) {
|
||||
if (auto *F = AI->getReferencedFunctionOrNull()) {
|
||||
auto Params = F->getLoweredFunctionType()->getParameters();
|
||||
auto Args = AI->getArguments();
|
||||
for (unsigned ArgIdx = 0, ArgEnd = Params.size(); ArgIdx != ArgEnd;
|
||||
++ArgIdx) {
|
||||
if (MatchedReleases.count(&AI->getArgumentRef(ArgIdx)))
|
||||
continue;
|
||||
if (!areArraysEqual(RCIA, Args[ArgIdx], RetainedValue, ArrayAddress))
|
||||
continue;
|
||||
ParameterConvention P = Params[ArgIdx].getConvention();
|
||||
if (P == ParameterConvention::Direct_Owned) {
|
||||
LLVM_DEBUG(llvm::dbgs() << " matching with release " << *Inst);
|
||||
MatchedReleases.insert(&AI->getArgumentRef(ArgIdx));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LLVM_DEBUG(llvm::dbgs() << " not a matching release " << *Inst);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user