Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 1, 2022
1 parent 0634e7d commit 097282a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions taichi/codegen/llvm/codegen_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ namespace taichi::lang {
// TODO(k-ye): Hide FunctionCreationGuard inside cpp file
FunctionCreationGuard::FunctionCreationGuard(
TaskCodeGenLLVM *mb,
std::vector<llvm::Type *> arguments, const std::string &func_name)
std::vector<llvm::Type *> arguments,
const std::string &func_name)
: mb(mb) {
// Create the loop body function
auto body_function_type = llvm::FunctionType::get(
llvm::Type::getVoidTy(*mb->llvm_context), arguments, false);

body = llvm::Function::Create(body_function_type,
llvm::Function::InternalLinkage,
func_name, mb->module.get());
llvm::Function::InternalLinkage, func_name,
mb->module.get());
old_func = mb->func;
// emit into loop body function
mb->func = body;
Expand Down Expand Up @@ -2668,7 +2669,8 @@ void TaskCodeGenLLVM::eliminate_unused_functions() {
}

FunctionCreationGuard TaskCodeGenLLVM::get_function_creation_guard(
std::vector<llvm::Type *> argument_types, const std::string &func_name) {
std::vector<llvm::Type *> argument_types,
const std::string &func_name) {
return FunctionCreationGuard(this, argument_types, func_name);
}

Expand Down Expand Up @@ -2804,7 +2806,8 @@ void TaskCodeGenLLVM::visit(ReferenceStmt *stmt) {
void TaskCodeGenLLVM::visit(FuncCallStmt *stmt) {
if (!func_map.count(stmt->func)) {
auto guard = get_function_creation_guard(
{llvm::PointerType::get(get_runtime_type("RuntimeContext"), 0)}, stmt->func->get_name());
{llvm::PointerType::get(get_runtime_type("RuntimeContext"), 0)},
stmt->func->get_name());
func_map.insert({stmt->func, guard.body});
stmt->func->ir->accept(this);
}
Expand Down
6 changes: 4 additions & 2 deletions taichi/codegen/llvm/codegen_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class FunctionCreationGuard {
llvm::IRBuilder<>::InsertPoint ip;

FunctionCreationGuard(TaskCodeGenLLVM *mb,
std::vector<llvm::Type *> arguments, const std::string &func_name);
std::vector<llvm::Type *> arguments,
const std::string &func_name);

~FunctionCreationGuard();
};
Expand Down Expand Up @@ -316,7 +317,8 @@ class TaskCodeGenLLVM : public IRVisitor, public LLVMModuleBuilder {
void finalize_offloaded_task_function();

FunctionCreationGuard get_function_creation_guard(
std::vector<llvm::Type *> argument_types, const std::string &func_name = "function_body");
std::vector<llvm::Type *> argument_types,
const std::string &func_name = "function_body");

std::tuple<llvm::Value *, llvm::Value *> get_range_for_bounds(
OffloadedStmt *stmt);
Expand Down

0 comments on commit 097282a

Please sign in to comment.