Fix SPIR-V code generation when unreachable code exists.
This will allow us to disable dead-code elimination and run performance tests. Change-Id: Ia98aa88e8db511e77ad2fb669af128f4510285ae Bug: skia:11361 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374316 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
3b31f68d2b
commit
7142e40534
@ -198,7 +198,7 @@ void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& ou
|
||||
case SpvOpSwitch: // fall through
|
||||
case SpvOpBranch: // fall through
|
||||
case SpvOpBranchConditional:
|
||||
SkASSERT(fCurrentBlock || !fContext.fConfig->fSettings.fDeadCodeElimination);
|
||||
SkASSERT(fCurrentBlock);
|
||||
fCurrentBlock = 0;
|
||||
break;
|
||||
case SpvOpConstant: // fall through
|
||||
@ -236,7 +236,18 @@ void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& ou
|
||||
case SpvOpMemberDecorate:
|
||||
break;
|
||||
default:
|
||||
SkASSERT(fCurrentBlock || !fContext.fConfig->fSettings.fDeadCodeElimination);
|
||||
if (!fProgram.fConfig->fSettings.fDeadCodeElimination) {
|
||||
// When dead-code elimination is disabled, we may find ourselves with instructions
|
||||
// that don't have an associated block. This should be a rare event, but if it
|
||||
// happens, synthesize a label; this is necessary to satisfy the validator.
|
||||
if (fCurrentBlock == 0) {
|
||||
this->writeLabel(this->nextId(), out);
|
||||
}
|
||||
} else {
|
||||
// When dead-code elimination is enabled, all code should be reachable and an
|
||||
// associated block should already exist.
|
||||
SkASSERT(fCurrentBlock);
|
||||
}
|
||||
}
|
||||
this->writeWord((length << 16) | opCode, out);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user