SIL: Replace uses of getReferencedFunction() by getReferencedFunctionOrNull() and getInitialReferencedFunction()

With the advent of dynamic_function_ref the actual callee of such a ref
my vary. Optimizations should not assume to know the content of a
function referenced by dynamic_function_ref. Introduce
getReferencedFunctionOrNull which will return null for such function
refs. And getInitialReferencedFunction to return the referenced
function.
Use as appropriate.

rdar://50959798
This commit is contained in:
Arnold Schwaighofer
2019-05-25 09:09:53 -07:00
parent 036e74a6a6
commit c187c8ac13
56 changed files with 223 additions and 157 deletions

View File

@@ -309,7 +309,7 @@ static bool isRelease(SILInstruction *Inst, SILValue RetainedValue,
}
if (auto *AI = dyn_cast<ApplyInst>(Inst)) {
if (auto *F = AI->getReferencedFunction()) {
if (auto *F = AI->getReferencedFunctionOrNull()) {
auto Params = F->getLoweredFunctionType()->getParameters();
auto Args = AI->getArguments();
for (unsigned ArgIdx = 0, ArgEnd = Params.size(); ArgIdx != ArgEnd;