Attributes Rewrite

Convert the uses of the Attributes class over to the new format. The
Attributes::get method call now takes an LLVM context so that the attributes
object can be uniquified and stored.

llvm-svn: 165918
This commit is contained in:
Bill Wendling 2012-10-15 04:47:45 +00:00
parent d079a446d7
commit 311c832fda
7 changed files with 28 additions and 16 deletions

View File

@ -990,7 +990,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
SRETAttrs.addAttribute(llvm::Attributes::InReg);
PAL.push_back(llvm::
AttributeWithIndex::get(Index,
llvm::Attributes::get(SRETAttrs)));
llvm::Attributes::get(getLLVMContext(),
SRETAttrs)));
++Index;
// sret disables readnone and readonly
@ -1006,7 +1007,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
if (RetAttrs.hasAttributes())
PAL.push_back(llvm::
AttributeWithIndex::get(0,
llvm::Attributes::get(RetAttrs)));
llvm::Attributes::get(getLLVMContext(),
RetAttrs)));
for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
ie = FI.arg_end(); it != ie; ++it) {
@ -1039,7 +1041,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
if (Attrs.hasAttributes())
for (unsigned I = 0; I < Extra; ++I)
PAL.push_back(llvm::AttributeWithIndex::get(Index + I,
llvm::Attributes::get(Attrs)));
llvm::Attributes::get(getLLVMContext(),
Attrs)));
Index += Extra;
}
break;
@ -1072,12 +1075,14 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
if (Attrs.hasAttributes())
PAL.push_back(llvm::AttributeWithIndex::get(Index,
llvm::Attributes::get(Attrs)));
llvm::Attributes::get(getLLVMContext(),
Attrs)));
++Index;
}
if (FuncAttrs.hasAttributes())
PAL.push_back(llvm::AttributeWithIndex::get(~0,
llvm::Attributes::get(FuncAttrs)));
llvm::Attributes::get(getLLVMContext(),
FuncAttrs)));
}
/// An argument came in as a promoted argument; demote it back to its
@ -1127,7 +1132,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
AI->setName("agg.result");
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoAlias);
AI->addAttr(llvm::Attributes::get(B));
AI->addAttr(llvm::Attributes::get(getLLVMContext(), B));
++AI;
}
@ -1199,7 +1204,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
if (Arg->getType().isRestrictQualified()) {
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoAlias);
AI->addAttr(llvm::Attributes::get(B));
AI->addAttr(llvm::Attributes::get(getLLVMContext(), B));
}
// Ensure the argument is the correct type.

View File

@ -2087,7 +2087,8 @@ void CodeGenFunction::EmitCheck(llvm::Value *Checked, StringRef CheckName,
.addAttribute(llvm::Attributes::UWTable);
llvm::Value *Fn = CGM.CreateRuntimeFunction(FnType,
("__ubsan_handle_" + CheckName).str(),
llvm::Attributes::get(B));
llvm::Attributes::get(getLLVMContext(),
B));
llvm::CallInst *HandlerCall = Builder.CreateCall(Fn, Args);
HandlerCall->setDoesNotReturn();
HandlerCall->setDoesNotThrow();

View File

@ -68,7 +68,8 @@ private:
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
params, true),
"objc_msgSend",
llvm::Attributes::get(B));
llvm::Attributes::get(CGM.getLLVMContext(),
B));
}
/// void objc_msgSend_stret (id, SEL, ...)
@ -587,7 +588,8 @@ public:
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty,
params, false),
"_setjmp",
llvm::Attributes::get(B));
llvm::Attributes::get(CGM.getLLVMContext(),
B));
}
public:

View File

@ -1634,7 +1634,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
llvm::CallInst *Result = Builder.CreateCall(IA, Args);
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoUnwind);
Result->addAttribute(~0, llvm::Attributes::get(B));
Result->addAttribute(~0, llvm::Attributes::get(getLLVMContext(), 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

@ -646,7 +646,8 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD,
if (unsigned IID = F->getIntrinsicID()) {
// If this is an intrinsic function, set the function's attributes
// to the intrinsic's attributes.
F->setAttributes(llvm::Intrinsic::getAttributes((llvm::Intrinsic::ID)IID));
F->setAttributes(llvm::Intrinsic::getAttributes(getLLVMContext(),
(llvm::Intrinsic::ID)IID));
return;
}

View File

@ -953,7 +953,8 @@ static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM,
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoUnwind);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire",
llvm::Attributes::get(B));
llvm::Attributes::get(CGM.getLLVMContext(),
B));
}
static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
@ -964,7 +965,8 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoUnwind);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release",
llvm::Attributes::get(B));
llvm::Attributes::get(CGM.getLLVMContext(),
B));
}
static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
@ -975,7 +977,8 @@ static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
llvm::Attributes::Builder B;
B.addAttribute(llvm::Attributes::NoUnwind);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort",
llvm::Attributes::get(B));
llvm::Attributes::get(CGM.getLLVMContext(),
B));
}
namespace {

View File

@ -970,7 +970,7 @@ void X86_32TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
// Now add the 'alignstack' attribute with a value of 16.
llvm::Attributes::Builder B;
B.addStackAlignmentAttr(16);
Fn->addAttribute(~0U, llvm::Attributes::get(B));
Fn->addAttribute(~0U, llvm::Attributes::get(CGM.getLLVMContext(), B));
}
}
}