From 603571a2d6daca43162bf1d9469baf919697c00a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 10 Oct 2012 07:36:56 +0000 Subject: [PATCH] Remove the final bits of Attributes being declared in the Attribute namespace. Use the attribute's enum value instead. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165611 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCall.cpp | 101 +++++++++++++++++++--------------- lib/CodeGen/CGExpr.cpp | 8 ++- lib/CodeGen/CGObjCMac.cpp | 8 ++- lib/CodeGen/CGStmt.cpp | 4 +- lib/CodeGen/CodeGenModule.h | 4 +- lib/CodeGen/ItaniumCXXABI.cpp | 15 +++-- 6 files changed, 82 insertions(+), 58 deletions(-) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index c1f95a2957..562c17ded3 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -924,50 +924,50 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, const Decl *TargetDecl, AttributeListType &PAL, unsigned &CallingConv) { - llvm::Attributes FuncAttrs; - llvm::Attributes RetAttrs; + llvm::Attributes::Builder FuncAttrs; + llvm::Attributes::Builder RetAttrs; CallingConv = FI.getEffectiveCallingConvention(); if (FI.isNoReturn()) - FuncAttrs |= llvm::Attribute::NoReturn; + FuncAttrs.addAttribute(llvm::Attributes::NoReturn); // FIXME: handle sseregparm someday... if (TargetDecl) { if (TargetDecl->hasAttr()) - FuncAttrs |= llvm::Attribute::ReturnsTwice; + FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice); if (TargetDecl->hasAttr()) - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); else if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) { const FunctionProtoType *FPT = Fn->getType()->getAs(); if (FPT && FPT->isNothrow(getContext())) - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } if (TargetDecl->hasAttr()) - FuncAttrs |= llvm::Attribute::NoReturn; + FuncAttrs.addAttribute(llvm::Attributes::NoReturn); if (TargetDecl->hasAttr()) - FuncAttrs |= llvm::Attribute::ReturnsTwice; + FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice); // 'const' and 'pure' attribute functions are also nounwind. if (TargetDecl->hasAttr()) { - FuncAttrs |= llvm::Attribute::ReadNone; - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::ReadNone); + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } else if (TargetDecl->hasAttr()) { - FuncAttrs |= llvm::Attribute::ReadOnly; - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::ReadOnly); + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } if (TargetDecl->hasAttr()) - RetAttrs |= llvm::Attribute::NoAlias; + RetAttrs.addAttribute(llvm::Attributes::NoAlias); } if (CodeGenOpts.OptimizeSize) - FuncAttrs |= llvm::Attribute::OptimizeForSize; + FuncAttrs.addAttribute(llvm::Attributes::OptimizeForSize); if (CodeGenOpts.DisableRedZone) - FuncAttrs |= llvm::Attribute::NoRedZone; + FuncAttrs.addAttribute(llvm::Attributes::NoRedZone); if (CodeGenOpts.NoImplicitFloat) - FuncAttrs |= llvm::Attribute::NoImplicitFloat; + FuncAttrs.addAttribute(llvm::Attributes::NoImplicitFloat); QualType RetTy = FI.getReturnType(); unsigned Index = 1; @@ -975,24 +975,27 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, switch (RetAI.getKind()) { case ABIArgInfo::Extend: if (RetTy->hasSignedIntegerRepresentation()) - RetAttrs |= llvm::Attribute::SExt; + RetAttrs.addAttribute(llvm::Attributes::SExt); else if (RetTy->hasUnsignedIntegerRepresentation()) - RetAttrs |= llvm::Attribute::ZExt; + RetAttrs.addAttribute(llvm::Attributes::ZExt); break; case ABIArgInfo::Direct: case ABIArgInfo::Ignore: break; case ABIArgInfo::Indirect: { - llvm::Attributes SRETAttrs = llvm::Attribute::StructRet; + llvm::Attributes::Builder SRETAttrs; + SRETAttrs.addAttribute(llvm::Attributes::StructRet); if (RetAI.getInReg()) - SRETAttrs |= llvm::Attribute::InReg; - PAL.push_back(llvm::AttributeWithIndex::get(Index, SRETAttrs)); + SRETAttrs.addAttribute(llvm::Attributes::InReg); + PAL.push_back(llvm:: + AttributeWithIndex::get(Index, + llvm::Attributes::get(SRETAttrs))); ++Index; // sret disables readnone and readonly - FuncAttrs &= ~(llvm::Attribute::ReadOnly | - llvm::Attribute::ReadNone); + FuncAttrs.removeAttribute(llvm::Attributes::ReadOnly) + .removeAttribute(llvm::Attributes::ReadNone); break; } @@ -1000,14 +1003,16 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, llvm_unreachable("Invalid ABI kind for return argument"); } - if (RetAttrs) - PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs)); + if (RetAttrs.hasAttributes()) + PAL.push_back(llvm:: + AttributeWithIndex::get(0, + llvm::Attributes::get(RetAttrs))); for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); it != ie; ++it) { QualType ParamType = it->type; const ABIArgInfo &AI = it->info; - llvm::Attributes Attrs; + llvm::Attributes::Builder Attrs; // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we // have the corresponding parameter variable. It doesn't make @@ -1015,13 +1020,13 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, switch (AI.getKind()) { case ABIArgInfo::Extend: if (ParamType->isSignedIntegerOrEnumerationType()) - Attrs |= llvm::Attribute::SExt; + Attrs.addAttribute(llvm::Attributes::SExt); else if (ParamType->isUnsignedIntegerOrEnumerationType()) - Attrs |= llvm::Attribute::ZExt; + Attrs.addAttribute(llvm::Attributes::ZExt); // FALL THROUGH case ABIArgInfo::Direct: if (AI.getInReg()) - Attrs |= llvm::Attribute::InReg; + Attrs.addAttribute(llvm::Attributes::InReg); // FIXME: handle sseregparm someday... @@ -1031,22 +1036,23 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (llvm::StructType *STy = dyn_cast(AI.getCoerceToType())) { unsigned Extra = STy->getNumElements()-1; // 1 will be added below. - if (Attrs != llvm::Attribute::None) + if (Attrs.hasAttributes()) for (unsigned I = 0; I < Extra; ++I) - PAL.push_back(llvm::AttributeWithIndex::get(Index + I, Attrs)); + PAL.push_back(llvm::AttributeWithIndex::get(Index + I, + llvm::Attributes::get(Attrs))); Index += Extra; } break; case ABIArgInfo::Indirect: if (AI.getIndirectByVal()) - Attrs |= llvm::Attribute::ByVal; + Attrs.addAttribute(llvm::Attributes::ByVal); + + Attrs.addAlignmentAttr(AI.getIndirectAlign()); - Attrs |= - llvm::Attributes::constructAlignmentFromInt(AI.getIndirectAlign()); // byval disables readnone and readonly. - FuncAttrs &= ~(llvm::Attribute::ReadOnly | - llvm::Attribute::ReadNone); + FuncAttrs.removeAttribute(llvm::Attributes::ReadOnly) + .removeAttribute(llvm::Attributes::ReadNone); break; case ABIArgInfo::Ignore: @@ -1064,12 +1070,14 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, } } - if (Attrs) - PAL.push_back(llvm::AttributeWithIndex::get(Index, Attrs)); + if (Attrs.hasAttributes()) + PAL.push_back(llvm::AttributeWithIndex::get(Index, + llvm::Attributes::get(Attrs))); ++Index; } - if (FuncAttrs) - PAL.push_back(llvm::AttributeWithIndex::get(~0, FuncAttrs)); + if (FuncAttrs.hasAttributes()) + PAL.push_back(llvm::AttributeWithIndex::get(~0, + llvm::Attributes::get(FuncAttrs))); } /// An argument came in as a promoted argument; demote it back to its @@ -1117,7 +1125,9 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // Name the struct return argument. if (CGM.ReturnTypeUsesSRet(FI)) { AI->setName("agg.result"); - AI->addAttr(llvm::Attribute::NoAlias); + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoAlias); + AI->addAttr(llvm::Attributes::get(B)); ++AI; } @@ -1186,8 +1196,11 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, assert(AI != Fn->arg_end() && "Argument mismatch!"); llvm::Value *V = AI; - if (Arg->getType().isRestrictQualified()) - AI->addAttr(llvm::Attribute::NoAlias); + if (Arg->getType().isRestrictQualified()) { + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoAlias); + AI->addAttr(llvm::Attributes::get(B)); + } // Ensure the argument is the correct type. if (V->getType() != ArgI.getCoerceToType()) @@ -2127,7 +2140,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, llvm::AttrListPtr Attrs = llvm::AttrListPtr::get(AttributeList); llvm::BasicBlock *InvokeDest = 0; - if (!(Attrs.getFnAttributes() & llvm::Attribute::NoUnwind)) + if (!Attrs.getFnAttributes().hasAttribute(llvm::Attributes::NoUnwind)) InvokeDest = getInvokeDest(); llvm::CallSite CS; diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 8b169410ce..8c9a80ace2 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2079,11 +2079,13 @@ void CodeGenFunction::EmitCheck(llvm::Value *Checked, StringRef CheckName, llvm::FunctionType *FnType = llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false); + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoReturn) + .addAttribute(llvm::Attributes::NoUnwind) + .addAttribute(llvm::Attributes::UWTable); llvm::Value *Fn = CGM.CreateRuntimeFunction(FnType, ("__ubsan_handle_" + CheckName).str(), - llvm::Attribute::NoReturn | - llvm::Attribute::NoUnwind | - llvm::Attribute::UWTable); + llvm::Attributes::get(B)); llvm::CallInst *HandlerCall = Builder.CreateCall(Fn, Args); HandlerCall->setDoesNotReturn(); HandlerCall->setDoesNotThrow(); diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index db7e87df98..4e4879921a 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -63,10 +63,12 @@ private: // Add the non-lazy-bind attribute, since objc_msgSend is likely to // be called a lot. llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy }; + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NonLazyBind); return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, params, true), "objc_msgSend", - llvm::Attribute::NonLazyBind); + llvm::Attributes::get(B)); } /// void objc_msgSend_stret (id, SEL, ...) @@ -580,10 +582,12 @@ public: llvm::Constant *getSetJmpFn() { // This is specifically the prototype for x86. llvm::Type *params[] = { CGM.Int32Ty->getPointerTo() }; + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NonLazyBind); return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty, params, false), "_setjmp", - llvm::Attribute::ReturnsTwice); + llvm::Attributes::get(B)); } public: diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index df09dce7fd..41a96e82e2 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1632,7 +1632,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, /* IsAlignStack */ false, AsmDialect); llvm::CallInst *Result = Builder.CreateCall(IA, Args); - Result->addAttribute(~0, llvm::Attribute::NoUnwind); + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoUnwind); + Result->addAttribute(~0, llvm::Attributes::get(B)); // Slap the source location of the inline asm into a !srcloc metadata on the // call. FIXME: Handle metadata for MS-style inline asms. diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 5c19fc31fd..923b268dac 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -702,7 +702,7 @@ public: llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::Attributes ExtraAttrs = - llvm::Attribute::None); + llvm::Attributes()); /// CreateRuntimeVariable - Create a new runtime global variable with the /// specified type and name. llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, @@ -881,7 +881,7 @@ private: GlobalDecl D, bool ForVTable, llvm::Attributes ExtraAttrs = - llvm::Attribute::None); + llvm::Attributes()); llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, llvm::PointerType *PTy, const VarDecl *D, diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 3c92581c64..4d944301d2 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -950,9 +950,10 @@ static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM, llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy), GuardPtrTy, /*isVarArg=*/false); - + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoUnwind); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire", - llvm::Attribute::NoUnwind); + llvm::Attributes::get(B)); } static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM, @@ -960,9 +961,10 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM, // void __cxa_guard_release(__guard *guard_object); llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false); - + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoUnwind); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release", - llvm::Attribute::NoUnwind); + llvm::Attributes::get(B)); } static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM, @@ -970,9 +972,10 @@ static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM, // void __cxa_guard_abort(__guard *guard_object); llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false); - + llvm::Attributes::Builder B; + B.addAttribute(llvm::Attributes::NoUnwind); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort", - llvm::Attribute::NoUnwind); + llvm::Attributes::get(B)); } namespace { -- 2.40.0