diff options
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 101 |
1 files changed, 57 insertions, 44 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<ReturnsTwiceAttr>()) - FuncAttrs |= llvm::Attribute::ReturnsTwice; + FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice); if (TargetDecl->hasAttr<NoThrowAttr>()) - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); else if (const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) { const FunctionProtoType *FPT = Fn->getType()->getAs<FunctionProtoType>(); if (FPT && FPT->isNothrow(getContext())) - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } if (TargetDecl->hasAttr<NoReturnAttr>()) - FuncAttrs |= llvm::Attribute::NoReturn; + FuncAttrs.addAttribute(llvm::Attributes::NoReturn); if (TargetDecl->hasAttr<ReturnsTwiceAttr>()) - FuncAttrs |= llvm::Attribute::ReturnsTwice; + FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice); // 'const' and 'pure' attribute functions are also nounwind. if (TargetDecl->hasAttr<ConstAttr>()) { - FuncAttrs |= llvm::Attribute::ReadNone; - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::ReadNone); + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } else if (TargetDecl->hasAttr<PureAttr>()) { - FuncAttrs |= llvm::Attribute::ReadOnly; - FuncAttrs |= llvm::Attribute::NoUnwind; + FuncAttrs.addAttribute(llvm::Attributes::ReadOnly); + FuncAttrs.addAttribute(llvm::Attributes::NoUnwind); } if (TargetDecl->hasAttr<MallocAttr>()) - 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<llvm::StructType>(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; |