[llvm-commits] [llvm] r165892 - in /llvm/trunk: include/llvm/Attributes.h lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/VMCore/Attributes.cpp lib/VMCore/Core.cpp lib/VMCore/Function.cpp lib/VMCore/Instructions.cpp
Bill Wendling
isanbard at gmail.com
Sat Oct 13 23:39:53 PDT 2012
Author: void
Date: Sun Oct 14 01:39:53 2012
New Revision: 165892
URL: http://llvm.org/viewvc/llvm-project?rev=165892&view=rev
Log:
Remove the bitwise NOT operator from the Attributes class. Replace it with the equivalent from the builder class.
Modified:
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/VMCore/Attributes.cpp
llvm/trunk/lib/VMCore/Core.cpp
llvm/trunk/lib/VMCore/Function.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Sun Oct 14 01:39:53 2012
@@ -131,7 +131,7 @@
/// 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 @@
.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 @@
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 @@
/// 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
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Sun Oct 14 01:39:53 2012
@@ -762,7 +762,9 @@
// 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 @@
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));
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Sun Oct 14 01:39:53 2012
@@ -2061,7 +2061,7 @@
}
}
-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 @@
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()));
}
}
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Sun Oct 14 01:39:53 2012
@@ -110,9 +110,6 @@
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 @@
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 @@
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 @@
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 @@
// 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));
Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Sun Oct 14 01:39:53 2012
@@ -1388,7 +1388,8 @@
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 @@
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,
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Sun Oct 14 01:39:53 2012
@@ -255,7 +255,7 @@
void Function::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
- PAL = PAL.removeAttr(i, attr);
+ PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=165892&r1=165891&r2=165892&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Sun Oct 14 01:39:53 2012
@@ -338,7 +338,7 @@
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::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
- PAL = PAL.removeAttr(i, attr);
+ PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}
More information about the llvm-commits
mailing list