diff --git a/gen/functions.cpp b/gen/functions.cpp index 0bc62414..cccb84e6 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -36,8 +36,11 @@ #include "llvm/Support/CFG.h" #include -#if LDC_LLVM_VER < 302 -using namespace llvm::Attribute; +#if LDC_LLVM_VER == 302 +namespace llvm +{ + typedef llvm::Attributes Attribute; +} #endif llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, Type* nesttype, bool isMain, bool isCtor) @@ -76,7 +79,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, #if LDC_LLVM_VER >= 302 llvm::AttrBuilder attrBuilder; #else - llvm::Attributes a = None; + llvm::Attributes a = llvm::Attribute::None; #endif // sret return @@ -97,8 +100,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, #endif ); #else - newIrFty.arg_sret = new IrFuncTyArg(rt, true, StructRet | NoAlias - ); + newIrFty.arg_sret = new IrFuncTyArg(rt, true, + llvm::Attribute::StructRet | llvm::Attribute::NoAlias); #endif rt = Type::tvoid; lidx++; @@ -173,7 +176,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias) .addAttribute(llvm::Attributes::NoCapture))); #else - newIrFty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false, NoAlias | NoCapture); + newIrFty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false, + llvm::Attribute::NoAlias | llvm::Attribute::NoCapture); #endif lidx++; } @@ -208,7 +212,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, #if LDC_LLVM_VER >= 302 llvm::AttrBuilder attrBuilder; #else - llvm::Attributes a = None; + llvm::Attributes a = llvm::Attribute::None; #endif // handle lazy args @@ -222,10 +226,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, // byval else if (abi->passByVal(byref ? argtype->pointerTo() : argtype)) { -#if LDC_LLVM_VER >= 303 +#if LDC_LLVM_VER >= 302 if (!byref) attrBuilder.addAttribute(llvm::Attribute::ByVal); -#elif LDC_LLVM_VER == 302 - if (!byref) attrBuilder.addAttribute(llvm::Attributes::ByVal); #else if (!byref) a |= llvm::Attribute::ByVal; #endif @@ -366,13 +368,7 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl) LLFunction* fun = gIR->module->getFunction(mangled_name); fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage); -#if LDC_LLVM_VER >= 303 fun->addFnAttr(llvm::Attribute::AlwaysInline); -#elif LDC_LLVM_VER == 302 - fun->addFnAttr(llvm::Attributes::AlwaysInline); -#else - fun->addFnAttr(AlwaysInline); -#endif return fun; } @@ -630,7 +626,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati #if LDC_LLVM_VER == 302 LLSmallVector attrptr(n, llvm::Attributes()); #else - LLSmallVector attrptr(n, None); + LLSmallVector attrptr(n, llvm::Attribute::None); #endif for (size_t k = 0; k < n; ++k) @@ -782,13 +778,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) if (!fdecl->isIntrinsic()) { set_param_attrs(f, func, fdecl); if (global.params.disableRedZone) { -#if LDC_LLVM_VER >= 303 func->addFnAttr(llvm::Attribute::NoRedZone); -#elif LDC_LLVM_VER == 302 - func->addFnAttr(llvm::Attributes::NoRedZone); -#else - func->addFnAttr(NoRedZone); -#endif } } @@ -978,13 +968,7 @@ void DtoDefineFunction(FuncDeclaration* fd) // TODO: Find a better place for this. if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) { -#if LDC_LLVM_VER >= 303 func->addFnAttr(llvm::Attribute::UWTable); -#elif LDC_LLVM_VER == 302 - func->addFnAttr(llvm::Attributes::UWTable); -#else - func->addFnAttr(UWTable); -#endif } std::string entryname("entry");