Skip to content

Two small SIL verifier improvements #34827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static llvm::cl::opt<bool> AbortOnFailure(
static llvm::cl::opt<bool> ContinueOnFailure("verify-continue-on-failure",
llvm::cl::init(false));

static llvm::cl::opt<bool> DumpModuleOnFailure("verify-dump-module-on-failure",
llvm::cl::init(false));

static llvm::cl::opt<bool> VerifyDIHoles(
"verify-di-holes",
llvm::cl::init(true));
Expand Down Expand Up @@ -712,8 +715,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {

llvm::dbgs() << "In function:\n";
F.print(llvm::dbgs());
llvm::dbgs() << "In module:\n";
F.getModule().print(llvm::dbgs());
if (DumpModuleOnFailure) {
// Don't do this by default because modules can be _very_ large.
llvm::dbgs() << "In module:\n";
F.getModule().print(llvm::dbgs());
}

// We abort by default because we want to always crash in
// the debugger.
Expand Down Expand Up @@ -1504,14 +1510,6 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
"cannot call coroutine with normal apply");
require(!calleeConv.funcTy->isAsync() || AI->getFunction()->isAsync(),
"cannot call an async function from a non async function");

// Check that if the apply is of a noreturn callee, make sure that an
// unreachable is the next instruction.
if (AI->getModule().getStage() == SILStage::Raw ||
!AI->isCalleeNoReturn())
return;
require(isa<UnreachableInst>(std::next(SILBasicBlock::iterator(AI))),
"No return apply without an unreachable as a next instruction.");
}

void checkTryApplyInst(TryApplyInst *AI) {
Expand Down