[verifier] Make sure that applies of no-return functions have an unreachable as the next instruction.

This makes it easy to find no-return functions since one must iterate
through all BB with unreachable terminators and check the previous
instruction.

Swift SVN r25004
This commit is contained in:
Michael Gottesman
2015-02-05 19:11:33 +00:00
parent 41912c9523
commit 7acd7def16
4 changed files with 31 additions and 7 deletions

View File

@@ -74,6 +74,11 @@ static bool canApplyDecrementRefCount(ApplyInst *AI, SILValue Ptr,
if (FTy->getExtInfo().hasContext())
return true;
// Treat applications of @noreturn functions as decrementing ref counts. This
// causes the apply to become a sink barrier for ref count increments.
if (AI->getCallee().getType().getAs<SILFunctionType>()->isNoReturn())
return true;
// swift_keepAlive can not retain values. Remove this when we get rid of that.
if (auto *FRI = dyn_cast<FunctionRefInst>(AI->getCallee()))
if (isKnownToNotDecrementRefCount(FRI))