LLVM 3.3: class Attributes is renamed to Attribute.

Some other renamings took place in "llvm/Attributes.h" but only this causes
compile errors in LDC.
Also uses new location of "llvm/IRBuilder.h".
This commit is contained in:
kai 2012-12-21 17:32:17 +01:00
parent 9d9f827efb
commit 5f37ae30cf
11 changed files with 170 additions and 38 deletions

View file

@ -533,7 +533,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
if (fty.arg_this) if (fty.arg_this)
{ {
Logger::println("Putting 'this' in register"); Logger::println("Putting 'this' in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fty.arg_this->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
fty.arg_this->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg)); fty.arg_this->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg));
#else #else
fty.arg_this->attrs = llvm::Attribute::InReg; fty.arg_this->attrs = llvm::Attribute::InReg;
@ -543,7 +545,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
else if (fty.arg_nest) else if (fty.arg_nest)
{ {
Logger::println("Putting context ptr in register"); Logger::println("Putting context ptr in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fty.arg_nest->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
fty.arg_nest->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg)); fty.arg_nest->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg));
#else #else
fty.arg_nest->attrs = llvm::Attribute::InReg; fty.arg_nest->attrs = llvm::Attribute::InReg;
@ -555,7 +559,10 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
Logger::println("Putting sret ptr in register"); Logger::println("Putting sret ptr in register");
// sret and inreg are incompatible, but the ABI requires the // sret and inreg are incompatible, but the ABI requires the
// sret parameter to be in RDI in this situation... // sret parameter to be in RDI in this situation...
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
sret->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attribute::InReg)
.removeAttribute(llvm::Attribute::StructRet));
#elif LDC_LLVM_VER == 302
sret->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attributes::InReg) sret->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attributes::InReg)
.removeAttribute(llvm::Attributes::StructRet)); .removeAttribute(llvm::Attributes::StructRet));
#else #else
@ -578,7 +585,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
{ {
if (xmmcount > 0) { if (xmmcount > 0) {
Logger::println("Putting float parameter in register"); Logger::println("Putting float parameter in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
arg.attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg)); arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg));
#else #else
arg.attrs |= llvm::Attribute::InReg; arg.attrs |= llvm::Attribute::InReg;
@ -593,7 +602,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
else if (arg.byref && !arg.isByVal()) else if (arg.byref && !arg.isByVal())
{ {
Logger::println("Putting byref parameter in register"); Logger::println("Putting byref parameter in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
arg.attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg)); arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg));
#else #else
arg.attrs |= llvm::Attribute::InReg; arg.attrs |= llvm::Attribute::InReg;
@ -603,7 +614,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
else if (ty->ty == Tpointer) else if (ty->ty == Tpointer)
{ {
Logger::println("Putting pointer parameter in register"); Logger::println("Putting pointer parameter in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
arg.attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg)); arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg));
#else #else
arg.attrs |= llvm::Attribute::InReg; arg.attrs |= llvm::Attribute::InReg;
@ -613,7 +626,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
else if (ty->isintegral() && sz <= 8) else if (ty->isintegral() && sz <= 8)
{ {
Logger::println("Putting integral parameter in register"); Logger::println("Putting integral parameter in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
arg.attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg)); arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(arg.attrs).addAttribute(llvm::Attributes::InReg));
#else #else
arg.attrs |= llvm::Attribute::InReg; arg.attrs |= llvm::Attribute::InReg;
@ -627,7 +642,9 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
arg.rewrite = &compositeToInt; arg.rewrite = &compositeToInt;
arg.ltype = compositeToInt.type(arg.type, arg.ltype); arg.ltype = compositeToInt.type(arg.type, arg.ltype);
arg.byref = false; arg.byref = false;
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
arg.attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg)); arg.attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg));
#else #else
arg.attrs = llvm::Attribute::InReg; arg.attrs = llvm::Attribute::InReg;

View file

@ -124,7 +124,9 @@ struct X86TargetABI : TargetABI
if (fty.arg_this) if (fty.arg_this)
{ {
Logger::println("Putting 'this' in register"); Logger::println("Putting 'this' in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fty.arg_this->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
fty.arg_this->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg)); fty.arg_this->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg));
#else #else
fty.arg_this->attrs = llvm::Attribute::InReg; fty.arg_this->attrs = llvm::Attribute::InReg;
@ -133,7 +135,9 @@ struct X86TargetABI : TargetABI
else if (fty.arg_nest) else if (fty.arg_nest)
{ {
Logger::println("Putting context ptr in register"); Logger::println("Putting context ptr in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fty.arg_nest->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
fty.arg_nest->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg)); fty.arg_nest->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::InReg));
#else #else
fty.arg_nest->attrs = llvm::Attribute::InReg; fty.arg_nest->attrs = llvm::Attribute::InReg;
@ -144,7 +148,10 @@ struct X86TargetABI : TargetABI
Logger::println("Putting sret ptr in register"); Logger::println("Putting sret ptr in register");
// sret and inreg are incompatible, but the ABI requires the // sret and inreg are incompatible, but the ABI requires the
// sret parameter to be in EAX in this situation... // sret parameter to be in EAX in this situation...
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
sret->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attribute::InReg)
.removeAttribute(llvm::Attribute::StructRet));
#elif LDC_LLVM_VER == 302
sret->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attributes::InReg) sret->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(sret->attrs).addAttribute(llvm::Attributes::InReg)
.removeAttribute(llvm::Attributes::StructRet)); .removeAttribute(llvm::Attributes::StructRet));
#else #else
@ -167,7 +174,9 @@ struct X86TargetABI : TargetABI
if (last->byref && !last->isByVal()) if (last->byref && !last->isByVal())
{ {
Logger::println("Putting last (byref) parameter in register"); Logger::println("Putting last (byref) parameter in register");
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
last->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
last->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attributes::InReg)); last->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attributes::InReg));
#else #else
last->attrs |= llvm::Attribute::InReg; last->attrs |= llvm::Attribute::InReg;
@ -182,13 +191,17 @@ struct X86TargetABI : TargetABI
last->ltype = compositeToInt.type(last->type, last->ltype); last->ltype = compositeToInt.type(last->type, last->ltype);
last->byref = false; last->byref = false;
// erase previous attributes // erase previous attributes
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
last->attrs = llvm::Attribute();
#elif LDC_LLVM_VER == 302
last->attrs = llvm::Attributes(); last->attrs = llvm::Attributes();
#else #else
last->attrs = llvm::Attribute::None; last->attrs = llvm::Attribute::None;
#endif #endif
} }
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
last->attrs = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attribute::InReg));
#elif LDC_LLVM_VER == 302
last->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attributes::InReg)); last->attrs = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(last->attrs).addAttribute(llvm::Attributes::InReg));
#else #else
last->attrs |= llvm::Attribute::InReg; last->attrs |= llvm::Attribute::InReg;

View file

