Add Block::successors.
This commit is contained in:
parent
60a7f3f7ae
commit
5fe789b4af
@ -857,7 +857,7 @@ void Builder::leaveFunction()
|
|||||||
if (! block->isTerminated()) {
|
if (! block->isTerminated()) {
|
||||||
|
|
||||||
// Whether we're in an unreachable (non-entry) block.
|
// 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) {
|
if (unreachable) {
|
||||||
// Given that this block is at the end of a function, it must be right after an
|
// Given that this block is at the end of a function, it must be right after an
|
||||||
|
|||||||
@ -162,9 +162,10 @@ public:
|
|||||||
|
|
||||||
Function& getParent() const { return parent; }
|
Function& getParent() const { return parent; }
|
||||||
void addInstruction(std::unique_ptr<Instruction> inst);
|
void addInstruction(std::unique_ptr<Instruction> 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<Instruction> inst) { localVariables.push_back(std::move(inst)); }
|
void addLocalVariable(std::unique_ptr<Instruction> inst) { localVariables.push_back(std::move(inst)); }
|
||||||
int getNumPredecessors() const { return (int)predecessors.size(); }
|
const std::vector<Block*> getPredecessors() const { return predecessors; }
|
||||||
|
const std::vector<Block*> getSuccessors() const { return successors; }
|
||||||
void setUnreachable() { unreachable = true; }
|
void setUnreachable() { unreachable = true; }
|
||||||
bool isUnreachable() const { return unreachable; }
|
bool isUnreachable() const { return unreachable; }
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ protected:
|
|||||||
friend Function;
|
friend Function;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Instruction> > instructions;
|
std::vector<std::unique_ptr<Instruction> > instructions;
|
||||||
std::vector<Block*> predecessors;
|
std::vector<Block*> predecessors, successors;
|
||||||
std::vector<std::unique_ptr<Instruction> > localVariables;
|
std::vector<std::unique_ptr<Instruction> > localVariables;
|
||||||
Function& parent;
|
Function& parent;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user