mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 03:46:02 +03:00
Fix LLVM 5.0 build. (#2050)
llvm::AttributeSet was renamed to llvm::AttributeList
This commit is contained in:
parent
9bb7ada8e0
commit
9e394e4f99
8 changed files with 33 additions and 27 deletions
|
@ -66,19 +66,17 @@ AttrSet::AttrSet(const AttrSet &base, unsigned index, LLAttribute attribute)
|
||||||
|
|
||||||
AttrSet
|
AttrSet
|
||||||
AttrSet::extractFunctionAndReturnAttributes(const llvm::Function *function) {
|
AttrSet::extractFunctionAndReturnAttributes(const llvm::Function *function) {
|
||||||
AttrSet r;
|
auto old = function->getAttributes();
|
||||||
|
LLAttributeSet existingAttrs[] = {old.getFnAttributes(),
|
||||||
llvm::AttributeSet old = function->getAttributes();
|
old.getRetAttributes()};
|
||||||
llvm::AttributeSet existingAttrs[] = {old.getFnAttributes(),
|
AttrSet r(LLAttributeSet::get(gIR->context(), existingAttrs));
|
||||||
old.getRetAttributes()};
|
|
||||||
r.set = llvm::AttributeSet::get(gIR->context(), existingAttrs);
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrSet &AttrSet::add(unsigned index, const AttrBuilder &builder) {
|
AttrSet &AttrSet::add(unsigned index, const AttrBuilder &builder) {
|
||||||
if (builder.hasAttributes()) {
|
if (builder.hasAttributes()) {
|
||||||
auto as = llvm::AttributeSet::get(gIR->context(), index, builder);
|
auto as = LLAttributeSet::get(gIR->context(), index, builder);
|
||||||
set = set.addAttributes(gIR->context(), index, as);
|
set = set.addAttributes(gIR->context(), index, as);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
|
|
||||||
using LLAttribute = llvm::Attribute::AttrKind;
|
using LLAttribute = llvm::Attribute::AttrKind;
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
using LLAttributeSet = llvm::AttributeList;
|
||||||
|
#else
|
||||||
|
using LLAttributeSet = llvm::AttributeSet;
|
||||||
|
#endif
|
||||||
|
|
||||||
class AttrBuilder {
|
class AttrBuilder {
|
||||||
llvm::AttrBuilder builder;
|
llvm::AttrBuilder builder;
|
||||||
|
@ -37,11 +42,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class AttrSet {
|
class AttrSet {
|
||||||
llvm::AttributeSet set;
|
LLAttributeSet set;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AttrSet() = default;
|
AttrSet() = default;
|
||||||
AttrSet(const llvm::AttributeSet &nativeSet) : set(nativeSet) {}
|
AttrSet(const LLAttributeSet &nativeSet) : set(nativeSet) {}
|
||||||
AttrSet(const AttrSet &base, unsigned index, LLAttribute attribute);
|
AttrSet(const AttrSet &base, unsigned index, LLAttribute attribute);
|
||||||
|
|
||||||
static AttrSet
|
static AttrSet
|
||||||
|
@ -50,8 +55,8 @@ public:
|
||||||
AttrSet &add(unsigned index, const AttrBuilder &builder);
|
AttrSet &add(unsigned index, const AttrBuilder &builder);
|
||||||
AttrSet &merge(const AttrSet &other);
|
AttrSet &merge(const AttrSet &other);
|
||||||
|
|
||||||
operator llvm::AttributeSet &() { return set; }
|
operator LLAttributeSet &() { return set; }
|
||||||
operator const llvm::AttributeSet &() const { return set; }
|
operator const LLAttributeSet &() const { return set; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct TempDisableDiscardValueNames {
|
||||||
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();
|
||||||
wannabe->addAttributes(llvm::AttributeSet::FunctionIndex, fnAttrSet);
|
wannabe->addAttributes(LLAttributeSet::FunctionIndex, fnAttrSet);
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,12 @@ public:
|
||||||
// Finalize the MD5 and return the hash.
|
// Finalize the MD5 and return the hash.
|
||||||
llvm::MD5::MD5Result Result;
|
llvm::MD5::MD5Result Result;
|
||||||
MD5.final(Result);
|
MD5.final(Result);
|
||||||
|
#if LDC_LLVM_VER >= 500
|
||||||
|
return Result.low();
|
||||||
|
#else
|
||||||
using namespace llvm::support;
|
using namespace llvm::support;
|
||||||
return endian::read<uint64_t, little, unaligned>(Result);
|
return endian::read<uint64_t, little, unaligned>(Result);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -306,17 +306,16 @@ static void buildRuntimeModule() {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Construct some attribute lists used below (possibly multiple times)
|
// Construct some attribute lists used below (possibly multiple times)
|
||||||
AttrSet NoAttrs, Attr_NoAlias(NoAttrs, llvm::AttributeSet::ReturnIndex,
|
AttrSet NoAttrs, Attr_NoAlias(NoAttrs, LLAttributeSet::ReturnIndex,
|
||||||
llvm::Attribute::NoAlias),
|
llvm::Attribute::NoAlias),
|
||||||
Attr_NoUnwind(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
Attr_NoUnwind(NoAttrs, LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::NoUnwind),
|
llvm::Attribute::NoUnwind),
|
||||||
Attr_ReadOnly(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
Attr_ReadOnly(NoAttrs, LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::ReadOnly),
|
llvm::Attribute::ReadOnly),
|
||||||
Attr_Cold(NoAttrs, llvm::AttributeSet::FunctionIndex,
|
Attr_Cold(NoAttrs, LLAttributeSet::FunctionIndex, llvm::Attribute::Cold),
|
||||||
llvm::Attribute::Cold),
|
Attr_Cold_NoReturn(Attr_Cold, LLAttributeSet::FunctionIndex,
|
||||||
Attr_Cold_NoReturn(Attr_Cold, llvm::AttributeSet::FunctionIndex,
|
|
||||||
llvm::Attribute::NoReturn),
|
llvm::Attribute::NoReturn),
|
||||||
Attr_ReadOnly_NoUnwind(Attr_ReadOnly, llvm::AttributeSet::FunctionIndex,
|
Attr_ReadOnly_NoUnwind(Attr_ReadOnly, LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::NoUnwind),
|
llvm::Attribute::NoUnwind),
|
||||||
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,
|
||||||
|
|
|
@ -979,7 +979,7 @@ DValue *DtoCallFunctionImpl(Loc &loc, Type *resulttype, DValue *fnval,
|
||||||
}
|
}
|
||||||
|
|
||||||
// set calling convention and parameter attributes
|
// set calling convention and parameter attributes
|
||||||
llvm::AttributeSet &attrlist = attrs;
|
LLAttributeSet &attrlist = attrs;
|
||||||
if (dfnval && dfnval->func) {
|
if (dfnval && dfnval->func) {
|
||||||
LLFunction *llfunc = llvm::dyn_cast<LLFunction>(DtoRVal(dfnval));
|
LLFunction *llfunc = llvm::dyn_cast<LLFunction>(DtoRVal(dfnval));
|
||||||
if (llfunc && llfunc->isIntrinsic()) // override intrinsic attrs
|
if (llfunc && llfunc->isIntrinsic()) // override intrinsic attrs
|
||||||
|
@ -995,7 +995,7 @@ DValue *DtoCallFunctionImpl(Loc &loc, Type *resulttype, DValue *fnval,
|
||||||
}
|
}
|
||||||
// merge in function attributes set in callOrInvoke
|
// merge in function attributes set in callOrInvoke
|
||||||
attrlist = attrlist.addAttributes(
|
attrlist = attrlist.addAttributes(
|
||||||
gIR->context(), llvm::AttributeSet::FunctionIndex, call.getAttributes());
|
gIR->context(), LLAttributeSet::FunctionIndex, call.getAttributes());
|
||||||
|
|
||||||
call.setAttributes(attrlist);
|
call.setAttributes(attrlist);
|
||||||
|
|
||||||
|
|
|
@ -186,10 +186,10 @@ void applyAttrAllocSize(StructLiteralExp *sle, IrFunction *irFunc) {
|
||||||
} else {
|
} else {
|
||||||
builder.addAllocSizeAttr(llvmSizeIdx, llvm::Optional<unsigned>());
|
builder.addAllocSizeAttr(llvmSizeIdx, llvm::Optional<unsigned>());
|
||||||
}
|
}
|
||||||
func->addAttributes(llvm::AttributeSet::FunctionIndex,
|
func->addAttributes(LLAttributeSet::FunctionIndex,
|
||||||
llvm::AttributeSet::get(func->getContext(),
|
LLAttributeSet::get(func->getContext(),
|
||||||
llvm::AttributeSet::FunctionIndex,
|
LLAttributeSet::FunctionIndex,
|
||||||
builder));
|
builder));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@ IrFunction::IrFunction(FuncDeclaration *fd) : FMF(opts::defaultFMF) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrFunction::setNeverInline() {
|
void IrFunction::setNeverInline() {
|
||||||
assert(!func->getAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex,
|
assert(!func->getAttributes().hasAttribute(LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::AlwaysInline) &&
|
llvm::Attribute::AlwaysInline) &&
|
||||||
"function can't be never- and always-inline at the same time");
|
"function can't be never- and always-inline at the same time");
|
||||||
func->addFnAttr(llvm::Attribute::NoInline);
|
func->addFnAttr(llvm::Attribute::NoInline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrFunction::setAlwaysInline() {
|
void IrFunction::setAlwaysInline() {
|
||||||
assert(!func->getAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex,
|
assert(!func->getAttributes().hasAttribute(LLAttributeSet::FunctionIndex,
|
||||||
llvm::Attribute::NoInline) &&
|
llvm::Attribute::NoInline) &&
|
||||||
"function can't be never- and always-inline at the same time");
|
"function can't be never- and always-inline at the same time");
|
||||||
func->addFnAttr(llvm::Attribute::AlwaysInline);
|
func->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue