Commit 59d8d400 by Yizhi Liu Committed by Zhi

[llvm] switch to use Align for llvm trunk (#4051)

parent 81118023
......@@ -71,7 +71,11 @@ class CodeGenAMDGPU : public CodeGenLLVM {
LLVMType(op->type), ConstInt32(constant_size));
});
if (alloca->getAlignment() < static_cast<uint32_t>(info.alignment)) {
#if TVM_LLVM_VERSION >= 100
alloca->setAlignment(llvm::Align(info.alignment));
#else
alloca->setAlignment(info.alignment);
#endif
}
buf = alloca;
} else {
......@@ -84,7 +88,11 @@ class CodeGenAMDGPU : public CodeGenLLVM {
llvm::GlobalVariable *global = new llvm::GlobalVariable(
*module_, type, false, llvm::GlobalValue::PrivateLinkage, 0, ".shared",
nullptr, llvm::GlobalValue::NotThreadLocal, shared_address_space);
#if TVM_LLVM_VERSION >= 100
global->setAlignment(llvm::Align(info.alignment));
#else
global->setAlignment(info.alignment);
#endif
buf = global;
}
}
......
......@@ -236,7 +236,11 @@ void CodeGenCPU::AddMainFunction(const std::string& entry_func_name) {
llvm::GlobalVariable *global = new llvm::GlobalVariable(
*module_, type, true, llvm::GlobalValue::WeakAnyLinkage, 0,
runtime::symbol::tvm_module_main);
#if TVM_LLVM_VERSION >= 100
global->setAlignment(llvm::Align(1));
#else
global->setAlignment(1);
#endif
global->setInitializer(llvm::ConstantDataArray::getString(*ctx_, entry_func_name));
}
......@@ -350,7 +354,11 @@ llvm::GlobalVariable* CodeGenCPU::InitContextPtr(
*module_, p_type, false,
llvm::GlobalValue::LinkOnceAnyLinkage, 0,
name);
#if TVM_LLVM_VERSION >= 100
gv->setAlignment(llvm::Align(data_layout_->getTypeAllocSize(p_type)));
#else
gv->setAlignment(data_layout_->getTypeAllocSize(p_type));
#endif
gv->setInitializer(llvm::Constant::getNullValue(p_type));
gv->setDLLStorageClass(llvm::GlobalValue::DLLStorageClassTypes::DLLExportStorageClass);
return gv;
......@@ -550,7 +558,11 @@ llvm::Value* CodeGenCPU::CreateStaticHandle() {
*module_, t_void_p_, false,
llvm::GlobalValue::PrivateLinkage, 0,
"__tvm_static_handle");
#if TVM_LLVM_VERSION >= 100
gv->setAlignment(llvm::Align(data_layout_->getTypeAllocSize(t_void_p_)));
#else
gv->setAlignment(data_layout_->getTypeAllocSize(t_void_p_));
#endif
gv->setInitializer(llvm::Constant::getNullValue(t_void_p_));
return gv;
}
......@@ -610,7 +622,11 @@ llvm::Value* CodeGenCPU::GetPackedFuncHandle(const std::string& fname) {
hptr = new llvm::GlobalVariable(
*module_, t_tvm_func_handle_, false,
llvm::GlobalValue::InternalLinkage, nullptr, ".tvm_func." + fname);
#if TVM_LLVM_VERSION >= 100
hptr->setAlignment(llvm::Align(align));
#else
hptr->setAlignment(align);
#endif
hptr->setInitializer(llvm::Constant::getNullValue(t_tvm_func_handle_));
func_handle_map_[fname] = hptr;
} else {
......
......@@ -595,7 +595,11 @@ llvm::Value* CodeGenLLVM::GetConstString(const std::string& str) {
llvm::Type* type = llvm::ArrayType::get(t_char_, str.length() + 1);
llvm::GlobalVariable *global = new llvm::GlobalVariable(
*module_, type, true, llvm::GlobalValue::PrivateLinkage, 0, ".str");
#if TVM_LLVM_VERSION >= 100
global->setAlignment(llvm::Align(1));
#else
global->setAlignment(1);
#endif
global->setInitializer(llvm::ConstantDataArray::getString(*ctx_, str));
llvm::Constant* zero = ConstInt32(0);
llvm::Constant* indices[] = {zero, zero};
......@@ -1150,7 +1154,11 @@ void CodeGenLLVM::VisitStmt_(const Allocate* op) {
LLVMType(op->type), ConstInt32(constant_size));
});
if (alloca->getAlignment() < static_cast<uint32_t>(info.alignment)) {
#if TVM_LLVM_VERSION >= 100
alloca->setAlignment(llvm::Align(info.alignment));
#else
alloca->setAlignment(info.alignment);
#endif
}
info.alignment = alloca->getAlignment();
buf = alloca;
......
......@@ -73,7 +73,11 @@ class CodeGenNVPTX : public CodeGenLLVM {
LLVMType(op->type), ConstInt32(constant_size));
});
if (alloca->getAlignment() < static_cast<uint32_t>(info.alignment)) {
#if TVM_LLVM_VERSION >= 100
alloca->setAlignment(llvm::Align(info.alignment));
#else
alloca->setAlignment(info.alignment);
#endif
}
buf = alloca;
} else {
......@@ -86,7 +90,11 @@ class CodeGenNVPTX : public CodeGenLLVM {
llvm::GlobalVariable *global = new llvm::GlobalVariable(
*module_, type, false, llvm::GlobalValue::PrivateLinkage, 0, ".shared",
nullptr, llvm::GlobalValue::NotThreadLocal, shared_address_space);
#if TVM_LLVM_VERSION >= 100
global->setAlignment(llvm::Align(info.alignment));
#else
global->setAlignment(info.alignment);
#endif
buf = global;
}
}
......
......@@ -55,6 +55,9 @@
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#include <llvm/Transforms/IPO.h>
#if TVM_LLVM_VERSION >= 100
#include <llvm/Support/Alignment.h>
#endif
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/raw_ostream.h>
......
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