Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 8f3659f

Browse files
Drop emitBasicBlock
This extra function is unneeded and unnecessarily complexifies the emitted LLVM IR. Instead just emit each member of the block in sequence and return the last BB.
1 parent e5c6778 commit 8f3659f

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

tc/core/polyhedral/codegen_llvm.cc

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,11 @@ class LLVMCodegen {
403403
} else if (auto userNode = node.as<isl::ast_node_user>()) {
404404
return emitStmt(userNode);
405405
} else if (auto blockNode = node.as<isl::ast_node_block>()) {
406-
return emitBlock(blockNode);
406+
llvm::BasicBlock* curBB;
407+
for (auto child : blockNode.get_children()) {
408+
curBB = emitAst(child);
409+
}
410+
return curBB;
407411
} else {
408412
if (auto cond = node.as<isl::ast_node_if>()) {
409413
return emitIf(cond);
@@ -415,24 +419,6 @@ class LLVMCodegen {
415419
}
416420

417421
private:
418-
llvm::BasicBlock* emitBlock(isl::ast_node_block node) {
419-
auto* function = halide_cg.get_builder().GetInsertBlock()->getParent();
420-
auto* currBB = llvm::BasicBlock::Create(llvmCtx, "block_exit", function);
421-
halide_cg.get_builder().CreateBr(currBB);
422-
halide_cg.get_builder().SetInsertPoint(currBB);
423-
424-
for (auto child : node.get_children()) {
425-
currBB = emitAst(child);
426-
halide_cg.get_builder().SetInsertPoint(currBB);
427-
}
428-
429-
auto* exit = llvm::BasicBlock::Create(llvmCtx, "block_exit", function);
430-
halide_cg.get_builder().SetInsertPoint(currBB);
431-
halide_cg.get_builder().CreateBr(exit);
432-
halide_cg.get_builder().SetInsertPoint(exit);
433-
return exit;
434-
}
435-
436422
llvm::Type* makePtrToArrayType(
437423
llvm::Type* baseTy,
438424
const std::vector<int64_t>& sizes) {

0 commit comments

Comments
 (0)