From 5fe789b4afb8d1e8067e3a91001399572cbd4db3 Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Sun, 17 Jan 2016 23:27:45 -0500 Subject: [PATCH] Add Block::successors. --- SPIRV/SpvBuilder.cpp | 2 +- SPIRV/spvIR.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 4d5ce419..29f48602 100755 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -857,7 +857,7 @@ void Builder::leaveFunction() if (! block->isTerminated()) { // Whether we're in an unreachable (non-entry) block. - bool unreachable = function.getEntryBlock() != block && block->getNumPredecessors() == 0; + bool unreachable = function.getEntryBlock() != block && block->getPredecessors().empty(); if (unreachable) { // Given that this block is at the end of a function, it must be right after an diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h index e763dbb9..38e51971 100755 --- a/SPIRV/spvIR.h +++ b/SPIRV/spvIR.h @@ -162,9 +162,10 @@ public: Function& getParent() const { return parent; } void addInstruction(std::unique_ptr inst); - void addPredecessor(Block* pred) { predecessors.push_back(pred); } + void addPredecessor(Block* pred) { predecessors.push_back(pred); pred->successors.push_back(this);} void addLocalVariable(std::unique_ptr inst) { localVariables.push_back(std::move(inst)); } - int getNumPredecessors() const { return (int)predecessors.size(); } + const std::vector getPredecessors() const { return predecessors; } + const std::vector getSuccessors() const { return successors; } void setUnreachable() { unreachable = true; } bool isUnreachable() const { return unreachable; } @@ -206,7 +207,7 @@ protected: friend Function; std::vector > instructions; - std::vector predecessors; + std::vector predecessors, successors; std::vector > localVariables; Function& parent;