From a81c19892f62b5ede74e34ddcfb261edb14003cd Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Fri, 29 Nov 2024 03:15:04 +0000 Subject: [PATCH 1/6] Make compilable with LLVM-20 --- src/target/llvm/codegen_cpu.cc | 8 ++++++++ src/target/llvm/codegen_llvm.cc | 4 ++++ src/target/llvm/llvm_module.cc | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index b9e18bc4f8d2..c2fc6cbfaa37 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -731,7 +731,11 @@ void CodeGenCPU::CreateStaticInit(const std::string& init_fname, const Stmt& bod llvm::Value* CodeGenCPU::GetPackedFuncHandle(const std::string& fname) { // We will store the packed function handle in global space. // Initialize it during the first call. +#if TVM_LLVM_VERSION >= 200 + llvm::DataLayout layout = module_->getDataLayout(); +#else llvm::DataLayout layout(module_.get()); +#endif uint64_t align = layout.getTypeAllocSize(t_tvm_func_handle_); auto it = func_handle_map_.find(fname); @@ -1297,7 +1301,11 @@ void CodeGenCPU::DefineFunctionRegistry(Array func_names) { } llvm::ArrayType* t_tvm_crt_func_ptrs = llvm::ArrayType::get(ftype_tvm_backend_packed_c_func_->getPointerTo(), funcs.size()); +#if TVM_LLVM_VERSION >= 200 + llvm::DataLayout layout = module_->getDataLayout(); +#else llvm::DataLayout layout(module_.get()); +#endif llvm::GlobalVariable* func_registry_ptrs = new llvm::GlobalVariable( *module_, t_tvm_crt_func_ptrs, true, llvm::GlobalValue::InternalLinkage, diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 3d6d3a9461d3..311ef0157cfa 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -169,7 +169,11 @@ void CodeGenLLVM::InitTarget() { llvm::TargetMachine* tm = llvm_target_->GetOrCreateTargetMachine(); module_->setTargetTriple(tm->getTargetTriple().str()); module_->setDataLayout(tm->createDataLayout()); +#if TVM_LLVM_VERSION >= 200 + data_layout_ = std::make_unique(module_->getDataLayout()); +#else data_layout_.reset(new llvm::DataLayout(module_.get())); +#endif if (native_vector_bits_ == 0) { const auto& arch = tm->getTargetTriple().getArch(); if (arch == llvm::Triple::x86_64) { diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc index 98dbe139f1cd..0f026f39684c 100644 --- a/src/target/llvm/llvm_module.cc +++ b/src/target/llvm/llvm_module.cc @@ -652,7 +652,11 @@ TVM_REGISTER_GLOBAL("codegen.LLVMModuleCreate") TVM_REGISTER_GLOBAL("target.llvm_lookup_intrinsic_id") .set_body_typed([](std::string name) -> int64_t { +#if TVM_LLVM_VERSION >= 200 + return static_cast(llvm::Intrinsic::lookupIntrinsicID(name)); +#else return static_cast(llvm::Function::lookupIntrinsicID(name)); +#endif }); TVM_REGISTER_GLOBAL("target.llvm_get_intrinsic_name").set_body_typed([](int64_t id) -> String { From 5d643a91ffc67545f81f540d1c33b6765db477f8 Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Fri, 29 Nov 2024 23:07:02 +0000 Subject: [PATCH 2/6] Resolving all deprecation warnings and addressing CR feedback --- src/target/llvm/codegen_amdgpu.cc | 12 ++++- src/target/llvm/codegen_blob.cc | 2 +- src/target/llvm/codegen_cpu.cc | 86 +++++++++++++++--------------- src/target/llvm/codegen_hexagon.cc | 35 ++++++++---- src/target/llvm/codegen_llvm.cc | 43 ++++++++++++--- src/target/llvm/codegen_nvptx.cc | 15 ++++-- src/target/llvm/codegen_x86_64.cc | 7 ++- src/target/llvm/llvm_instance.h | 7 +++ 8 files changed, 141 insertions(+), 66 deletions(-) diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc index fafe718feee5..73aa5f075b1b 100644 --- a/src/target/llvm/codegen_amdgpu.cc +++ b/src/target/llvm/codegen_amdgpu.cc @@ -147,7 +147,7 @@ class CodeGenAMDGPU : public CodeGenLLVM { } buf = builder_->CreatePointerCast( - buf, DTypeToLLVMType(op->dtype)->getPointerTo(buf->getType()->getPointerAddressSpace())); + buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); ICHECK(!var_map_.count(op->buffer_var.get())); var_map_[op->buffer_var.get()] = buf; this->VisitStmt(op->body); @@ -187,7 +187,12 @@ class CodeGenAMDGPU : public CodeGenLLVM { LOG(FATAL) << "unknown workgroup idx"; } } +#if TVM_LLVM_VERSION >= 200 + llvm::Function* f = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), intrin_id, {})); +#else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), intrin_id); +#endif llvm::Value* result = builder_->CreateCall(f, {}); return this->CreateCast(DataType::Int(32), iv->var->dtype, result); } @@ -197,8 +202,13 @@ class CodeGenAMDGPU : public CodeGenLLVM { if (sync == "warp") { return nullptr; } else if (sync == "shared") { +#if TVM_LLVM_VERSION >= 200 + llvm::Function* f = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), llvm::Intrinsic::amdgcn_s_barrier, {})); +#else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::amdgcn_s_barrier); +#endif return builder_->CreateCall(f, {}); } else { LOG(FATAL) << "Do not support sync " << sync; diff --git a/src/target/llvm/codegen_blob.cc b/src/target/llvm/codegen_blob.cc index b4fe93b518d8..343fdca3eec1 100644 --- a/src/target/llvm/codegen_blob.cc +++ b/src/target/llvm/codegen_blob.cc @@ -106,7 +106,7 @@ std::unique_ptr CodeGenBlob(const std::string& data, bool system_l auto void_ty = llvm::Type::getVoidTy(*ctx); auto int32_ty = llvm::Type::getInt32Ty(*ctx); auto int8_ty = llvm::Type::getInt8Ty(*ctx); - auto int8_ptr_ty = int8_ty->getPointerTo(0); + auto int8_ptr_ty = llvmGetPointerTo(int8_ty, 0); llvm::Constant* constant_zero = llvm::Constant::getNullValue(int32_ty); auto* tvm_dev_mblob_reg = diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index c2fc6cbfaa37..ede7ab34acac 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -97,29 +97,29 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // Defined in 3rdparty/dlpack/include/dlpack/dlpack.h: // typedef struct { ... } DLTensor; t_tvm_array_ = llvm::StructType::create({t_void_p_, t_tvm_device_, t_int_, t_tvm_type_, - t_tvm_shape_index_->getPointerTo(), - t_tvm_shape_index_->getPointerTo(), t_int64_}); + llvmGetPointerTo(t_tvm_shape_index_, 0), + llvmGetPointerTo(t_tvm_shape_index_, 0), t_int64_}); // Defined in include/tvm/runtime/c_runtime_api.h: // typedef union { ... } TVMValue; t_tvm_value_ = llvm::StructType::create({t_float64_}); // Defined in include/tvm/runtime/c_backend_api.h: // typedef struct { void* sync_handle; int32_t num_task; } TVMParallelGroupEnv; - t_tvm_parallel_group_env_ = llvm::StructType::create({t_int32_->getPointerTo(), t_int32_}); + t_tvm_parallel_group_env_ = llvm::StructType::create({llvmGetPointerTo(t_int32_, 0), t_int32_}); // Defined in include/tvm/runtime/c_backend_api.h: // typedef int (*TVMBackendPackedCFunc)(TVMValue* args, int* type_codes, int num_args, // TVMValue* out_ret_value, int* out_ret_tcode, // void* resource_handle); ftype_tvm_backend_packed_c_func_ = llvm::FunctionType::get( t_int_, - {t_void_p_, t_int_->getPointerTo(), t_int_, t_void_p_, t_int_->getPointerTo(), t_void_p_}, + {t_void_p_, llvmGetPointerTo(t_int_, 0), t_int_, t_void_p_, llvmGetPointerTo(t_int_, 0), t_void_p_}, false); t_tvm_crt_func_registry_ = llvm::StructType::create( - {t_char_->getPointerTo(), ftype_tvm_backend_packed_c_func_->getPointerTo()}); - t_tvm_crt_module_ = llvm::StructType::create({t_tvm_crt_func_registry_->getPointerTo()}); + {llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0)}); + t_tvm_crt_module_ = llvm::StructType::create({llvmGetPointerTo(t_tvm_crt_func_registry_, 0)}); // Defined in include/tvm/runtime/c_backend_api.h: // typedef int (*FTVMParallelLambda)(int task_id, TVMParallelGroupEnv* penv, void* cdata); ftype_tvm_parallel_lambda_ = llvm::FunctionType::get( - t_int_, {t_int_, t_tvm_parallel_group_env_->getPointerTo(), t_void_p_}, false); + t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0), t_void_p_}, false); md_tbaa_ctx_ptr_ = md_builder_->createTBAAScalarTypeNode("ctx_ptr", md_tbaa_root_); // Runtime functions. @@ -129,30 +129,30 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // TVMValue* ret_val, int* ret_type_code); ftype_tvm_func_call_ = llvm::FunctionType::get( t_int_, - {t_tvm_func_handle_, t_tvm_value_->getPointerTo(), t_int_->getPointerTo(), t_int_, - t_tvm_value_->getPointerTo(), t_int_->getPointerTo()}, + {t_tvm_func_handle_, llvmGetPointerTo(t_tvm_value_, 0), llvmGetPointerTo(t_int_, 0), t_int_, + llvmGetPointerTo(t_tvm_value_, 0), llvmGetPointerTo(t_int_, 0)}, false); // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendGetFuncFromEnv(void* mod_node, const char* func_name, TVMFunctionHandle* out); ftype_tvm_get_func_from_env_ = llvm::FunctionType::get( - t_int_, {t_void_p_, t_char_->getPointerTo(), t_tvm_func_handle_->getPointerTo()}, false); + t_int_, {t_void_p_, llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(t_tvm_func_handle_, 0)}, false); // Defined in include/tvm/runtime/c_runtime_api.h: // void TVMAPISetLastError(const char* msg); ftype_tvm_api_set_last_error_ = - llvm::FunctionType::get(t_void_, {t_char_->getPointerTo()}, false); + llvm::FunctionType::get(t_void_, {llvmGetPointerTo(t_char_, 0)}, false); // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendParallelLaunch(FTVMParallelLambda flambda, void* cdata, int num_task); ftype_tvm_parallel_launch_ = llvm::FunctionType::get( - t_int_, {ftype_tvm_parallel_lambda_->getPointerTo(), t_void_p_, t_int_}, false); + t_int_, {llvmGetPointerTo(ftype_tvm_parallel_lambda_, 0), t_void_p_, t_int_}, false); // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendParallelBarrier(int task_id, TVMParallelGroupEnv* penv); ftype_tvm_parallel_barrier_ = - llvm::FunctionType::get(t_int_, {t_int_, t_tvm_parallel_group_env_->getPointerTo()}, false); + llvm::FunctionType::get(t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0)}, false); ftype_tvm_static_init_callback_ = llvm::FunctionType::get(t_int_, {t_void_p_}, false); ftype_tvm_static_init_ = llvm::FunctionType::get(t_int_, - {t_void_p_->getPointerTo(), - ftype_tvm_static_init_callback_->getPointerTo(), t_void_p_, t_int_}, + {llvmGetPointerTo(t_void_p_, 0), + llvmGetPointerTo(ftype_tvm_static_init_callback_, 0), t_void_p_, t_int_}, false); // initialize TVM runtime API if (system_lib_prefix_.defined() && !target_c_runtime) { @@ -160,7 +160,7 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendRegisterSystemLibSymbol(const char* name, void* ptr); f_tvm_register_system_symbol_ = llvm::Function::Create( - llvm::FunctionType::get(t_int_, {t_char_->getPointerTo(), t_void_p_}, false), + llvm::FunctionType::get(t_int_, {llvmGetPointerTo(t_char_, 0), t_void_p_}, false), llvm::Function::ExternalLinkage, "TVMBackendRegisterSystemLibSymbol", module_.get()); } else { f_tvm_register_system_symbol_ = nullptr; @@ -276,9 +276,9 @@ CodeGenLLVM::TypedPointer CodeGenCPU::CreateStructRefPtr(DataType t, llvm::Value llvm::Value* index, int kind) { if (kind < builtin::kArrKindBound_) { if (buf->getType() == t_void_p_) { - buf = builder_->CreatePointerCast(buf, t_tvm_array_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_array_, 0)); } else { - ICHECK_EQ(buf->getType(), t_tvm_array_->getPointerTo()); + ICHECK_EQ(buf->getType(), llvmGetPointerTo(t_tvm_array_, 0)); } } switch (kind) { @@ -351,20 +351,20 @@ CodeGenLLVM::TypedPointer CodeGenCPU::CreateStructRefPtr(DataType t, llvm::Value // The stride between adjacent entries is still // `sizeof(TVMValue)==64`, even if the enum currently holds a // boolean. - buf = builder_->CreatePointerCast(buf, t_int64_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_int64_, 0)); buf = builder_->CreateInBoundsGEP(t_int64_, buf, index); - buf = builder_->CreatePointerCast(buf, DTypeToLLVMType(t)->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(DTypeToLLVMType(t), 0)); return TypedPointer(t_int8_, buf); } else if (t.is_int() && t.bits() == 64) { - buf = builder_->CreatePointerCast(buf, t_int64_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_int64_, 0)); return TypedPointer(t_int64_, builder_->CreateInBoundsGEP(t_int64_, buf, index)); } else if (t.is_float() && t.bits() == 64) { - buf = builder_->CreatePointerCast(buf, t_float64_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_float64_, 0)); return TypedPointer(t_float64_, builder_->CreateInBoundsGEP(t_float64_, buf, index)); } else if (t.is_handle()) { - buf = builder_->CreatePointerCast(buf, t_tvm_value_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, t_void_p_->getPointerTo())); + return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } else { LOG(DEBUG) << "DataType " << t << " cannot be stored into a TVMValue"; } @@ -390,7 +390,7 @@ llvm::Value* CodeGenCPU::CreateCallExtern(Type ret_type, String global_symbol, auto callee = [&]() -> llvm::Value* { if (auto it = gv_func_map_.find(global_symbol); it != gv_func_map_.end()) { if (it->second == nullptr) { - it->second = InitContextPtr(ftype->getPointerTo(), "__" + global_symbol); + it->second = InitContextPtr(llvmGetPointerTo(ftype, 0), "__" + global_symbol); } return GetContextPtr(it->second); } else if (llvm::Function* f = module_->getFunction(MakeStringRef(global_symbol))) { @@ -401,8 +401,8 @@ llvm::Value* CodeGenCPU::CreateCallExtern(Type ret_type, String global_symbol, } }(); - if (callee->getType() != ftype->getPointerTo()) { - callee = builder_->CreatePointerCast(callee, ftype->getPointerTo()); + if (callee->getType() != llvmGetPointerTo(ftype, 0)) { + callee = builder_->CreatePointerCast(callee, llvmGetPointerTo(ftype, 0)); } return builder_->CreateCall(ftype, callee, arg_values); } @@ -451,14 +451,14 @@ void CodeGenCPU::InitGlobalContext(bool dynamic_lookup) { export_system_symbols_.emplace_back(std::make_pair(ctx_symbol, gv_mod_ctx_)); } else { if (!dynamic_lookup) { - gv_tvm_func_call_ = InitContextPtr(ftype_tvm_func_call_->getPointerTo(), "__TVMFuncCall"); - gv_tvm_get_func_from_env_ = InitContextPtr(ftype_tvm_get_func_from_env_->getPointerTo(), + gv_tvm_func_call_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_func_call_, 0), "__TVMFuncCall"); + gv_tvm_get_func_from_env_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_get_func_from_env_, 0), "__TVMBackendGetFuncFromEnv"); gv_tvm_api_set_last_error_ = - InitContextPtr(ftype_tvm_api_set_last_error_->getPointerTo(), "__TVMAPISetLastError"); + InitContextPtr(llvmGetPointerTo(ftype_tvm_api_set_last_error_, 0), "__TVMAPISetLastError"); gv_tvm_parallel_launch_ = - InitContextPtr(ftype_tvm_parallel_launch_->getPointerTo(), "__TVMBackendParallelLaunch"); - gv_tvm_parallel_barrier_ = InitContextPtr(ftype_tvm_parallel_barrier_->getPointerTo(), + InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_launch_, 0), "__TVMBackendParallelLaunch"); + gv_tvm_parallel_barrier_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_barrier_, 0), "__TVMBackendParallelBarrier"); // Mark as context functions gv_func_map_["TVMBackendAllocWorkspace"] = nullptr; @@ -732,7 +732,7 @@ llvm::Value* CodeGenCPU::GetPackedFuncHandle(const std::string& fname) { // We will store the packed function handle in global space. // Initialize it during the first call. #if TVM_LLVM_VERSION >= 200 - llvm::DataLayout layout = module_->getDataLayout(); + llvm::DataLayout layout(module_.get()->getDataLayout()); #else llvm::DataLayout layout(module_.get()); #endif @@ -829,12 +829,12 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& llvm::Value* stack_value = MakeValue(args[1]); llvm::Value* stack_tcode = MakeValue(args[2]); llvm::Value* arg_value = builder_->CreateInBoundsGEP( - t_tvm_value_, builder_->CreatePointerCast(stack_value, t_tvm_value_->getPointerTo()), + t_tvm_value_, builder_->CreatePointerCast(stack_value, llvmGetPointerTo(t_tvm_value_, 0)), ConstInt32(begin)); TypedPointer arg_tcode = CreateBufferPtr(stack_tcode, DataType::Int(32), {ConstInt32(begin)}, DataType::Int(32)); llvm::Value* ret_value = builder_->CreateInBoundsGEP( - t_tvm_value_, builder_->CreatePointerCast(stack_value, t_tvm_value_->getPointerTo()), + t_tvm_value_, builder_->CreatePointerCast(stack_value, llvmGetPointerTo(t_tvm_value_, 0)), ConstInt32(end)); TypedPointer ret_tcode = CreateBufferPtr(stack_tcode, DataType::Int(32), {ConstInt32(end)}, DataType::Int(32)); @@ -886,7 +886,7 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& // Load the return value and cast it to the designated type (r_type). DataType r_api_type = tir::APIType(r_type); llvm::Type* llvm_r_api_type = DTypeToLLVMType(r_api_type); - llvm::Value* load_ptr = builder_->CreatePointerCast(ret_value, llvm_r_api_type->getPointerTo()); + llvm::Value* load_ptr = builder_->CreatePointerCast(ret_value, llvmGetPointerTo(llvm_r_api_type, 0)); #if TVM_LLVM_VERSION >= 110 llvm::Value* rvalue = builder_->CreateAlignedLoad(llvm_r_api_type, load_ptr, llvm::Align(8)); #elif TVM_LLVM_VERSION >= 80 @@ -1238,7 +1238,7 @@ void CodeGenCPU::DefineMetadata(runtime::metadata::Metadata metadata) { llvm::Type::getInt8Ty(*ctx) /* t_uint8 */, t_int64_ /* t_int64 */, llvm::Type::getInt8Ty(*ctx) /* t_bool */, - t_char_->getPointerTo() /* t_cstring */, + llvmGetPointerTo(t_char_, 0) /* t_cstring */, t_void_p_ /* t_void_p */, llvm::StructType::create(*ctx, {t_int8_, t_int8_, t_int8_}, "DLDataType") /* t_data_type */, }; @@ -1277,10 +1277,10 @@ void CodeGenCPU::DefineMetadata(runtime::metadata::Metadata metadata) { llvm::BasicBlock* entry_point_entry = llvm::BasicBlock::Create(*ctx, "entry", function_); builder_->SetInsertPoint(entry_point_entry); - auto ret_values_p = builder_->CreateBitCast(GetArg(function_, 3), t_void_p_->getPointerTo()); + auto ret_values_p = builder_->CreateBitCast(GetArg(function_, 3), llvmGetPointerTo(t_void_p_, 0)); builder_->CreateStore(builder_->CreateBitCast(metadata_constant_gv, t_void_p_), ret_values_p); - auto ret_tcode = builder_->CreateBitCast(GetArg(function_, 4), t_int_->getPointerTo()); + auto ret_tcode = builder_->CreateBitCast(GetArg(function_, 4), llvmGetPointerTo(t_int_, 0)); builder_->CreateStore(llvm::ConstantInt::get(t_int_, kTVMOpaqueHandle), ret_tcode); builder_->CreateRet(ConstInt32(0)); @@ -1300,9 +1300,9 @@ void CodeGenCPU::DefineFunctionRegistry(Array func_names) { funcs.emplace_back(sym_func); } llvm::ArrayType* t_tvm_crt_func_ptrs = - llvm::ArrayType::get(ftype_tvm_backend_packed_c_func_->getPointerTo(), funcs.size()); + llvm::ArrayType::get(llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0), funcs.size()); #if TVM_LLVM_VERSION >= 200 - llvm::DataLayout layout = module_->getDataLayout(); + llvm::DataLayout layout(module_.get()->getDataLayout()); #else llvm::DataLayout layout(module_.get()); #endif @@ -1311,7 +1311,7 @@ void CodeGenCPU::DefineFunctionRegistry(Array func_names) { *module_, t_tvm_crt_func_ptrs, true, llvm::GlobalValue::InternalLinkage, llvm::ConstantArray::get(t_tvm_crt_func_ptrs, funcs), "_tvm_func_registry_ptrs"); - uint64_t align = layout.getTypeAllocSize(ftype_tvm_backend_packed_c_func_->getPointerTo()); + uint64_t align = layout.getTypeAllocSize(llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0)); #if TVM_LLVM_VERSION >= 100 func_registry_ptrs->setAlignment(llvm::Align(align)); #else @@ -1323,7 +1323,7 @@ void CodeGenCPU::DefineFunctionRegistry(Array func_names) { t_tvm_crt_func_registry_, {GetConstString(::tvm::target::GenerateFuncRegistryNames(symbols)), llvm::ConstantExpr::getBitCast(func_registry_ptrs, - ftype_tvm_backend_packed_c_func_->getPointerTo())}), + llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0))}), "_tvm_crt_func_registry"); llvm::GlobalVariable* module = new llvm::GlobalVariable( *module_, t_tvm_crt_module_, true, llvm::GlobalValue::InternalLinkage, diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index 5113957aa127..ba64e6c642b8 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -211,7 +211,12 @@ llvm::Value* CodeGenHexagon::CreateIntrinsic(const CallNode* op) { op->op.same_as(builtin::end_profile_intrinsic())) { llvm::Value* id = MakeValue(op->args[0]); auto instrprof_id = llvm::Intrinsic::hexagon_instrprof_custom; +#if TVM_LLVM_VERSION >= 200 + llvm::Function* func = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), instrprof_id, {})); +#else llvm::Function* func = llvm::Intrinsic::getDeclaration(module_.get(), instrprof_id); +#endif llvm::GlobalVariable* name_var = module_->getGlobalVariable("handler_name"); if (!name_var) { llvm::StringRef init_str = "lwp_handler"; @@ -220,7 +225,7 @@ llvm::Value* CodeGenHexagon::CreateIntrinsic(const CallNode* op) { name_var = new llvm::GlobalVariable(*module_, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, "handler_name"); } - llvm::Type* t_int8_p_ = t_int8_->getPointerTo(); + llvm::Type* t_int8_p_ = llvmGetPointerTo(t_int8_, 0); return builder_->CreateCall(func, {llvm::ConstantExpr::getBitCast(name_var, t_int8_p_), id}); } #endif @@ -237,17 +242,22 @@ void CodeGenHexagon::CreatePrintf(const std::string& format, llvm::Function* func = module_->getFunction(func_name); if (func == nullptr) { llvm::FunctionType* ftype = llvm::FunctionType::get( - t_void_, {t_int32_, t_char_->getPointerTo(), t_int32_, t_char_->getPointerTo()}, true); + t_void_, {t_int32_, llvmGetPointerTo(t_char_, 0), t_int32_, llvmGetPointerTo(t_char_, 0)}, true); func = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, func_name, module_.get()); } + // There is no such filename/line number for this print statement +#if TVM_LLVM_VERSION >= 200 + llvm::Value* filename = builder_->CreateGlobalString("generated-LLVM-code", "dummy_filename"); + llvm::Value* format_str = builder_->CreateGlobalString(format, "printf_format_str"); +#else + llvm::Value* filename = builder_->CreateGlobalStringPtr("generated-LLVM-code", "dummy_filename"); llvm::Value* format_str = builder_->CreateGlobalStringPtr(format, "printf_format_str"); +#endif // The value of FARF_ALWAYS_LEVEL, defined as HAP_LEVEL_HIGH llvm::Value* level = ConstInt32(2); - // There is no such filename/line number for this print statement - llvm::Value* filename = builder_->CreateGlobalStringPtr("generated-LLVM-code", "dummy_filename"); llvm::Value* line_number = ConstInt32(1); std::vector func_args = {level, filename, line_number, format_str}; @@ -295,9 +305,9 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V if (kind < builtin::kArrKindBound_) { if (buf->getType() == t_void_p_) { - buf = builder_->CreatePointerCast(buf, t_tvm_array_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_array_, 0)); } else { - ICHECK_EQ(buf->getType(), t_tvm_array_->getPointerTo()); + ICHECK_EQ(buf->getType(), llvmGetPointerTo(t_tvm_array_, 0)); } /* The following "kinds" are accessing the members of DLTensor: typedef struct { @@ -350,16 +360,16 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V ICHECK_EQ(t.lanes(), 1); ICHECK(t.is_handle() || t.bits() == 64); if (t.is_int()) { - buf = builder_->CreatePointerCast(buf, t_int64_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_int64_, 0)); return TypedPointer(t_int64_, builder_->CreateInBoundsGEP(t_int64_, buf, index)); } else if (t.is_float()) { - buf = builder_->CreatePointerCast(buf, t_float64_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_float64_, 0)); return TypedPointer(t_float64_, builder_->CreateInBoundsGEP(t_float64_, buf, index)); } else { ICHECK(t.is_handle()); - buf = builder_->CreatePointerCast(buf, t_tvm_value_->getPointerTo()); + buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, t_void_p_->getPointerTo())); + return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } } @@ -369,7 +379,12 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V llvm::Value* CodeGenHexagon::Intrinsic(llvm::Intrinsic::ID IntID, llvm::ArrayRef args) { +#if TVM_LLVM_VERSION >= 200 + llvm::Function* intf = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), IntID, {})); +#else llvm::Function* intf = llvm::Intrinsic::getDeclaration(module_.get(), IntID); +#endif #if TVM_LLVM_VERSION >= 90 auto intf_callee = llvm::FunctionCallee(intf); #else diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 311ef0157cfa..25a8cb530887 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -148,7 +148,7 @@ void CodeGenLLVM::Init(const std::string& module_name, LLVMTarget* llvm_target, md_builder_.reset(new llvm::MDBuilder(*ctx)); // types t_void_ = llvm::Type::getVoidTy(*ctx); - t_void_p_ = llvm::Type::getInt8Ty(*ctx)->getPointerTo(GetGlobalAddressSpace()); + t_void_p_ = llvmGetPointerTo(llvm::Type::getInt8Ty(*ctx), GetGlobalAddressSpace()); t_int_ = llvm::Type::getInt32Ty(*ctx); t_char_ = llvm::Type::getInt8Ty(*ctx); t_int8_ = llvm::Type::getInt8Ty(*ctx); @@ -170,7 +170,7 @@ void CodeGenLLVM::InitTarget() { module_->setTargetTriple(tm->getTargetTriple().str()); module_->setDataLayout(tm->createDataLayout()); #if TVM_LLVM_VERSION >= 200 - data_layout_ = std::make_unique(module_->getDataLayout()); + data_layout_.reset(new llvm::DataLayout(module_.get()->getDataLayout())); #else data_layout_.reset(new llvm::DataLayout(module_.get())); #endif @@ -628,7 +628,7 @@ llvm::Type* CodeGenLLVM::GetLLVMType(const Type& type) const { } } // TODO(tvm-team) consider put storage scope into the pointer type. - return GetLLVMType(ptr->element_type)->getPointerTo(GetGlobalAddressSpace()); + return llvmGetPointerTo(GetLLVMType(ptr->element_type),GetGlobalAddressSpace()); } else if (IsVoidType(type)) { return t_void_; } else { @@ -971,9 +971,9 @@ CodeGenLLVM::TypedPointer CodeGenLLVM::CreateBufferPtr(llvm::Value* buffer_ptr, llvm::Type* element_type = DTypeToLLVMType(buffer_element_dtype); llvm::PointerType* element_ptr_type = - DTypeToLLVMType(buffer_element_dtype)->getPointerTo(address_space); + llvmGetPointerTo(DTypeToLLVMType(buffer_element_dtype), address_space); llvm::Type* value_type = DTypeToLLVMType(value_dtype); - llvm::PointerType* value_ptr_type = value_type->getPointerTo(address_space); + llvm::PointerType* value_ptr_type = llvmGetPointerTo(value_type, address_space); ICHECK(index->getType()->isIntegerTy()) << "Expected buffer index to be an integer"; @@ -1016,7 +1016,11 @@ void CodeGenLLVM::CreatePrintf(const std::string& format, llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, "fflush", module_.get()); } +#if TVM_LLVM_VERSION >= 200 + llvm::Value* str = builder_->CreateGlobalString(format); +#else llvm::Value* str = builder_->CreateGlobalStringPtr(format); +#endif str->setName("printf_format_str"); std::vector printf_args = {str}; @@ -1034,8 +1038,13 @@ void CodeGenLLVM::CreatePrintf(const std::string& format, llvm::Value* CodeGenLLVM::CreateLookupReturnAddress(unsigned int level) { EmitDebugLocation(); llvm::Value* level_val = llvm::ConstantInt::get(t_int32_, level); +#if TVM_LLVM_VERSION >= 200 + llvm::Function* builtin = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), llvm::Intrinsic::returnaddress, {})); +#else llvm::Function* builtin = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::returnaddress); +#endif llvm::Value* call = builder_->CreateCall(builtin, level_val); call->setName("return_addr"); @@ -1065,7 +1074,12 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type llvm::Module* module = module_.get(); if (!llvm::Intrinsic::isOverloaded(id)) { + #if TVM_LLVM_VERSION >= 200 + return llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module, id, {})); + #else return llvm::Intrinsic::getDeclaration(module, id, {}); + #endif } llvm::SmallVector infos; @@ -1093,7 +1107,12 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type // The return type doesn't match, there is nothing else to do. return nullptr; case llvm::Intrinsic::MatchIntrinsicTypes_Match: +#if TVM_LLVM_VERSION >= 200 + return llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module, id, overload_types)); +#else return llvm::Intrinsic::getDeclaration(module, id, overload_types); +#endif case llvm::Intrinsic::MatchIntrinsicTypes_NoMatchArg: break; } @@ -1105,7 +1124,12 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type if (i > 0) var_types.push_back(arg_types[i - 1]); auto* ft = llvm::FunctionType::get(ret_type, var_types, true); if (try_match(ft, true) == llvm::Intrinsic::MatchIntrinsicTypes_Match) { +#if TVM_LLVM_VERSION >= 200 + return llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module, id, overload_types)); +#else return llvm::Intrinsic::getDeclaration(module, id, overload_types); +#endif } } // Failed to identify the type. @@ -1122,7 +1146,12 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type return nullptr; } } +#if TVM_LLVM_VERSION >= 200 + return llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module, id, overload_types)); +#else return llvm::Intrinsic::getDeclaration(module, id, overload_types); +#endif #endif // TVM_LLVM_VERSION } @@ -1358,7 +1387,7 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* op) { if (param_type != arg_value[0]->getType()) { unsigned addrspace = llvm::dyn_cast(arg_value[0]->getType())->getAddressSpace(); - arg_value[0] = builder_->CreatePointerCast(arg_value[0], t_char_->getPointerTo(addrspace)); + arg_value[0] = builder_->CreatePointerCast(arg_value[0], llvmGetPointerTo(t_char_, addrspace)); } } @@ -2068,7 +2097,7 @@ void CodeGenLLVM::VisitStmt_(const AllocateNode* op) { buf = alloca; buf = builder_->CreatePointerCast( - buf, DTypeToLLVMType(op->dtype)->getPointerTo(buf->getType()->getPointerAddressSpace())); + buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); AddDebugInformation(buf, op->buffer_var); ICHECK(!var_map_.count(op->buffer_var.get())); diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc index b500958a8a53..9e4527dfbdf3 100644 --- a/src/target/llvm/codegen_nvptx.cc +++ b/src/target/llvm/codegen_nvptx.cc @@ -130,7 +130,7 @@ class CodeGenNVPTX : public CodeGenLLVM { } buf = builder_->CreatePointerCast( - buf, DTypeToLLVMType(op->dtype)->getPointerTo(buf->getType()->getPointerAddressSpace())); + buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); ICHECK(!var_map_.count(op->buffer_var.get())); var_map_[op->buffer_var.get()] = buf; this->VisitStmt(op->body); @@ -170,7 +170,12 @@ class CodeGenNVPTX : public CodeGenLLVM { LOG(FATAL) << "unknown thread idx"; } } +#if TVM_LLVM_VERSION >= 200 + llvm::Function* f = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), intrin_id, {})); +#else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), intrin_id); +#endif return builder_->CreateCall(f, {}); } @@ -180,8 +185,12 @@ class CodeGenNVPTX : public CodeGenLLVM { // TODO(tqchen) warp sync in CUDA9 return nullptr; } else if (sync == "shared" || sync == "shared.dyn") { - llvm::Function* f = - llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0); +#if TVM_LLVM_VERSION >= 200 + llvm::Function* f = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0, {})); +#else + llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0); +#endif return builder_->CreateCall(f, {}); } else { LOG(FATAL) << "Do not support sync " << sync; diff --git a/src/target/llvm/codegen_x86_64.cc b/src/target/llvm/codegen_x86_64.cc index 1872d64d71c5..3febcaa4a5fb 100644 --- a/src/target/llvm/codegen_x86_64.cc +++ b/src/target/llvm/codegen_x86_64.cc @@ -93,7 +93,12 @@ llvm::Value* CodeGenX86_64::VisitExpr_(const CastNode* op) { llvm::Value* CodeGenX86_64::CallVectorIntrin(llvm::Intrinsic::ID id, size_t intrin_lanes, llvm::Type* result_ty, const std::vector& args) { - llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), id, {}); +#if TVM_LLVM_VERSION >= 200 + llvm::Function* f = llvm::cast( + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), id, {})); +#else + llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), id); +#endif #if TVM_LLVM_VERSION >= 120 size_t num_elems = llvm::cast(result_ty)->getNumElements(); #else diff --git a/src/target/llvm/llvm_instance.h b/src/target/llvm/llvm_instance.h index 5cea99403a0b..a7711384d00c 100644 --- a/src/target/llvm/llvm_instance.h +++ b/src/target/llvm/llvm_instance.h @@ -44,6 +44,13 @@ #include #include +// LLVM compatibility macro +#if TVM_LLVM_VERSION >= 200 +#define llvmGetPointerTo(arg, offset) (llvm::PointerType::get((arg), (offset))) +#else +#define llvmGetPointerTo(arg, offset) (arg->getPointerTo(offset)) +#endif + namespace llvm { class LLVMContext; class MemoryBuffer; From db6da9c924c2ccc6a10a69c1a30a0f276dfb5d75 Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Sat, 30 Nov 2024 03:19:26 +0000 Subject: [PATCH 3/6] Removing trailing spaces --- src/target/llvm/codegen_llvm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 25a8cb530887..d6ffcbcec31e 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -1076,7 +1076,7 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type if (!llvm::Intrinsic::isOverloaded(id)) { #if TVM_LLVM_VERSION >= 200 return llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module, id, {})); + llvm::Intrinsic::getOrInsertDeclaration(module, id, {})); #else return llvm::Intrinsic::getDeclaration(module, id, {}); #endif From faeadd4227b0d37b200845c05a87e10bf4824ca3 Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Sat, 30 Nov 2024 18:55:46 +0000 Subject: [PATCH 4/6] Fixing linting errors --- src/target/llvm/codegen_amdgpu.cc | 6 ++++-- src/target/llvm/codegen_cpu.cc | 28 +++++++++++++++++++--------- src/target/llvm/codegen_hexagon.cc | 6 ++++-- src/target/llvm/codegen_llvm.cc | 5 +++-- src/target/llvm/codegen_nvptx.cc | 9 ++++++--- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc index 73aa5f075b1b..3c1f9502a279 100644 --- a/src/target/llvm/codegen_amdgpu.cc +++ b/src/target/llvm/codegen_amdgpu.cc @@ -147,7 +147,8 @@ class CodeGenAMDGPU : public CodeGenLLVM { } buf = builder_->CreatePointerCast( - buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); + buf, + llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); ICHECK(!var_map_.count(op->buffer_var.get())); var_map_[op->buffer_var.get()] = buf; this->VisitStmt(op->body); @@ -204,7 +205,8 @@ class CodeGenAMDGPU : public CodeGenLLVM { } else if (sync == "shared") { #if TVM_LLVM_VERSION >= 200 llvm::Function* f = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module_.get(), llvm::Intrinsic::amdgcn_s_barrier, {})); + llvm::Intrinsic::getOrInsertDeclaration( + module_.get(), llvm::Intrinsic::amdgcn_s_barrier, {})); #else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::amdgcn_s_barrier); diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index ede7ab34acac..8b46ab2dda89 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -111,7 +111,8 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // void* resource_handle); ftype_tvm_backend_packed_c_func_ = llvm::FunctionType::get( t_int_, - {t_void_p_, llvmGetPointerTo(t_int_, 0), t_int_, t_void_p_, llvmGetPointerTo(t_int_, 0), t_void_p_}, + {t_void_p_, llvmGetPointerTo(t_int_, 0), t_int_, + t_void_p_, llvmGetPointerTo(t_int_, 0), t_void_p_}, false); t_tvm_crt_func_registry_ = llvm::StructType::create( {llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0)}); @@ -135,7 +136,9 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendGetFuncFromEnv(void* mod_node, const char* func_name, TVMFunctionHandle* out); ftype_tvm_get_func_from_env_ = llvm::FunctionType::get( - t_int_, {t_void_p_, llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(t_tvm_func_handle_, 0)}, false); + t_int_, + {t_void_p_, llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(t_tvm_func_handle_, 0)}, + false); // Defined in include/tvm/runtime/c_runtime_api.h: // void TVMAPISetLastError(const char* msg); ftype_tvm_api_set_last_error_ = @@ -147,12 +150,14 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendParallelBarrier(int task_id, TVMParallelGroupEnv* penv); ftype_tvm_parallel_barrier_ = - llvm::FunctionType::get(t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0)}, false); + llvm::FunctionType::get( + t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0)}, false); ftype_tvm_static_init_callback_ = llvm::FunctionType::get(t_int_, {t_void_p_}, false); ftype_tvm_static_init_ = llvm::FunctionType::get(t_int_, {llvmGetPointerTo(t_void_p_, 0), - llvmGetPointerTo(ftype_tvm_static_init_callback_, 0), t_void_p_, t_int_}, + llvmGetPointerTo(ftype_tvm_static_init_callback_, 0), + t_void_p_, t_int_}, false); // initialize TVM runtime API if (system_lib_prefix_.defined() && !target_c_runtime) { @@ -364,7 +369,8 @@ CodeGenLLVM::TypedPointer CodeGenCPU::CreateStructRefPtr(DataType t, llvm::Value } else if (t.is_handle()) { buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); + return TypedPointer( + t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } else { LOG(DEBUG) << "DataType " << t << " cannot be stored into a TVMValue"; } @@ -451,13 +457,16 @@ void CodeGenCPU::InitGlobalContext(bool dynamic_lookup) { export_system_symbols_.emplace_back(std::make_pair(ctx_symbol, gv_mod_ctx_)); } else { if (!dynamic_lookup) { - gv_tvm_func_call_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_func_call_, 0), "__TVMFuncCall"); + gv_tvm_func_call_ = + InitContextPtr(llvmGetPointerTo(ftype_tvm_func_call_, 0), "__TVMFuncCall"); gv_tvm_get_func_from_env_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_get_func_from_env_, 0), "__TVMBackendGetFuncFromEnv"); gv_tvm_api_set_last_error_ = - InitContextPtr(llvmGetPointerTo(ftype_tvm_api_set_last_error_, 0), "__TVMAPISetLastError"); + InitContextPtr( + llvmGetPointerTo(ftype_tvm_api_set_last_error_, 0), "__TVMAPISetLastError"); gv_tvm_parallel_launch_ = - InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_launch_, 0), "__TVMBackendParallelLaunch"); + InitContextPtr( + llvmGetPointerTo(ftype_tvm_parallel_launch_, 0), "__TVMBackendParallelLaunch"); gv_tvm_parallel_barrier_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_barrier_, 0), "__TVMBackendParallelBarrier"); // Mark as context functions @@ -886,7 +895,8 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& // Load the return value and cast it to the designated type (r_type). DataType r_api_type = tir::APIType(r_type); llvm::Type* llvm_r_api_type = DTypeToLLVMType(r_api_type); - llvm::Value* load_ptr = builder_->CreatePointerCast(ret_value, llvmGetPointerTo(llvm_r_api_type, 0)); + llvm::Value* load_ptr = + builder_->CreatePointerCast(ret_value, llvmGetPointerTo(llvm_r_api_type, 0)); #if TVM_LLVM_VERSION >= 110 llvm::Value* rvalue = builder_->CreateAlignedLoad(llvm_r_api_type, load_ptr, llvm::Align(8)); #elif TVM_LLVM_VERSION >= 80 diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index ba64e6c642b8..41d213538325 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -242,7 +242,8 @@ void CodeGenHexagon::CreatePrintf(const std::string& format, llvm::Function* func = module_->getFunction(func_name); if (func == nullptr) { llvm::FunctionType* ftype = llvm::FunctionType::get( - t_void_, {t_int32_, llvmGetPointerTo(t_char_, 0), t_int32_, llvmGetPointerTo(t_char_, 0)}, true); + t_void_, {t_int32_, llvmGetPointerTo(t_char_, 0), + t_int32_, llvmGetPointerTo(t_char_, 0)}, true); func = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, func_name, module_.get()); } @@ -369,7 +370,8 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V ICHECK(t.is_handle()); buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer(t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); + return TypedPointer( + t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } } diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index d6ffcbcec31e..0a87cc32e6f1 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -628,7 +628,7 @@ llvm::Type* CodeGenLLVM::GetLLVMType(const Type& type) const { } } // TODO(tvm-team) consider put storage scope into the pointer type. - return llvmGetPointerTo(GetLLVMType(ptr->element_type),GetGlobalAddressSpace()); + return llvmGetPointerTo(GetLLVMType(ptr->element_type), GetGlobalAddressSpace()); } else if (IsVoidType(type)) { return t_void_; } else { @@ -1387,7 +1387,8 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* op) { if (param_type != arg_value[0]->getType()) { unsigned addrspace = llvm::dyn_cast(arg_value[0]->getType())->getAddressSpace(); - arg_value[0] = builder_->CreatePointerCast(arg_value[0], llvmGetPointerTo(t_char_, addrspace)); + arg_value[0] = + builder_->CreatePointerCast(arg_value[0], llvmGetPointerTo(t_char_, addrspace)); } } diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc index 9e4527dfbdf3..65a1ba1b9a9b 100644 --- a/src/target/llvm/codegen_nvptx.cc +++ b/src/target/llvm/codegen_nvptx.cc @@ -130,7 +130,8 @@ class CodeGenNVPTX : public CodeGenLLVM { } buf = builder_->CreatePointerCast( - buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); + buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), + buf->getType()->getPointerAddressSpace())); ICHECK(!var_map_.count(op->buffer_var.get())); var_map_[op->buffer_var.get()] = buf; this->VisitStmt(op->body); @@ -187,9 +188,11 @@ class CodeGenNVPTX : public CodeGenLLVM { } else if (sync == "shared" || sync == "shared.dyn") { #if TVM_LLVM_VERSION >= 200 llvm::Function* f = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0, {})); + llvm::Intrinsic::getOrInsertDeclaration(module_.get(), + llvm::Intrinsic::nvvm_barrier0, {})); #else - llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0); + llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), + llvm::Intrinsic::nvvm_barrier0); #endif return builder_->CreateCall(f, {}); } else { From 7ad703765676aaa467b016c4834b82423645c0cd Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Mon, 2 Dec 2024 00:25:24 +0000 Subject: [PATCH 5/6] Clang formatting --- src/target/llvm/codegen_amdgpu.cc | 5 ++- src/target/llvm/codegen_cpu.cc | 50 +++++++++++++----------------- src/target/llvm/codegen_hexagon.cc | 12 +++---- src/target/llvm/codegen_llvm.cc | 15 +++++---- src/target/llvm/codegen_nvptx.cc | 13 ++++---- src/target/llvm/codegen_x86_64.cc | 4 +-- 6 files changed, 45 insertions(+), 54 deletions(-) diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc index 3c1f9502a279..0dbbcc89a113 100644 --- a/src/target/llvm/codegen_amdgpu.cc +++ b/src/target/llvm/codegen_amdgpu.cc @@ -204,9 +204,8 @@ class CodeGenAMDGPU : public CodeGenLLVM { return nullptr; } else if (sync == "shared") { #if TVM_LLVM_VERSION >= 200 - llvm::Function* f = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration( - module_.get(), llvm::Intrinsic::amdgcn_s_barrier, {})); + llvm::Function* f = llvm::cast(llvm::Intrinsic::getOrInsertDeclaration( + module_.get(), llvm::Intrinsic::amdgcn_s_barrier, {})); #else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::amdgcn_s_barrier); diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index 8b46ab2dda89..816046a0a475 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -109,11 +109,11 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // typedef int (*TVMBackendPackedCFunc)(TVMValue* args, int* type_codes, int num_args, // TVMValue* out_ret_value, int* out_ret_tcode, // void* resource_handle); - ftype_tvm_backend_packed_c_func_ = llvm::FunctionType::get( - t_int_, - {t_void_p_, llvmGetPointerTo(t_int_, 0), t_int_, - t_void_p_, llvmGetPointerTo(t_int_, 0), t_void_p_}, - false); + ftype_tvm_backend_packed_c_func_ = + llvm::FunctionType::get(t_int_, + {t_void_p_, llvmGetPointerTo(t_int_, 0), t_int_, t_void_p_, + llvmGetPointerTo(t_int_, 0), t_void_p_}, + false); t_tvm_crt_func_registry_ = llvm::StructType::create( {llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(ftype_tvm_backend_packed_c_func_, 0)}); t_tvm_crt_module_ = llvm::StructType::create({llvmGetPointerTo(t_tvm_crt_func_registry_, 0)}); @@ -136,8 +136,7 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendGetFuncFromEnv(void* mod_node, const char* func_name, TVMFunctionHandle* out); ftype_tvm_get_func_from_env_ = llvm::FunctionType::get( - t_int_, - {t_void_p_, llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(t_tvm_func_handle_, 0)}, + t_int_, {t_void_p_, llvmGetPointerTo(t_char_, 0), llvmGetPointerTo(t_tvm_func_handle_, 0)}, false); // Defined in include/tvm/runtime/c_runtime_api.h: // void TVMAPISetLastError(const char* msg); @@ -149,16 +148,14 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, t_int_, {llvmGetPointerTo(ftype_tvm_parallel_lambda_, 0), t_void_p_, t_int_}, false); // Defined in include/tvm/runtime/c_backend_api.h: // int TVMBackendParallelBarrier(int task_id, TVMParallelGroupEnv* penv); - ftype_tvm_parallel_barrier_ = - llvm::FunctionType::get( - t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0)}, false); + ftype_tvm_parallel_barrier_ = llvm::FunctionType::get( + t_int_, {t_int_, llvmGetPointerTo(t_tvm_parallel_group_env_, 0)}, false); ftype_tvm_static_init_callback_ = llvm::FunctionType::get(t_int_, {t_void_p_}, false); - ftype_tvm_static_init_ = - llvm::FunctionType::get(t_int_, - {llvmGetPointerTo(t_void_p_, 0), - llvmGetPointerTo(ftype_tvm_static_init_callback_, 0), - t_void_p_, t_int_}, - false); + ftype_tvm_static_init_ = llvm::FunctionType::get( + t_int_, + {llvmGetPointerTo(t_void_p_, 0), llvmGetPointerTo(ftype_tvm_static_init_callback_, 0), + t_void_p_, t_int_}, + false); // initialize TVM runtime API if (system_lib_prefix_.defined() && !target_c_runtime) { // We will need this in environment for backward registration. @@ -369,8 +366,8 @@ CodeGenLLVM::TypedPointer CodeGenCPU::CreateStructRefPtr(DataType t, llvm::Value } else if (t.is_handle()) { buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer( - t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); + return TypedPointer(t_void_p_, + builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } else { LOG(DEBUG) << "DataType " << t << " cannot be stored into a TVMValue"; } @@ -458,15 +455,13 @@ void CodeGenCPU::InitGlobalContext(bool dynamic_lookup) { } else { if (!dynamic_lookup) { gv_tvm_func_call_ = - InitContextPtr(llvmGetPointerTo(ftype_tvm_func_call_, 0), "__TVMFuncCall"); + InitContextPtr(llvmGetPointerTo(ftype_tvm_func_call_, 0), "__TVMFuncCall"); gv_tvm_get_func_from_env_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_get_func_from_env_, 0), "__TVMBackendGetFuncFromEnv"); - gv_tvm_api_set_last_error_ = - InitContextPtr( - llvmGetPointerTo(ftype_tvm_api_set_last_error_, 0), "__TVMAPISetLastError"); - gv_tvm_parallel_launch_ = - InitContextPtr( - llvmGetPointerTo(ftype_tvm_parallel_launch_, 0), "__TVMBackendParallelLaunch"); + gv_tvm_api_set_last_error_ = InitContextPtr( + llvmGetPointerTo(ftype_tvm_api_set_last_error_, 0), "__TVMAPISetLastError"); + gv_tvm_parallel_launch_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_launch_, 0), + "__TVMBackendParallelLaunch"); gv_tvm_parallel_barrier_ = InitContextPtr(llvmGetPointerTo(ftype_tvm_parallel_barrier_, 0), "__TVMBackendParallelBarrier"); // Mark as context functions @@ -828,8 +823,7 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& std::string func_name = [&]() { auto ptr = args[0].as(); ICHECK(ptr) << "Expected first argument of tir::Call to be " - << "a string containing the callee's name, " - << "but instead contained " << args[0]; + << "a string containing the callee's name, " << "but instead contained " << args[0]; return ptr->value; }(); // call the function @@ -896,7 +890,7 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& DataType r_api_type = tir::APIType(r_type); llvm::Type* llvm_r_api_type = DTypeToLLVMType(r_api_type); llvm::Value* load_ptr = - builder_->CreatePointerCast(ret_value, llvmGetPointerTo(llvm_r_api_type, 0)); + builder_->CreatePointerCast(ret_value, llvmGetPointerTo(llvm_r_api_type, 0)); #if TVM_LLVM_VERSION >= 110 llvm::Value* rvalue = builder_->CreateAlignedLoad(llvm_r_api_type, load_ptr, llvm::Align(8)); #elif TVM_LLVM_VERSION >= 80 diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index 41d213538325..7d71c9e119a4 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -242,8 +242,8 @@ void CodeGenHexagon::CreatePrintf(const std::string& format, llvm::Function* func = module_->getFunction(func_name); if (func == nullptr) { llvm::FunctionType* ftype = llvm::FunctionType::get( - t_void_, {t_int32_, llvmGetPointerTo(t_char_, 0), - t_int32_, llvmGetPointerTo(t_char_, 0)}, true); + t_void_, {t_int32_, llvmGetPointerTo(t_char_, 0), t_int32_, llvmGetPointerTo(t_char_, 0)}, + true); func = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, func_name, module_.get()); } @@ -370,8 +370,8 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V ICHECK(t.is_handle()); buf = builder_->CreatePointerCast(buf, llvmGetPointerTo(t_tvm_value_, 0)); buf = builder_->CreateInBoundsGEP(t_tvm_value_, buf, index); - return TypedPointer( - t_void_p_, builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); + return TypedPointer(t_void_p_, + builder_->CreatePointerCast(buf, llvmGetPointerTo(t_void_p_, 0))); } } @@ -382,8 +382,8 @@ CodeGenLLVM::TypedPointer CodeGenHexagon::CreateStructRefPtr(DataType t, llvm::V llvm::Value* CodeGenHexagon::Intrinsic(llvm::Intrinsic::ID IntID, llvm::ArrayRef args) { #if TVM_LLVM_VERSION >= 200 - llvm::Function* intf = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module_.get(), IntID, {})); + llvm::Function* intf = + llvm::cast(llvm::Intrinsic::getOrInsertDeclaration(module_.get(), IntID, {})); #else llvm::Function* intf = llvm::Intrinsic::getDeclaration(module_.get(), IntID); #endif diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 0a87cc32e6f1..65f1d53e7827 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -1074,12 +1074,11 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type llvm::Module* module = module_.get(); if (!llvm::Intrinsic::isOverloaded(id)) { - #if TVM_LLVM_VERSION >= 200 - return llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module, id, {})); - #else +#if TVM_LLVM_VERSION >= 200 + return llvm::cast(llvm::Intrinsic::getOrInsertDeclaration(module, id, {})); +#else return llvm::Intrinsic::getDeclaration(module, id, {}); - #endif +#endif } llvm::SmallVector infos; @@ -1135,7 +1134,7 @@ llvm::Function* CodeGenLLVM::GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type // Failed to identify the type. return nullptr; -#else // TVM_LLVM_VERSION +#else // TVM_LLVM_VERSION llvm::ArrayRef ref(infos); // matchIntrinsicType returns true on error. if (llvm::Intrinsic::matchIntrinsicType(ret_type, ref, overload_types)) { @@ -1911,8 +1910,8 @@ llvm::Value* CodeGenLLVM::VisitExpr_(const ShuffleNode* op) { std::vector idx(op->indices.size()); for (int i = 0, e = op->indices.size(); i < e; ++i) { const int64_t* val = as_const_int(op->indices[i]); - ICHECK(val && *val >= 0 && *val < total_lanes) << "Shuffled indeces are suppose to be int, " - << "but get " << op->indices[i] << "\n"; + ICHECK(val && *val >= 0 && *val < total_lanes) + << "Shuffled indeces are suppose to be int, " << "but get " << op->indices[i] << "\n"; idx[i] = *val; } llvm::Value* mask = llvm::ConstantDataVector::get(builder_->getContext(), idx); diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc index 65a1ba1b9a9b..492248ea189d 100644 --- a/src/target/llvm/codegen_nvptx.cc +++ b/src/target/llvm/codegen_nvptx.cc @@ -130,8 +130,8 @@ class CodeGenNVPTX : public CodeGenLLVM { } buf = builder_->CreatePointerCast( - buf, llvmGetPointerTo(DTypeToLLVMType(op->dtype), - buf->getType()->getPointerAddressSpace())); + buf, + llvmGetPointerTo(DTypeToLLVMType(op->dtype), buf->getType()->getPointerAddressSpace())); ICHECK(!var_map_.count(op->buffer_var.get())); var_map_[op->buffer_var.get()] = buf; this->VisitStmt(op->body); @@ -187,12 +187,11 @@ class CodeGenNVPTX : public CodeGenLLVM { return nullptr; } else if (sync == "shared" || sync == "shared.dyn") { #if TVM_LLVM_VERSION >= 200 - llvm::Function* f = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module_.get(), - llvm::Intrinsic::nvvm_barrier0, {})); + llvm::Function* f = llvm::cast(llvm::Intrinsic::getOrInsertDeclaration( + module_.get(), llvm::Intrinsic::nvvm_barrier0, {})); #else - llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), - llvm::Intrinsic::nvvm_barrier0); + llvm::Function* f = + llvm::Intrinsic::getDeclaration(module_.get(), llvm::Intrinsic::nvvm_barrier0); #endif return builder_->CreateCall(f, {}); } else { diff --git a/src/target/llvm/codegen_x86_64.cc b/src/target/llvm/codegen_x86_64.cc index 3febcaa4a5fb..6329a77d7aee 100644 --- a/src/target/llvm/codegen_x86_64.cc +++ b/src/target/llvm/codegen_x86_64.cc @@ -94,8 +94,8 @@ llvm::Value* CodeGenX86_64::CallVectorIntrin(llvm::Intrinsic::ID id, size_t intr llvm::Type* result_ty, const std::vector& args) { #if TVM_LLVM_VERSION >= 200 - llvm::Function* f = llvm::cast( - llvm::Intrinsic::getOrInsertDeclaration(module_.get(), id, {})); + llvm::Function* f = + llvm::cast(llvm::Intrinsic::getOrInsertDeclaration(module_.get(), id, {})); #else llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), id); #endif From e7f7c9e59b013b1156af8e853fbc3e80f982503b Mon Sep 17 00:00:00 2001 From: Renat Idrisov Date: Mon, 2 Dec 2024 16:15:30 +0000 Subject: [PATCH 6/6] Clang formatting --- src/target/llvm/codegen_cpu.cc | 3 ++- src/target/llvm/codegen_llvm.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index 816046a0a475..8fdedeb78687 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -823,7 +823,8 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array& std::string func_name = [&]() { auto ptr = args[0].as(); ICHECK(ptr) << "Expected first argument of tir::Call to be " - << "a string containing the callee's name, " << "but instead contained " << args[0]; + << "a string containing the callee's name, " + << "but instead contained " << args[0]; return ptr->value; }(); // call the function diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 65f1d53e7827..55093ff8eea9 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -1910,8 +1910,8 @@ llvm::Value* CodeGenLLVM::VisitExpr_(const ShuffleNode* op) { std::vector idx(op->indices.size()); for (int i = 0, e = op->indices.size(); i < e; ++i) { const int64_t* val = as_const_int(op->indices[i]); - ICHECK(val && *val >= 0 && *val < total_lanes) - << "Shuffled indeces are suppose to be int, " << "but get " << op->indices[i] << "\n"; + ICHECK(val && *val >= 0 && *val < total_lanes) << "Shuffled indeces are suppose to be int, " + << "but get " << op->indices[i] << "\n"; idx[i] = *val; } llvm::Value* mask = llvm::ConstantDataVector::get(builder_->getContext(), idx);