@ -68,7 +68,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
else else
{ {
Type* rt = f->next; Type* rt = f->next;
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
llvm::Attribute a;
#elif LDC_LLVM_VER == 302
llvm::Attributes a; llvm::Attributes a;
#else #else
llvm::Attributes a = None; llvm::Attributes a = None;
@ -78,9 +80,15 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
if (abi->returnInArg(f)) if (abi->returnInArg(f))
{ {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 302
#if LDC_LLVM_VER >= 303
fty.arg_sret = new IrFuncTyArg(rt, true, llvm::Attribute::get(gIR->context(),
llvm::AttrBuilder().addAttribute(llvm::Attribute::StructRet)
.addAttribute(llvm::Attribute::NoAlias)
#else
fty.arg_sret = new IrFuncTyArg(rt, true, llvm::Attributes::get(gIR->context(), fty.arg_sret = new IrFuncTyArg(rt, true, llvm::Attributes::get(gIR->context(),
llvm::AttrBuilder().addAttribute(llvm::Attributes::StructRet) llvm::AttrBuilder().addAttribute(llvm::Attributes::StructRet)
.addAttribute(llvm::Attributes::NoAlias) .addAttribute(llvm::Attributes::NoAlias)
#endif
#if !STRUCTTHISREF #if !STRUCTTHISREF
// In D2 where 'this' in structs is a reference, nocapture // In D2 where 'this' in structs is a reference, nocapture
// might not actually be applicable, even if it probably still // might not actually be applicable, even if it probably still
@ -146,7 +154,11 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
fty.arg_arguments = new IrFuncTyArg(Type::typeinfo->type->arrayOf(), false); fty.arg_arguments = new IrFuncTyArg(Type::typeinfo->type->arrayOf(), false);
lidx++; lidx++;
// _argptr // _argptr
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false,
llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoAlias)
.addAttribute(llvm::Attribute::NoCapture)));
#elif LDC_LLVM_VER == 302
fty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false, fty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false,
llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias) llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias)
.addAttribute(llvm::Attributes::NoCapture))); .addAttribute(llvm::Attributes::NoCapture)));
@ -186,7 +198,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
#endif #endif
Type* argtype = arg->type; Type* argtype = arg->type;
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
llvm::Attribute a;
#elif LDC_LLVM_VER == 302
llvm::Attributes a; llvm::Attributes a;
#else #else
llvm::Attributes a = None; llvm::Attributes a = None;
@ -203,7 +217,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
// byval // byval
else if (abi->passByVal(byref ? argtype->pointerTo() : argtype)) else if (abi->passByVal(byref ? argtype->pointerTo() : argtype))
{ {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
if (!byref) a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attribute::ByVal));
#elif LDC_LLVM_VER == 302
if (!byref) a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attributes::ByVal)); if (!byref) a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attributes::ByVal));
#else #else
if (!byref) a |= llvm::Attribute::ByVal; if (!byref) a |= llvm::Attribute::ByVal;
@ -214,7 +230,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
// sext/zext // sext/zext
else if (!byref) else if (!byref)
{ {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype)));
#elif LDC_LLVM_VER == 302
a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype))); a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype)));
#else #else
a |= DtoShouldExtend(argtype); a |= DtoShouldExtend(argtype);
@ -333,7 +351,9 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
LLFunction* fun = gIR->module->getFunction(mangled_name); LLFunction* fun = gIR->module->getFunction(mangled_name);
fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage); fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
fun->addFnAttr(llvm::Attribute::AlwaysInline);
#elif LDC_LLVM_VER == 302
fun->addFnAttr(llvm::Attributes::AlwaysInline); fun->addFnAttr(llvm::Attributes::AlwaysInline);
#else #else
fun->addFnAttr(AlwaysInline); fun->addFnAttr(AlwaysInline);
@ -544,7 +564,9 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
// set attrs on the rest of the arguments // set attrs on the rest of the arguments
size_t n = Parameter::dim(f->parameters); size_t n = Parameter::dim(f->parameters);
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
LLSmallVector<llvm::Attribute, 8> attrptr(n, llvm::Attribute());
#elif LDC_LLVM_VER == 302
LLSmallVector<llvm::Attributes, 8> attrptr(n, llvm::Attributes()); LLSmallVector<llvm::Attributes, 8> attrptr(n, llvm::Attributes());
#else #else
LLSmallVector<llvm::Attributes, 8> attrptr(n, None); LLSmallVector<llvm::Attributes, 8> attrptr(n, None);
@ -587,7 +609,11 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
bool found = false; bool found = false;
for (size_t j = 0; j < newSize; ++j) { for (size_t j = 0; j < newSize; ++j) {
if (attrs[j].Index == curr.Index) { if (attrs[j].Index == curr.Index) {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
attrs[j].Attrs = llvm::Attribute::get(
gIR->context(),
llvm::AttrBuilder(attrs[j].Attrs).addAttributes(curr.Attrs));
#elif LDC_LLVM_VER == 302
attrs[j].Attrs = llvm::Attributes::get( attrs[j].Attrs = llvm::Attributes::get(
gIR->context(), gIR->context(),
llvm::AttrBuilder(attrs[j].Attrs).addAttributes(curr.Attrs)); llvm::AttrBuilder(attrs[j].Attrs).addAttributes(curr.Attrs));
@ -688,7 +714,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
if (!fdecl->isIntrinsic()) { if (!fdecl->isIntrinsic()) {
set_param_attrs(f, func, fdecl); set_param_attrs(f, func, fdecl);
if (global.params.disableRedZone) { if (global.params.disableRedZone) {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
func->addFnAttr(llvm::Attribute::NoRedZone);
#elif LDC_LLVM_VER == 302
func->addFnAttr(llvm::Attributes::NoRedZone); func->addFnAttr(llvm::Attributes::NoRedZone);
#else #else
func->addFnAttr(NoRedZone); func->addFnAttr(NoRedZone);

View file

@ -27,7 +27,11 @@
#include "llvm/Intrinsics.h" #include "llvm/Intrinsics.h"
#include "llvm/Support/CallSite.h" #include "llvm/Support/CallSite.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IRBuilder.h"
#else
#include "llvm/Support/IRBuilder.h" #include "llvm/Support/IRBuilder.h"
#endif
#include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/ValueTracking.h" #include "llvm/Analysis/ValueTracking.h"
@ -716,7 +720,9 @@ bool isSafeToStackAllocate(Instruction* Alloc, Value* V, DominatorTree& DT,
for (CallSite::arg_iterator A = B; A != E; ++A) for (CallSite::arg_iterator A = B; A != E; ++A)
if (A->get() == V) { if (A->get() == V) {
if (!CS.paramHasAttr(A - B + 1, if (!CS.paramHasAttr(A - B + 1,
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
Attribute::NoCapture
#elif LDC_LLVM_VER == 302
Attributes::NoCapture Attributes::NoCapture
#else #else
Attribute::NoCapture Attribute::NoCapture

View file

@ -197,12 +197,41 @@ static void LLVM_D_BuildRuntimeModule()
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
// Construct some attribute lists used below (possibly multiple times) // Construct some attribute lists used below (possibly multiple times)
#if LDC_LLVM_VER >= 302
#if LDC_LLVM_VER >= 303 #if LDC_LLVM_VER >= 303
llvm::AttributeSet llvm::AttributeSet
#else NoAttrs,
llvm::AttrListPtr Attr_NoAlias
= NoAttrs.addAttr(gIR->context(), 0, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoAlias))),
Attr_NoUnwind
= NoAttrs.addAttr(gIR->context(), ~0U, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoUnwind))),
Attr_ReadOnly
= NoAttrs.addAttr(gIR->context(), ~0U, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::ReadOnly))),
Attr_ReadOnly_NoUnwind
= Attr_ReadOnly.addAttr(gIR->context(), ~0U, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoUnwind))),
Attr_ReadOnly_1_NoCapture
= Attr_ReadOnly.addAttr(gIR->context(), 1, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
Attr_ReadOnly_1_3_NoCapture
= Attr_ReadOnly_1_NoCapture.addAttr(gIR->context(), 3, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
Attr_ReadOnly_NoUnwind_1_NoCapture
= Attr_ReadOnly_1_NoCapture.addAttr(gIR->context(), ~0U, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoUnwind))),
Attr_ReadNone
= NoAttrs.addAttr(gIR->context(), ~0U, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::ReadNone))),
Attr_1_NoCapture
= NoAttrs.addAttr(gIR->context(), 1, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
Attr_NoAlias_1_NoCapture
= Attr_1_NoCapture.addAttr(gIR->context(), 0, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoAlias))),
#if DMDV1
Attr_NoAlias_3_NoCapture
= Attr_NoAlias.addAttr(gIR->context(), 3, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
#endif #endif
Attr_1_2_NoCapture
= Attr_1_NoCapture.addAttr(gIR->context(), 2, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
Attr_1_3_NoCapture
= Attr_1_NoCapture.addAttr(gIR->context(), 3, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture))),
Attr_1_4_NoCapture
= Attr_1_NoCapture.addAttr(gIR->context(), 4, llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::NoCapture)));
#elif LDC_LLVM_VER == 302
llvm::AttrListPtr
NoAttrs, NoAttrs,
Attr_NoAlias Attr_NoAlias
= NoAttrs.addAttr(gIR->context(), 0, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias))), = NoAttrs.addAttr(gIR->context(), 0, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias))),

