Remove the final bits of Attributes being declared in the Attribute

namespace. Use the attribute's enum value instead. No functionality change
intended.

llvm-svn: 165611
This commit is contained in:
Bill Wendling 2012-10-10 07:36:56 +00:00
parent bbcdf4e2a5
commit a7912f8894
6 changed files with 82 additions and 58 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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:

View File

@ -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.

View File

@ -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,

View File

@ -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 {