This commit is contained in:
Diego Novillo 2018-01-04 13:20:18 -05:00
parent 7834beea80
commit 5b52626eaa
2 changed files with 10 additions and 3 deletions

View File

@ -381,7 +381,12 @@ bool AggressiveDCEPass::AggressiveDCE(ir::Function* func) {
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);

View File

@ -30,8 +30,10 @@ namespace opt {
// 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 {