View file

@ -404,7 +404,10 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
// add attrs for hidden ptr // add attrs for hidden ptr
Attr.Index = 1; Attr.Index = 1;
Attr.Attrs = tf->fty.arg_sret->attrs; Attr.Attrs = tf->fty.arg_sret->attrs;
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
assert((Attr.Attrs.hasAttribute(llvm::Attribute::StructRet) || Attr.Attrs.hasAttribute(llvm::Attribute::InReg))
&& "Sret arg not sret or inreg?");
#elif LDC_LLVM_VER == 302
assert((Attr.Attrs.hasAttribute(llvm::Attributes::StructRet) || Attr.Attrs.hasAttribute(llvm::Attributes::InReg)) assert((Attr.Attrs.hasAttribute(llvm::Attributes::StructRet) || Attr.Attrs.hasAttribute(llvm::Attributes::InReg))
&& "Sret arg not sret or inreg?"); && "Sret arg not sret or inreg?");
#else #else
@ -525,7 +528,9 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
} }
size_t n = Parameter::dim(tf->parameters); size_t n = Parameter::dim(tf->parameters);
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
LLSmallVector<llvm::Attribute, 10> attrptr(n, llvm::Attribute());
#elif LDC_LLVM_VER == 302
LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attributes()); LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attributes());
#else #else
LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attribute::None); LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attribute::None);

View file

@ -42,7 +42,11 @@ bool DtoIsPassedByRef(Type* type)
return (t == Tstruct || t == Tsarray); return (t == Tstruct || t == Tsarray);
} }
#if LDC_LLVM_VER >= 303
llvm::Attribute DtoShouldExtend(Type* type)
#else
llvm::Attributes DtoShouldExtend(Type* type) llvm::Attributes DtoShouldExtend(Type* type)
#endif
{ {
type = type->toBasetype(); type = type->toBasetype();
if (type->isintegral()) if (type->isintegral())
@ -51,7 +55,9 @@ llvm::Attributes DtoShouldExtend(Type* type)
{ {
case Tint8: case Tint8:
case Tint16: case Tint16:
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::SExt));
#elif LDC_LLVM_VER == 302
return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::SExt)); return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::SExt));
#else #else
return llvm::Attribute::SExt; return llvm::Attribute::SExt;
@ -59,14 +65,18 @@ llvm::Attributes DtoShouldExtend(Type* type)
case Tuns8: case Tuns8:
case Tuns16: case Tuns16:
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::ZExt));
#elif LDC_LLVM_VER == 302
return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::ZExt)); return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::ZExt));
#else #else
return llvm::Attribute::ZExt; return llvm::Attribute::ZExt;
#endif #endif
} }
} }
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
return llvm::Attribute();
#elif LDC_LLVM_VER == 302
return llvm::Attributes(); return llvm::Attributes();
#else #else
return llvm::Attribute::None; return llvm::Attribute::None;

View file

@ -34,7 +34,11 @@ LLType* DtoTypeNotVoid(Type* t);
bool DtoIsPassedByRef(Type* type); bool DtoIsPassedByRef(Type* type);
// should argument be zero or sign extended // should argument be zero or sign extended
#if LDC_LLVM_VER >= 303
llvm::Attribute DtoShouldExtend(Type* type);
#else
llvm::Attributes DtoShouldExtend(Type* type); llvm::Attributes DtoShouldExtend(Type* type);
#endif
// tuple helper // tuple helper
// takes a arguments list and makes a struct type out of them // takes a arguments list and makes a struct type out of them

View file

@ -72,7 +72,10 @@ IrFunction::IrFunction(FuncDeclaration* fd)
void IrFunction::setNeverInline() void IrFunction::setNeverInline()
{ {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
assert(!func->getFnAttributes().hasAttribute(llvm::Attribute::AlwaysInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attribute::NoInline);
#elif LDC_LLVM_VER == 302
assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) && "function can't be never- and always-inline at the same time"); assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attributes::NoInline); func->addFnAttr(llvm::Attributes::NoInline);
#else #else
@ -83,7 +86,10 @@ void IrFunction::setNeverInline()
void IrFunction::setAlwaysInline() void IrFunction::setAlwaysInline()
{ {
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
assert(!func->getFnAttributes().hasAttribute(llvm::Attribute::NoInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attribute::AlwaysInline);
#elif LDC_LLVM_VER == 302
assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::NoInline) && "function can't be never- and always-inline at the same time"); assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::NoInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attributes::AlwaysInline); func->addFnAttr(llvm::Attributes::AlwaysInline);
#else #else

View file

@ -17,7 +17,11 @@
#include "gen/llvm.h" #include "gen/llvm.h"
#include "gen/tollvm.h" #include "gen/tollvm.h"
#if LDC_LLVM_VER >= 303
IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attribute a) : type(t)
#else
IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t) IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t)
#endif
{ {
ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t); ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t);
attrs = a; attrs = a;
@ -25,7 +29,11 @@ IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t)
rewrite = NULL; rewrite = NULL;
} }
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
bool IrFuncTyArg::isInReg() const { return attrs.hasAttribute(llvm::Attribute::InReg); }
bool IrFuncTyArg::isSRet() const { return attrs.hasAttribute(llvm::Attribute::StructRet); }
bool IrFuncTyArg::isByVal() const { return attrs.hasAttribute(llvm::Attribute::ByVal); }
#elif LDC_LLVM_VER == 302
bool IrFuncTyArg::isInReg() const { return attrs.hasAttribute(llvm::Attributes::InReg); } bool IrFuncTyArg::isInReg() const { return attrs.hasAttribute(llvm::Attributes::InReg); }
bool IrFuncTyArg::isSRet() const { return attrs.hasAttribute(llvm::Attributes::StructRet); } bool IrFuncTyArg::isSRet() const { return attrs.hasAttribute(llvm::Attributes::StructRet); }
bool IrFuncTyArg::isByVal() const { return attrs.hasAttribute(llvm::Attributes::ByVal); } bool IrFuncTyArg::isByVal() const { return attrs.hasAttribute(llvm::Attributes::ByVal); }

View file

@ -44,7 +44,11 @@ struct IrFuncTyArg : IrBase
/** These are the final LLVM attributes used for the function. /** These are the final LLVM attributes used for the function.
* Must be valid for the LLVM Type and byref setting */ * Must be valid for the LLVM Type and byref setting */
#if LDC_LLVM_VER >= 303
llvm::Attribute attrs;
#else
llvm::Attributes attrs; llvm::Attributes attrs;
#endif
/** 'true' if the final LLVM argument is a LLVM reference type. /** 'true' if the final LLVM argument is a LLVM reference type.
* Must be true when the D Type is a value type, but the final * Must be true when the D Type is a value type, but the final
@ -67,7 +71,9 @@ struct IrFuncTyArg : IrBase
* @param byref Initial value for the 'byref' field. If true the initial * @param byref Initial value for the 'byref' field. If true the initial
* LLVM Type will be of DtoType(type->pointerTo()), instead * LLVM Type will be of DtoType(type->pointerTo()), instead
* of just DtoType(type) */ * of just DtoType(type) */
#if LDC_LLVM_VER >= 302 #if LDC_LLVM_VER >= 303
IrFuncTyArg(Type* t, bool byref, llvm::Attribute a = llvm::Attribute());
#elif LDC_LLVM_VER == 302
IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attributes()); IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attributes());
#else #else
IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attribute::None); IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attribute::None);