diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-04-28 23:01:32 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-04-28 23:01:32 +0000 |
commit | 0f88d863b477afef36f02fd11a96abd9eb5563a5 (patch) | |
tree | 564f3c06fa76fd25d150342cb55ba3f8785e5421 /llvm/lib/IR | |
parent | e0f9e984fd7e6c02016b16eb355e788a645091ee (diff) | |
download | bcm5719-llvm-0f88d863b477afef36f02fd11a96abd9eb5563a5.tar.gz bcm5719-llvm-0f88d863b477afef36f02fd11a96abd9eb5563a5.zip |
Revert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This broke the Clang build. (Clang-side patch missing?)
Original commit message:
> [IR] Make add/remove Attributes use AttrBuilder instead of
> AttributeList
>
> This change cleans up call sites and avoids creating temporary
> AttributeList objects.
>
> NFC
llvm-svn: 301712
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 43 | ||||
-rw-r--r-- | llvm/lib/IR/Function.cpp | 4 |
2 files changed, 28 insertions, 19 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 3d08ecdd484..62f127bd02e 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -936,9 +936,7 @@ AttributeList AttributeList::get(LLVMContext &C, AttributeList AttributeList::addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const { if (hasAttribute(Index, Kind)) return *this; - AttrBuilder B; - B.addAttribute(Kind); - return addAttributes(C, Index, B); + return addAttributes(C, Index, AttributeList::get(C, Index, Kind)); } AttributeList AttributeList::addAttribute(LLVMContext &C, unsigned Index, @@ -946,7 +944,7 @@ AttributeList AttributeList::addAttribute(LLVMContext &C, unsigned Index, StringRef Value) const { AttrBuilder B; B.addAttribute(Kind, Value); - return addAttributes(C, Index, B); + return addAttributes(C, Index, AttributeList::get(C, Index, B)); } AttributeList AttributeList::addAttribute(LLVMContext &C, @@ -980,6 +978,14 @@ AttributeList AttributeList::addAttribute(LLVMContext &C, } AttributeList AttributeList::addAttributes(LLVMContext &C, unsigned Index, + AttributeList Attrs) const { + if (!pImpl) return Attrs; + if (!Attrs.pImpl) return *this; + + return addAttributes(C, Index, Attrs.getAttributes(Index)); +} + +AttributeList AttributeList::addAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &B) const { if (!B.hasAttributes()) return *this; @@ -1028,17 +1034,18 @@ AttributeList AttributeList::addAttributes(LLVMContext &C, unsigned Index, AttributeList AttributeList::removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const { if (!hasAttribute(Index, Kind)) return *this; - AttrBuilder B; - B.addAttribute(Kind); - return removeAttributes(C, Index, B); + return removeAttributes(C, Index, AttributeList::get(C, Index, Kind)); } AttributeList AttributeList::removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const { if (!hasAttribute(Index, Kind)) return *this; - AttrBuilder B; - B.addAttribute(Kind); - return removeAttributes(C, Index, B); + return removeAttributes(C, Index, AttributeList::get(C, Index, Kind)); +} + +AttributeList AttributeList::removeAttributes(LLVMContext &C, unsigned Index, + AttributeList Attrs) const { + return removeAttributes(C, Index, AttrBuilder(Attrs.getAttributes(Index))); } AttributeList AttributeList::removeAttributes(LLVMContext &C, unsigned Index, @@ -1096,7 +1103,7 @@ AttributeList AttributeList::addDereferenceableAttr(LLVMContext &C, uint64_t Bytes) const { AttrBuilder B; B.addDereferenceableAttr(Bytes); - return addAttributes(C, Index, B); + return addAttributes(C, Index, AttributeList::get(C, Index, B)); } AttributeList @@ -1104,7 +1111,7 @@ AttributeList::addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const { AttrBuilder B; B.addDereferenceableOrNullAttr(Bytes); - return addAttributes(C, Index, B); + return addAttributes(C, Index, AttributeList::get(C, Index, B)); } AttributeList @@ -1113,7 +1120,7 @@ AttributeList::addAllocSizeAttr(LLVMContext &C, unsigned Index, const Optional<unsigned> &NumElemsArg) { AttrBuilder B; B.addAllocSizeAttr(ElemSizeArg, NumElemsArg); - return addAttributes(C, Index, B); + return addAttributes(C, Index, AttributeList::get(C, Index, B)); } //===----------------------------------------------------------------------===// @@ -1603,10 +1610,12 @@ static void adjustCallerSSPLevel(Function &Caller, const Function &Callee) { // If upgrading the SSP attribute, clear out the old SSP Attributes first. // Having multiple SSP attributes doesn't actually hurt, but it adds useless // clutter to the IR. - AttrBuilder OldSSPAttr; - OldSSPAttr.addAttribute(Attribute::StackProtect) - .addAttribute(Attribute::StackProtectStrong) - .addAttribute(Attribute::StackProtectReq); + AttrBuilder B; + B.addAttribute(Attribute::StackProtect) + .addAttribute(Attribute::StackProtectStrong) + .addAttribute(Attribute::StackProtectReq); + AttributeList OldSSPAttr = + AttributeList::get(Caller.getContext(), AttributeList::FunctionIndex, B); if (Callee.hasFnAttribute(Attribute::StackProtectReq)) { Caller.removeAttributes(AttributeList::FunctionIndex, OldSSPAttr); diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 7b0838c41ab..fc61ba7439b 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -328,7 +328,7 @@ void Function::addAttribute(unsigned i, Attribute Attr) { setAttributes(PAL); } -void Function::addAttributes(unsigned i, const AttrBuilder &Attrs) { +void Function::addAttributes(unsigned i, AttributeList Attrs) { AttributeList PAL = getAttributes(); PAL = PAL.addAttributes(getContext(), i, Attrs); setAttributes(PAL); @@ -346,7 +346,7 @@ void Function::removeAttribute(unsigned i, StringRef Kind) { setAttributes(PAL); } -void Function::removeAttributes(unsigned i, const AttrBuilder &Attrs) { +void Function::removeAttributes(unsigned i, AttributeList Attrs) { AttributeList PAL = getAttributes(); PAL = PAL.removeAttributes(getContext(), i, Attrs); setAttributes(PAL); |