Commit b3f86e63 authored by Marius Wachtler's avatar Marius Wachtler

rename CFGBlock::getLastStmt to getTerminator

parent ee6cacaf
......@@ -741,7 +741,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// are disallowed
auto pred = block->predecessors[0];
auto last_inst = pred->getLastStmt();
auto last_inst = pred->getTerminator();
SymbolTable* sym_table = ending_symbol_tables[pred];
bool created_new_sym_table = false;
......@@ -823,7 +823,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm_exit_blocks[block] = ending_st.ending_block;
if (ending_st.exception_state.size()) {
BST_stmt* last_stmt = block->getLastStmt();
BST_stmt* last_stmt = block->getTerminator();
assert(last_stmt->is_invoke());
CFGBlock* exc_block = last_stmt->get_exc_block();
assert(!incoming_exception_state.count(exc_block));
......
......@@ -233,7 +233,7 @@ static int getLastLineno(llvm::ArrayRef<AST_stmt*> body, int default_lineno) {
llvm::SmallVector<CFGBlock*, 2> CFGBlock::successors() const {
llvm::SmallVector<CFGBlock*, 2> successors;
auto* last = getLastStmt();
auto* last = getTerminator();
if (last->type() == BST_TYPE::Jump) {
successors.push_back(bst_cast<BST_Jump>(last)->target);
} else if (last->type() == BST_TYPE::Branch) {
......@@ -3239,7 +3239,7 @@ static int pruneUnnecessaryBlocks(CFG* rtn) {
if (b2->predecessors.size() != 1)
continue;
auto last_stmt = b->getLastStmt();
auto last_stmt = b->getTerminator();
if (last_stmt->is_invoke()) {
// TODO probably shouldn't be generating these anyway:
assert(last_stmt->get_normal_block() == last_stmt->get_exc_block());
......@@ -3277,7 +3277,7 @@ static int pruneUnnecessaryBlocks(CFG* rtn) {
bool should_merge_blocks = blocks_to_merge.count(b);
if (should_merge_blocks) {
// copy first block without the terminator
block_size -= b->getLastStmt()->size_in_bytes();
block_size -= b->getTerminator()->size_in_bytes();
memcpy(final_bytecode.allocate(block_size), b->body(), block_size);
offset += block_size;
// copy second block and delete it
......@@ -3410,7 +3410,7 @@ static std::pair<CFG*, CodeConstants> computeCFG(llvm::ArrayRef<AST_stmt*> body,
ASSERT(b->body() != NULL, "%d", b->idx);
ASSERT(b->successors().size() <= 2, "%d has too many successors!", b->idx);
if (b->successors().size() == 0) {
BST_stmt* terminator = b->getLastStmt();
BST_stmt* terminator = b->getTerminator();
assert(terminator->type() == BST_TYPE::Return || terminator->type() == BST_TYPE::Raise
|| terminator->type() == BST_TYPE::Assert);
}
......
......@@ -102,7 +102,7 @@ public:
}
return size;
}
BST_stmt* getLastStmt() const {
BST_stmt* getTerminator() const {
// TODO: this is inefficient
for (BST_stmt* stmt : *this) {
if (stmt->is_terminator())
......
......@@ -75,7 +75,7 @@ TEST_F(AnalysisTest, augassign) {
for (CFGBlock* block : cfg->blocks) {
//printf("%d\n", block->idx);
if (block->getLastStmt()->type() != BST_TYPE::Return)
if (block->getTerminator()->type() != BST_TYPE::Return)
ASSERT_TRUE(liveness->isLiveAtEnd(vregs.getVReg(module->interned_strings->get("a")), block));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment