for (auto bi = structuredOrder.begin(); bi != structuredOrder.end(); ++bi) {
for (auto ii = (*bi)->begin(); ii != (*bi)->end(); ++ii) {
if (IsLive(&*ii)) continue;
- if (ii->IsBranch() &&
+ // TODO(greg-lunarg
+ // https://github.com/KhronosGroup/SPIRV-Tools/issues/1021) This should be
+ // using ii->IsBranch(), but this code does not handle OpSwitch
+ // instructions yet.
+ if ((ii->opcode() == SpvOpBranch ||
+ ii->opcode() == SpvOpBranchConditional) &&
!IsStructuredIfOrLoopHeader(*bi, nullptr, nullptr, nullptr))
continue;
dead_insts_.insert(&*ii);
// Represents a CFG control edge.
struct Edge {
- explicit Edge(ir::BasicBlock* b1, ir::BasicBlock* b2)
- : source(b1), dest(b2) {}
+ Edge(ir::BasicBlock* b1, ir::BasicBlock* b2) : source(b1), dest(b2) {
+ assert(source && "CFG edges cannot have a null source block.");
+ assert(dest && "CFG edges cannot have a null destination block.");
+ }
ir::BasicBlock* source;
ir::BasicBlock* dest;
bool operator<(const Edge& o) const {