mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 00:20:40 +03:00
Fix LLVM 5.0 compilation.
This commit is contained in:
parent
3c297dcc06
commit
64df1687a8
8 changed files with 52 additions and 15 deletions
|
@ -67,11 +67,14 @@ AttrSet::AttrSet(const AttrSet &base, unsigned index, LLAttribute attribute)
|
||||||
AttrSet
|
AttrSet
|
||||||
AttrSet::extractFunctionAndReturnAttributes(const llvm::Function *function) {
|
AttrSet::extractFunctionAndReturnAttributes(const llvm::Function *function) {
|
||||||
auto old = function->getAttributes();
|
auto old = function->getAttributes();
|
||||||
LLAttributeSet existingAttrs[] = {old.getFnAttributes(),
|
#if LDC_LLVM_VER >= 500
|
||||||
old.getRetAttributes()};
|
return {LLAttributeSet::get(gIR->context(), old.getFnAttributes(),
|
||||||
AttrSet r(LLAttributeSet::get(gIR->context(), existingAttrs));
|
old.getRetAttributes(), {})};
|
||||||
|
#else
|
||||||
return r;
|
llvm::AttributeSet existingAttrs[] = {old.getFnAttributes(),
|
||||||
|
old.getRetAttributes()};
|
||||||
|
return {LLAttributeSet::get(gIR->context(), existingAttrs)};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrSet &AttrSet::add(unsigned index, const AttrBuilder &builder) {
|
AttrSet &AttrSet::add(unsigned index, const AttrBuilder &builder) {
|
||||||
|
|
|
@ -978,8 +978,12 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
||||||
// create alloca point
|
// create alloca point
|
||||||
// this gets erased when the function is complete, so alignment etc does not
|
// this gets erased when the function is complete, so alignment etc does not
|
||||||
// matter at all
|
// matter at all
|
||||||
llvm::Instruction *allocaPoint = new llvm::AllocaInst(
|
llvm::Instruction *allocaPoint =
|
||||||
LLType::getInt32Ty(gIR->context()), "alloca point", beginbb);
|
new llvm::AllocaInst(LLType::getInt32Ty(gIR->context()),
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
0, // Address space
|
||||||
|
#endif
|
||||||
|
"alloca point", beginbb);
|
||||||
funcGen.allocapoint = allocaPoint;
|
funcGen.allocapoint = allocaPoint;
|
||||||
|
|
||||||
// debug info - after all allocas, but before any llvm.dbg.declare etc
|
// debug info - after all allocas, but before any llvm.dbg.declare etc
|
||||||
|
|
|
@ -35,10 +35,18 @@ struct TempDisableDiscardValueNames {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Adds the idol's function attributes to the wannabe
|
/// Adds the idol's function attributes to the wannabe
|
||||||
|
/// Note: don't add function _parameter_ attributes
|
||||||
void copyFnAttributes(llvm::Function *wannabe, llvm::Function *idol) {
|
void copyFnAttributes(llvm::Function *wannabe, llvm::Function *idol) {
|
||||||
auto attrSet = idol->getAttributes();
|
auto attrSet = idol->getAttributes();
|
||||||
auto fnAttrSet = attrSet.getFnAttributes();
|
auto fnAttrSet = attrSet.getFnAttributes();
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
wannabe->addAttributes(LLAttributeSet::FunctionIndex,
|
||||||
|
LLAttributeSet::get(gIR->context(),
|
||||||
|
LLAttributeSet::FunctionIndex,
|
||||||
|
fnAttrSet));
|
||||||
|
#else
|
||||||
wannabe->addAttributes(LLAttributeSet::FunctionIndex, fnAttrSet);
|
wannabe->addAttributes(LLAttributeSet::FunctionIndex, fnAttrSet);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
|
@ -180,15 +180,24 @@ llvm::AllocaInst *DtoAlloca(VarDeclaration *vd, const char *name) {
|
||||||
llvm::AllocaInst *DtoArrayAlloca(Type *type, unsigned arraysize,
|
llvm::AllocaInst *DtoArrayAlloca(Type *type, unsigned arraysize,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
LLType *lltype = DtoType(type);
|
LLType *lltype = DtoType(type);
|
||||||
auto ai = new llvm::AllocaInst(lltype, DtoConstUint(arraysize), name,
|
auto ai = new llvm::AllocaInst(
|
||||||
gIR->topallocapoint());
|
lltype,
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
gIR->module.getDataLayout().getAllocaAddrSpace(),
|
||||||
|
#endif
|
||||||
|
DtoConstUint(arraysize), name, gIR->topallocapoint());
|
||||||
ai->setAlignment(DtoAlignment(type));
|
ai->setAlignment(DtoAlignment(type));
|
||||||
return ai;
|
return ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::AllocaInst *DtoRawAlloca(LLType *lltype, size_t alignment,
|
llvm::AllocaInst *DtoRawAlloca(LLType *lltype, size_t alignment,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
auto ai = new llvm::AllocaInst(lltype, name, gIR->topallocapoint());
|
auto ai =
|
||||||
|
new llvm::AllocaInst(lltype,
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
gIR->module.getDataLayout().getAllocaAddrSpace(),
|
||||||
|
#endif
|
||||||
|
name, gIR->topallocapoint());
|
||||||
if (alignment) {
|
if (alignment) {
|
||||||
ai->setAlignment(alignment);
|
ai->setAlignment(alignment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,16 @@ public:
|
||||||
virtual Value *promote(CallSite CS, IRBuilder<> &B, const Analysis &A) {
|
virtual Value *promote(CallSite CS, IRBuilder<> &B, const Analysis &A) {
|
||||||
NumGcToStack++;
|
NumGcToStack++;
|
||||||
|
|
||||||
Instruction *Begin = &(*CS.getCaller()->getEntryBlock().begin());
|
auto &BB = CS.getCaller()->getEntryBlock();
|
||||||
return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align?
|
Instruction *Begin = &(*BB.begin());
|
||||||
|
|
||||||
|
// FIXME: set alignment on alloca?
|
||||||
|
return new AllocaInst(
|
||||||
|
Ty,
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
BB.getModule()->getDataLayout().getAllocaAddrSpace(),
|
||||||
|
#endif
|
||||||
|
".nongc_mem", Begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit FunctionInfo(ReturnType::Type returnType) : ReturnType(returnType) {}
|
explicit FunctionInfo(ReturnType::Type returnType) : ReturnType(returnType) {}
|
||||||
|
|
|
@ -320,11 +320,13 @@ static void buildRuntimeModule() {
|
||||||
Attr_ReadOnly_1_NoCapture(Attr_ReadOnly, 1, llvm::Attribute::NoCapture),
|
Attr_ReadOnly_1_NoCapture(Attr_ReadOnly, 1, llvm::Attribute::NoCapture),
|
||||||
Attr_ReadOnly_1_3_NoCapture(Attr_ReadOnly_1_NoCapture, 3,
|
Attr_ReadOnly_1_3_NoCapture(Attr_ReadOnly_1_NoCapture, 3,
|
||||||
llvm::Attribute::NoCapture),
|
llvm::Attribute::NoCapture),
|
||||||
Attr_ReadOnly_NoUnwind_1_NoCapture(Attr_ReadOnly_1_NoCapture, ~0U,
|
Attr_ReadOnly_NoUnwind_1_NoCapture(Attr_ReadOnly_1_NoCapture,
|
||||||
|
LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::NoUnwind),
|
llvm::Attribute::NoUnwind),
|
||||||
Attr_ReadOnly_NoUnwind_1_2_NoCapture(Attr_ReadOnly_NoUnwind_1_NoCapture,
|
Attr_ReadOnly_NoUnwind_1_2_NoCapture(Attr_ReadOnly_NoUnwind_1_NoCapture,
|
||||||
2, llvm::Attribute::NoCapture),
|
2, llvm::Attribute::NoCapture),
|
||||||
Attr_ReadNone(NoAttrs, ~0U, llvm::Attribute::ReadNone),
|
Attr_ReadNone(NoAttrs, LLAttributeSet::FunctionIndex,
|
||||||
|
llvm::Attribute::ReadNone),
|
||||||
Attr_1_NoCapture(NoAttrs, 1, llvm::Attribute::NoCapture),
|
Attr_1_NoCapture(NoAttrs, 1, llvm::Attribute::NoCapture),
|
||||||
Attr_NoAlias_1_NoCapture(Attr_1_NoCapture, 0, llvm::Attribute::NoAlias),
|
Attr_NoAlias_1_NoCapture(Attr_1_NoCapture, 0, llvm::Attribute::NoAlias),
|
||||||
Attr_1_2_NoCapture(Attr_1_NoCapture, 2, llvm::Attribute::NoCapture),
|
Attr_1_2_NoCapture(Attr_1_NoCapture, 2, llvm::Attribute::NoCapture),
|
||||||
|
|
|
@ -826,7 +826,7 @@ DValue *DtoCallFunctionImpl(Loc &loc, Type *resulttype, DValue *fnval,
|
||||||
AttrSet attrs;
|
AttrSet attrs;
|
||||||
|
|
||||||
// return attrs
|
// return attrs
|
||||||
attrs.add(0, irFty.ret->attrs);
|
attrs.add(LLAttributeSet::ReturnIndex, irFty.ret->attrs);
|
||||||
|
|
||||||
std::vector<LLValue *> args;
|
std::vector<LLValue *> args;
|
||||||
args.reserve(irFty.args.size());
|
args.reserve(irFty.args.size());
|
||||||
|
|
|
@ -306,6 +306,9 @@ llvm::BasicBlock *CleanupScope::run(IRState &irs, llvm::BasicBlock *sourceBlock,
|
||||||
if (!branchSelector) {
|
if (!branchSelector) {
|
||||||
// ... and have not created one yet, so do so now.
|
// ... and have not created one yet, so do so now.
|
||||||
branchSelector = new llvm::AllocaInst(llvm::Type::getInt32Ty(irs.context()),
|
branchSelector = new llvm::AllocaInst(llvm::Type::getInt32Ty(irs.context()),
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
irs.module.getDataLayout().getAllocaAddrSpace(),
|
||||||
|
#endif
|
||||||
llvm::Twine("branchsel.") +
|
llvm::Twine("branchsel.") +
|
||||||
beginBlock()->getName(),
|
beginBlock()->getName(),
|
||||||
irs.topallocapoint());
|
irs.topallocapoint());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue