aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-14 06:39:53 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-14 06:39:53 +0000
commit5886b7bfc82385dfd35b7602304c86075e1d72e6 (patch)
treeb818eb58d9335787f839a6e1757f5350185bb157
parenta19a53065fcaa6fafce902efde38fcae7b0bdea4 (diff)
Remove the bitwise NOT operator from the Attributes class. Replace it with the equivalent from the builder class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165892 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Attributes.h12
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp8
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp8
-rw-r--r--lib/VMCore/Attributes.cpp18
-rw-r--r--lib/VMCore/Core.cpp5
-rw-r--r--lib/VMCore/Function.cpp2
-rw-r--r--lib/VMCore/Instructions.cpp4
7 files changed, 35 insertions, 22 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h
index ce477c8aeb..5b614e9107 100644
--- a/include/llvm/Attributes.h
+++ b/include/llvm/Attributes.h
@@ -131,7 +131,7 @@ public:
/// a power of 2) into the form used internally in Attributes.
Builder &addStackAlignmentAttr(unsigned Align);
- void removeAttributes(const Attributes &A);
+ Builder &removeAttributes(const Attributes &A);
/// @brief Remove attributes that are used on functions only.
void removeFunctionOnlyAttrs() {
@@ -154,6 +154,13 @@ public:
.removeAttribute(Attributes::ReturnsTwice)
.removeAttribute(Attributes::AddressSafety);
}
+
+ bool operator==(const Builder &B) {
+ return Bits == B.Bits;
+ }
+ bool operator!=(const Builder &B) {
+ return Bits != B.Bits;
+ }
};
/// get - Return a uniquified Attributes object. This takes the uniquified
@@ -232,7 +239,6 @@ public:
Attributes operator ^ (const Attributes &A) const;
Attributes &operator |= (const Attributes &A);
Attributes &operator &= (const Attributes &A);
- Attributes operator ~ () const;
uint64_t Raw() const;
@@ -351,7 +357,7 @@ public:
/// removeAttr - Remove the specified attribute at the specified index from
/// this attribute list. Since attribute lists are immutable, this
/// returns the new list.
- AttrListPtr removeAttr(unsigned Idx, Attributes Attrs) const;
+ AttrListPtr removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
//===--------------------------------------------------------------------===//
// Attribute List Accessors
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index b107669b17..6b52387504 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -762,7 +762,9 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// here. Currently, this should not be possible, but special handling might be
// required when new return value attributes are added.
if (NRetTy->isVoidTy())
- RAttrs &= ~Attributes::typeIncompatible(NRetTy);
+ RAttrs =
+ Attributes::get(Attributes::Builder(RAttrs).
+ removeAttributes(Attributes::typeIncompatible(NRetTy)));
else
assert((RAttrs & Attributes::typeIncompatible(NRetTy)) == 0
&& "Return attributes no longer compatible?");
@@ -831,7 +833,9 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Attributes RAttrs = CallPAL.getRetAttributes();
Attributes FnAttrs = CallPAL.getFnAttributes();
// Adjust in case the function was changed to return void.
- RAttrs &= ~Attributes::typeIncompatible(NF->getReturnType());
+ RAttrs =
+ Attributes::get(Attributes::Builder(RAttrs).
+ removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
if (RAttrs)
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index a1b976577a..a32f35a8df 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2061,7 +2061,7 @@ static void ChangeCalleesToFastCall(Function *F) {
}
}
-static AttrListPtr StripNest(const AttrListPtr &Attrs) {
+static AttrListPtr StripNest(LLVMContext &C, const AttrListPtr &Attrs) {
Attributes::Builder B;
B.addAttribute(Attributes::Nest);
@@ -2070,19 +2070,19 @@ static AttrListPtr StripNest(const AttrListPtr &Attrs) {
continue;
// There can be only one.
- return Attrs.removeAttr(Attrs.getSlot(i).Index, Attributes::get(B));
+ return Attrs.removeAttr(C, Attrs.getSlot(i).Index, Attributes::get(B));
}
return Attrs;
}
static void RemoveNestAttribute(Function *F) {
- F->setAttributes(StripNest(F->getAttributes()));
+ F->setAttributes(StripNest(F->getContext(), F->getAttributes()));
for (Value::use_iterator UI = F->use_begin(), E = F->use_end(); UI != E;++UI){
if (isa<BlockAddress>(*UI))
continue;
CallSite User(cast<Instruction>(*UI));
- User.setAttributes(StripNest(User.getAttributes()));
+ User.setAttributes(StripNest(F->getContext(), User.getAttributes()));
}
}
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index 4f3200b002..326afc7ba9 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -110,9 +110,6 @@ Attributes &Attributes::operator &= (const Attributes &A) {
Attrs.Bits &= A.Raw();
return *this;
}
-Attributes Attributes::operator ~ () const {
- return Attributes(~Raw());
-}
uint64_t Attributes::Raw() const {
return Attrs.Bits;
@@ -242,8 +239,10 @@ removeAttribute(Attributes::AttrVal Val) {
return *this;
}
-void Attributes::Builder::removeAttributes(const Attributes &A) {
+Attributes::Builder &Attributes::Builder::
+removeAttributes(const Attributes &A) {
Bits &= ~A.Raw();
+ return *this;
}
bool Attributes::Builder::hasAttribute(Attributes::AttrVal A) const {
@@ -548,7 +547,8 @@ AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
return get(NewAttrList);
}
-AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
+AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
+ Attributes Attrs) const {
#ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment.
// For now, say we can't pass in alignment, which no current use does.
@@ -558,8 +558,9 @@ AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
if (AttrList == 0) return AttrListPtr();
Attributes OldAttrs = getAttributes(Idx);
- Attributes NewAttrs = OldAttrs & ~Attrs;
- if (NewAttrs == OldAttrs)
+ Attributes::Builder NewAttrs =
+ Attributes::Builder(OldAttrs).removeAttributes(Attrs);
+ if (NewAttrs == Attributes::Builder(OldAttrs))
return *this;
SmallVector<AttributeWithIndex, 8> NewAttrList;
@@ -572,7 +573,8 @@ AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
// If there are attributes already at this index, merge them in.
assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
- Attrs = OldAttrList[i].Attrs & ~Attrs;
+ Attrs = Attributes::get(C, Attributes::Builder(OldAttrList[i].Attrs).
+ removeAttributes(Attrs));
++i;
if (Attrs) // If any attributes left for this parameter, add them.
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 7973325e50..bafdfa3079 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1388,7 +1388,8 @@ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes();
- const AttrListPtr PALnew = PAL.removeAttr(~0U, Attributes(PA));
+ const AttrListPtr PALnew = PAL.removeAttr(Func->getContext(), ~0U,
+ Attributes(PA));
Func->setAttributes(PALnew);
}
@@ -1673,7 +1674,7 @@ void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
Call.setAttributes(
- Call.getAttributes().removeAttr(index, Attributes(PA)));
+ Call.getAttributes().removeAttr(Call->getContext(), index, Attributes(PA)));
}
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 5c2a03ce09..15e9f7cfdc 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -255,7 +255,7 @@ void Function::addAttribute(unsigned i, Attributes attr) {
void Function::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
- PAL = PAL.removeAttr(i, attr);
+ PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 74c0c6e1d9..15bc3ae1bc 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -338,7 +338,7 @@ void CallInst::addAttribute(unsigned i, Attributes attr) {
void CallInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
- PAL = PAL.removeAttr(i, attr);
+ PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}
@@ -594,7 +594,7 @@ void InvokeInst::addAttribute(unsigned i, Attributes attr) {
void InvokeInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
- PAL = PAL.removeAttr(i, attr);
+ PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}