Fixes to build with LLVM top-of-tree
This commit is contained in:
18
ctx.cpp
18
ctx.cpp
@@ -765,8 +765,14 @@ FunctionEmitContext::EmitMalloc(LLVM_TYPE_CONST llvm::Type *ty, int align) {
|
|||||||
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(ty, 0);
|
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(ty, 0);
|
||||||
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
||||||
llvm::Value *index[1] = { LLVMInt32(1) };
|
llvm::Value *index[1] = { LLVMInt32(1) };
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
||||||
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
|
||||||
|
"offset_ptr", bblock);
|
||||||
|
#else
|
||||||
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[1],
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[1],
|
||||||
"offset_ptr", bblock);
|
"offset_ptr", bblock);
|
||||||
|
#endif
|
||||||
AddDebugPos(poffset);
|
AddDebugPos(poffset);
|
||||||
llvm::Value *sizeOf = PtrToIntInst(poffset, LLVMTypes::Int64Type, "offset_int");
|
llvm::Value *sizeOf = PtrToIntInst(poffset, LLVMTypes::Int64Type, "offset_int");
|
||||||
|
|
||||||
@@ -798,8 +804,13 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
|
|||||||
llvm::GlobalValue::InternalLinkage,
|
llvm::GlobalValue::InternalLinkage,
|
||||||
sConstant, s);
|
sConstant, s);
|
||||||
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
|
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
||||||
|
return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock);
|
||||||
|
#else
|
||||||
return llvm::GetElementPtrInst::Create(sPtr, &indices[0], &indices[2],
|
return llvm::GetElementPtrInst::Create(sPtr, &indices[0], &indices[2],
|
||||||
"sptr", bblock);
|
"sptr", bblock);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1289,9 +1300,16 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
|
|||||||
// The easy case: both the base pointer and the indices are
|
// The easy case: both the base pointer and the indices are
|
||||||
// uniform, so just emit the regular LLVM GEP instruction
|
// uniform, so just emit the regular LLVM GEP instruction
|
||||||
llvm::Value *indices[2] = { index0, index1 };
|
llvm::Value *indices[2] = { index0, index1 };
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
||||||
|
llvm::Instruction *inst =
|
||||||
|
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
||||||
|
name ? name : "gep", bblock);
|
||||||
|
#else
|
||||||
llvm::Instruction *inst =
|
llvm::Instruction *inst =
|
||||||
llvm::GetElementPtrInst::Create(basePtr, &indices[0], &indices[2],
|
llvm::GetElementPtrInst::Create(basePtr, &indices[0], &indices[2],
|
||||||
name ? name : "gep", bblock);
|
name ? name : "gep", bblock);
|
||||||
|
#endif
|
||||||
AddDebugPos(inst);
|
AddDebugPos(inst);
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|||||||
26
opt.cpp
26
opt.cpp
@@ -798,8 +798,14 @@ lSizeOf(LLVM_TYPE_CONST llvm::Type *type, llvm::Instruction *insertBefore) {
|
|||||||
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
|
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
|
||||||
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
||||||
llvm::Value *index[1] = { LLVMInt32(1) };
|
llvm::Value *index[1] = { LLVMInt32(1) };
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
||||||
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
|
||||||
|
"offset_ptr", insertBefore);
|
||||||
|
#else
|
||||||
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[1],
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[1],
|
||||||
"offset_ptr", insertBefore);
|
"offset_ptr", insertBefore);
|
||||||
|
#endif
|
||||||
lCopyMetadata(poffset, insertBefore);
|
lCopyMetadata(poffset, insertBefore);
|
||||||
llvm::Instruction *inst = new llvm::PtrToIntInst(poffset, LLVMTypes::Int64Type,
|
llvm::Instruction *inst = new llvm::PtrToIntInst(poffset, LLVMTypes::Int64Type,
|
||||||
"offset_int", insertBefore);
|
"offset_int", insertBefore);
|
||||||
@@ -822,8 +828,14 @@ lStructOffset(LLVM_TYPE_CONST llvm::Type *type, uint64_t member,
|
|||||||
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
|
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
|
||||||
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
|
||||||
llvm::Value *index[2] = { LLVMInt32(0), LLVMInt32((int32_t)member) };
|
llvm::Value *index[2] = { LLVMInt32(0), LLVMInt32((int32_t)member) };
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[2]);
|
||||||
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
|
||||||
|
"member_ptr", insertBefore);
|
||||||
|
#else
|
||||||
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[2],
|
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, &index[0], &index[2],
|
||||||
"member_ptr", insertBefore);
|
"member_ptr", insertBefore);
|
||||||
|
#endif
|
||||||
lCopyMetadata(poffset, insertBefore);
|
lCopyMetadata(poffset, insertBefore);
|
||||||
llvm::Instruction *inst = new llvm::PtrToIntInst(poffset, LLVMTypes::Int64Type,
|
llvm::Instruction *inst = new llvm::PtrToIntInst(poffset, LLVMTypes::Int64Type,
|
||||||
"member_int", insertBefore);
|
"member_int", insertBefore);
|
||||||
@@ -2122,9 +2134,15 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType,
|
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType,
|
||||||
"base2i8", callInst);
|
"base2i8", callInst);
|
||||||
lCopyMetadata(basei8, callInst);
|
lCopyMetadata(basei8, callInst);
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[1]);
|
||||||
|
llvm::Value *ptr =
|
||||||
|
llvm::GetElementPtrInst::Create(basei8, arrayRef, "ptr", callInst);
|
||||||
|
#else
|
||||||
llvm::Value *ptr =
|
llvm::Value *ptr =
|
||||||
llvm::GetElementPtrInst::Create(basei8, &indices[0], &indices[1],
|
llvm::GetElementPtrInst::Create(basei8, &indices[0], &indices[1],
|
||||||
"ptr", callInst);
|
"ptr", callInst);
|
||||||
|
#endif
|
||||||
lCopyMetadata(ptr, callInst);
|
lCopyMetadata(ptr, callInst);
|
||||||
|
|
||||||
if (gatherInfo != NULL) {
|
if (gatherInfo != NULL) {
|
||||||
@@ -2182,13 +2200,19 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
// and 64 bit gather/scatters, respectively.)
|
// and 64 bit gather/scatters, respectively.)
|
||||||
|
|
||||||
// Get the base pointer using the first guy's offset.
|
// Get the base pointer using the first guy's offset.
|
||||||
llvm::Value *indices[2] = { offsetElements[0] };
|
llvm::Value *indices[1] = { offsetElements[0] };
|
||||||
llvm::Value *basei8 =
|
llvm::Value *basei8 =
|
||||||
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType, "base2i8", callInst);
|
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType, "base2i8", callInst);
|
||||||
lCopyMetadata(basei8, callInst);
|
lCopyMetadata(basei8, callInst);
|
||||||
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[1]);
|
||||||
|
llvm::Value *ptr =
|
||||||
|
llvm::GetElementPtrInst::Create(basei8, arrayRef, "ptr", callInst);
|
||||||
|
#else
|
||||||
llvm::Value *ptr =
|
llvm::Value *ptr =
|
||||||
llvm::GetElementPtrInst::Create(basei8, &indices[0], &indices[1],
|
llvm::GetElementPtrInst::Create(basei8, &indices[0], &indices[1],
|
||||||
"ptr", callInst);
|
"ptr", callInst);
|
||||||
|
#endif
|
||||||
lCopyMetadata(ptr, callInst);
|
lCopyMetadata(ptr, callInst);
|
||||||
|
|
||||||
if (gatherInfo != NULL) {
|
if (gatherInfo != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user