Skip to content

Commit 96cac92

Browse files
committed
SILInstruction printing; check isDeleted()
before accessing the instruction's operands, which will crash.
1 parent 78dbe2b commit 96cac92

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
981981

982982
// Print results.
983983
auto results = I->getResults();
984-
if (results.size() == 1 &&
985-
I->isStaticInitializerInst() &&
986-
I == &I->getParent()->back()) {
984+
if (results.size() == 1 && !I->isDeleted() && I->isStaticInitializerInst()
985+
&& I == &I->getParent()->back()) {
987986
*this << "%initval = ";
988987
} else if (results.size() == 1) {
989988
ID Name = Ctx.getID(results[0]);
@@ -1011,7 +1010,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
10111010

10121011
// Maybe print debugging information.
10131012
bool printedSlashes = false;
1014-
if (Ctx.printDebugInfo() && !I->isStaticInitializerInst()) {
1013+
if (Ctx.printDebugInfo() && !I->isDeleted()
1014+
&& !I->isStaticInitializerInst()) {
10151015
auto &SM = I->getModule().getASTContext().SourceMgr;
10161016
printDebugLocRef(I->getLoc(), SM);
10171017
printDebugScopeRef(I->getDebugScope(), SM);
@@ -1439,6 +1439,9 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
14391439

14401440
void printForwardingOwnershipKind(OwnershipForwardingMixin *inst,
14411441
SILValue op) {
1442+
if (!op)
1443+
return;
1444+
14421445
if (inst->getForwardingOwnershipKind() != op.getOwnershipKind()) {
14431446
*this << ", forwarding: @" << inst->getForwardingOwnershipKind();
14441447
}

0 commit comments

Comments
 (0)