summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/LLParser.cpp14
-rw-r--r--lib/AsmParser/LLParser.h2
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--lib/CodeGen/Analysis.cpp6
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp4
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp6
-rw-r--r--lib/Transforms/IPO/FunctionAttrs.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp2
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp2
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp6
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp4
-rw-r--r--lib/Transforms/Scalar/ObjCARC.cpp18
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp2
-rw-r--r--lib/VMCore/Attributes.cpp88
-rw-r--r--lib/VMCore/Core.cpp16
-rw-r--r--lib/VMCore/Verifier.cpp4
16 files changed, 109 insertions, 71 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 6f67e48f21..60e1741d69 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -916,7 +916,7 @@ bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace) {
/// ParseOptionalAttrs - Parse a potentially empty attribute list. AttrKind
/// indicates what kind of attribute list this is: 0: function arg, 1: result,
/// 2: function attr.
-bool LLParser::ParseOptionalAttrs(Attributes::Builder &B, unsigned AttrKind) {
+bool LLParser::ParseOptionalAttrs(AttrBuilder &B, unsigned AttrKind) {
LocTy AttrLoc = Lex.getLoc();
bool HaveError = false;
@@ -1435,7 +1435,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
// Parse the argument.
LocTy ArgLoc;
Type *ArgTy = 0;
- Attributes::Builder ArgAttrs;
+ AttrBuilder ArgAttrs;
Value *V;
if (ParseType(ArgTy, ArgLoc))
return true;
@@ -1476,7 +1476,7 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
} else {
LocTy TypeLoc = Lex.getLoc();
Type *ArgTy = 0;
- Attributes::Builder Attrs;
+ AttrBuilder Attrs;
std::string Name;
if (ParseType(ArgTy) ||
@@ -2677,7 +2677,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
unsigned Linkage;
unsigned Visibility;
- Attributes::Builder RetAttrs;
+ AttrBuilder RetAttrs;
CallingConv::ID CC;
Type *RetType = 0;
LocTy RetTypeLoc = Lex.getLoc();
@@ -2741,7 +2741,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
SmallVector<ArgInfo, 8> ArgList;
bool isVarArg;
- Attributes::Builder FuncAttrs;
+ AttrBuilder FuncAttrs;
std::string Section;
unsigned Alignment;
std::string GC;
@@ -3262,7 +3262,7 @@ bool LLParser::ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS) {
/// OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue
bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
LocTy CallLoc = Lex.getLoc();
- Attributes::Builder RetAttrs, FnAttrs;
+ AttrBuilder RetAttrs, FnAttrs;
CallingConv::ID CC;
Type *RetType = 0;
LocTy RetTypeLoc;
@@ -3667,7 +3667,7 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
/// ParameterList OptionalAttrs
bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
bool isTail) {
- Attributes::Builder RetAttrs, FnAttrs;
+ AttrBuilder RetAttrs, FnAttrs;
CallingConv::ID CC;
Type *RetType = 0;
LocTy RetTypeLoc;
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index 671eaf6429..c6bbdb27ae 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -175,7 +175,7 @@ namespace llvm {
bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
bool ParseOptionalAddrSpace(unsigned &AddrSpace);
- bool ParseOptionalAttrs(Attributes::Builder &Attrs, unsigned AttrKind);
+ bool ParseOptionalAttrs(AttrBuilder &Attrs, unsigned AttrKind);
bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage);
bool ParseOptionalLinkage(unsigned &Linkage) {
bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 756dca6d92..279343c48c 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -481,7 +481,7 @@ bool BitcodeReader::ParseAttributeBlock() {
}
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
- Attributes::Builder B(Record[i+1]);
+ AttrBuilder B(Record[i+1]);
if (B.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(Record[i],
Attributes::get(Context, B)));
diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp
index 110a294020..5162ad762e 100644
--- a/lib/CodeGen/Analysis.cpp
+++ b/lib/CodeGen/Analysis.cpp
@@ -314,8 +314,8 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr,
// the return. Ignore noalias because it doesn't affect the call sequence.
const Function *F = ExitBB->getParent();
Attributes CallerRetAttr = F->getAttributes().getRetAttributes();
- if (Attributes::Builder(CalleeRetAttr).removeAttribute(Attributes::NoAlias) !=
- Attributes::Builder(CallerRetAttr).removeAttribute(Attributes::NoAlias))
+ if (AttrBuilder(CalleeRetAttr).removeAttribute(Attributes::NoAlias) !=
+ AttrBuilder(CallerRetAttr).removeAttribute(Attributes::NoAlias))
return false;
// It's not safe to eliminate the sign / zero extension of the return value.
@@ -356,7 +356,7 @@ bool llvm::isInTailCallPosition(SelectionDAG &DAG, SDNode *Node,
// Conservatively require the attributes of the call to match those of
// the return. Ignore noalias because it doesn't affect the call sequence.
Attributes CallerRetAttr = F->getAttributes().getRetAttributes();
- if (Attributes::Builder(CallerRetAttr)
+ if (AttrBuilder(CallerRetAttr)
.removeAttribute(Attributes::NoAlias).hasAttributes())
return false;
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 5b17a0f927..969afe56e9 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -474,9 +474,9 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
Out << "AttributeWithIndex PAWI;"; nl(Out);
for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
unsigned index = PAL.getSlot(i).Index;
- Attributes::Builder attrs(PAL.getSlot(i).Attrs);
+ AttrBuilder attrs(PAL.getSlot(i).Attrs);
Out << "PAWI.Index = " << index << "U;\n";
- Out << " Attributes::Builder B;\n";
+ Out << " AttrBuilder B;\n";
#define HANDLE_ATTR(X) \
if (attrs.hasAttribute(Attributes::X)) \
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index a7ff182dac..fc22548db7 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -765,10 +765,10 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// required when new return value attributes are added.
if (NRetTy->isVoidTy())
RAttrs =
- Attributes::get(NRetTy->getContext(), Attributes::Builder(RAttrs).
+ Attributes::get(NRetTy->getContext(), AttrBuilder(RAttrs).
removeAttributes(Attributes::typeIncompatible(NRetTy)));
else
- assert(!Attributes::Builder(RAttrs).
+ assert(!AttrBuilder(RAttrs).
hasAttributes(Attributes::typeIncompatible(NRetTy)) &&
"Return attributes no longer compatible?");
@@ -840,7 +840,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Attributes FnAttrs = CallPAL.getFnAttributes();
// Adjust in case the function was changed to return void.
RAttrs =
- Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
+ Attributes::get(NF->getContext(), AttrBuilder(RAttrs).
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index 9fe42f074a..d8f374c330 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -212,7 +212,7 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
MadeChange = true;
// Clear out any existing attributes.
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::ReadOnly)
.addAttribute(Attributes::ReadNone);
F->removeAttribute(AttrListPtr::FunctionIndex,
@@ -357,7 +357,7 @@ bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
ArgumentGraph AG;
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoCapture);
// Check each function in turn, determining which pointer arguments are not
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index d4eeafa859..6468ff3276 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2062,7 +2062,7 @@ static void ChangeCalleesToFastCall(Function *F) {
}
static AttrListPtr StripNest(LLVMContext &C, const AttrListPtr &Attrs) {
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::Nest);
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index b5252aac84..fb4ecbfe7b 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -137,7 +137,7 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
// If the SCC doesn't unwind or doesn't throw, note this fact.
if (!SCCMightUnwind || !SCCMightReturn)
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
- Attributes::Builder NewAttributes;
+ AttrBuilder NewAttributes;
if (!SCCMightUnwind)
NewAttributes.addAttribute(Attributes::NoUnwind);
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 44ddf3be34..5ad6f9111c 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1007,7 +1007,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false; // Cannot transform this return value.
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
- Attributes::Builder RAttrs = CallerPAL.getRetAttributes();
+ AttrBuilder RAttrs = CallerPAL.getRetAttributes();
if (RAttrs.hasAttributes(Attributes::typeIncompatible(NewRetTy)))
return false; // Attribute not compatible with transformed value.
}
@@ -1038,7 +1038,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false; // Cannot transform this parameter value.
Attributes Attrs = CallerPAL.getParamAttributes(i + 1);
- if (Attributes::Builder(Attrs).
+ if (AttrBuilder(Attrs).
hasAttributes(Attributes::typeIncompatible(ParamTy)))
return false; // Attribute not compatible with transformed value.
@@ -1109,7 +1109,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
attrVec.reserve(NumCommonArgs);
// Get any return attributes.
- Attributes::Builder RAttrs = CallerPAL.getRetAttributes();
+ AttrBuilder RAttrs = CallerPAL.getRetAttributes();
// If the return value is not being used, the type may not be compatible
// with the existing attributes. Wipe out any problematic attributes.
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 665d5b0171..4d8176bc6c 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -774,9 +774,9 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
// Conservatively require the attributes of the call to match those of the
// return. Ignore noalias because it doesn't affect the call sequence.
Attributes CalleeRetAttr = CS.getAttributes().getRetAttributes();
- if (Attributes::Builder(CalleeRetAttr).
+ if (AttrBuilder(CalleeRetAttr).
removeAttribute(Attributes::NoAlias) !=
- Attributes::Builder(CallerRetAttr).
+ AttrBuilder(CallerRetAttr).
removeAttribute(Attributes::NoAlias))
continue;
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp
index 017df8f1a4..e18208d4a5 100644
--- a/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/lib/Transforms/Scalar/ObjCARC.cpp
@@ -1788,7 +1788,7 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -1806,7 +1806,7 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -1822,7 +1822,7 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) {
if (!ReleaseCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -1840,7 +1840,7 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) {
if (!RetainCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -1873,7 +1873,7 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) {
if (!AutoreleaseCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -3850,9 +3850,9 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) {
Type *I8XX = PointerType::getUnqual(I8X);
Type *Params[] = { I8XX, I8X };
- Attributes::Builder BNoUnwind;
+ AttrBuilder BNoUnwind;
BNoUnwind.addAttribute(Attributes::NoUnwind);
- Attributes::Builder BNoCapture;
+ AttrBuilder BNoCapture;
BNoCapture.addAttribute(Attributes::NoCapture);
AttrListPtr Attributes = AttrListPtr()
.addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -3874,7 +3874,7 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
@@ -3891,7 +3891,7 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoUnwind);
AttrListPtr Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index e751750986..0223d39ab3 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -348,7 +348,7 @@ struct StrToOpt : public LibCallOptimization {
if (isa<ConstantPointerNull>(EndPtr)) {
// With a null EndPtr, this function won't capture the main argument.
// It would be readonly too, except that it still may write to errno.
- Attributes::Builder B;
+ AttrBuilder B;
B.addAttribute(Attributes::NoCapture);
CI->addAttribute(1, Attributes::get(Callee->getContext(), B));
}
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index e81bf3c83a..cfa276ebd6 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -33,14 +33,14 @@ Attributes::Attributes(AttributesImpl *A) : Attrs(A) {}
Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
Attributes Attributes::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
- Attributes::Builder B;
+ AttrBuilder B;
for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end();
I != E; ++I)
B.addAttribute(*I);
return Attributes::get(Context, B);
}
-Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
+Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) {
// If there are no attributes, return an empty Attributes class.
if (B.Bits == 0)
return Attributes();
@@ -96,7 +96,7 @@ uint64_t Attributes::Raw() const {
}
Attributes Attributes::typeIncompatible(Type *Ty) {
- Attributes::Builder Incompatible;
+ AttrBuilder Incompatible;
if (!Ty->isIntegerTy())
// Attributes that only apply to integers.
@@ -114,6 +114,44 @@ Attributes Attributes::typeIncompatible(Type *Ty) {
return Attributes::get(Ty->getContext(), Incompatible);
}
+/// encodeLLVMAttributesForBitcode - This returns an integer containing an
+/// encoding of all the LLVM attributes found in the given attribute bitset.
+/// Any change to this encoding is a breaking change to bitcode compatibility.
+uint64_t Attributes::encodeLLVMAttributesForBitcode(Attributes Attrs) {
+ // FIXME: It doesn't make sense to store the alignment information as an
+ // expanded out value, we should store it as a log2 value. However, we can't
+ // just change that here without breaking bitcode compatibility. If this ever
+ // becomes a problem in practice, we should introduce new tag numbers in the
+ // bitcode file and have those tags use a more efficiently encoded alignment
+ // field.
+
+ // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
+ // log2 encoded value. Shift the bits above the alignment up by 11 bits.
+ uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
+ if (Attrs.hasAttribute(Attributes::Alignment))
+ EncodedAttrs |= Attrs.getAlignment() << 16;
+ EncodedAttrs |= (Attrs.Raw() & (0xfffULL << 21)) << 11;
+ return EncodedAttrs;
+}
+
+/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
+/// the LLVM attributes that have been decoded from the given integer. This
+/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
+Attributes Attributes::decodeLLVMAttributesForBitcode(LLVMContext &C,
+ uint64_t EncodedAttrs) {
+ // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
+ // the bits above 31 down by 11 bits.
+ unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
+ assert((!Alignment || isPowerOf2_32(Alignment)) &&
+ "Alignment must be a power of two.");
+
+ AttrBuilder B(EncodedAttrs & 0xffff);
+ if (Alignment)
+ B.addAlignmentAttr(Alignment);
+ B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
+ return Attributes::get(C, B);
+}
+
std::string Attributes::getAsString() const {
std::string Result;
if (hasAttribute(Attributes::ZExt))
@@ -183,27 +221,27 @@ std::string Attributes::getAsString() const {
}
//===----------------------------------------------------------------------===//
-// Attributes::Builder Implementation
+// AttrBuilder Implementation
//===----------------------------------------------------------------------===//
-Attributes::Builder &Attributes::Builder::addAttribute(Attributes::AttrVal Val){
+AttrBuilder &AttrBuilder::addAttribute(Attributes::AttrVal Val){
Bits |= AttributesImpl::getAttrMask(Val);
return *this;
}
-Attributes::Builder &Attributes::Builder::addRawValue(uint64_t Val) {
+AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
Bits |= Val;
return *this;
}
-Attributes::Builder &Attributes::Builder::addAlignmentAttr(unsigned Align) {
+AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
if (Align == 0) return *this;
assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
assert(Align <= 0x40000000 && "Alignment too large.");
Bits |= (Log2_32(Align) + 1) << 16;
return *this;
}
-Attributes::Builder &Attributes::Builder::addStackAlignmentAttr(unsigned Align){
+AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
// Default alignment, allow the target to define how to align it.
if (Align == 0) return *this;
assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
@@ -212,44 +250,44 @@ Attributes::Builder &Attributes::Builder::addStackAlignmentAttr(unsigned Align){
return *this;
}
-Attributes::Builder &Attributes::Builder::
+AttrBuilder &AttrBuilder::
removeAttribute(Attributes::AttrVal Val) {
Bits &= ~AttributesImpl::getAttrMask(Val);
return *this;
}
-Attributes::Builder &Attributes::Builder::addAttributes(const Attributes &A) {
+AttrBuilder &AttrBuilder::addAttributes(const Attributes &A) {
Bits |= A.Raw();
return *this;
}
-Attributes::Builder &Attributes::Builder::removeAttributes(const Attributes &A){
+AttrBuilder &AttrBuilder::removeAttributes(const Attributes &A){
Bits &= ~A.Raw();
return *this;
}
-bool Attributes::Builder::hasAttribute(Attributes::AttrVal A) const {
+bool AttrBuilder::hasAttribute(Attributes::AttrVal A) const {
return Bits & AttributesImpl::getAttrMask(A);
}
-bool Attributes::Builder::hasAttributes() const {
+bool AttrBuilder::hasAttributes() const {
return Bits != 0;
}
-bool Attributes::Builder::hasAttributes(const Attributes &A) const {
+bool AttrBuilder::hasAttributes(const Attributes &A) const {
return Bits & A.Raw();
}
-bool Attributes::Builder::hasAlignmentAttr() const {
+bool AttrBuilder::hasAlignmentAttr() const {
return Bits & AttributesImpl::getAttrMask(Attributes::Alignment);
}
-uint64_t Attributes::Builder::getAlignment() const {
+uint64_t AttrBuilder::getAlignment() const {
if (!hasAlignmentAttr())
return 0;
return 1U <<
(((Bits & AttributesImpl::getAttrMask(Attributes::Alignment)) >> 16) - 1);
}
-uint64_t Attributes::Builder::getStackAlignment() const {
+uint64_t AttrBuilder::getStackAlignment() const {
if (!hasAlignmentAttr())
return 0;
return 1U <<
@@ -497,9 +535,9 @@ AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx,
"Attempt to change alignment!");
#endif
- Attributes::Builder NewAttrs =
- Attributes::Builder(OldAttrs).addAttributes(Attrs);
- if (NewAttrs == Attributes::Builder(OldAttrs))
+ AttrBuilder NewAttrs =
+ AttrBuilder(OldAttrs).addAttributes(Attrs);
+ if (NewAttrs == AttrBuilder(OldAttrs))
return *this;
SmallVector<AttributeWithIndex, 8> NewAttrList;
@@ -515,7 +553,7 @@ AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx,
// If there are attributes already at this index, merge them in.
if (i != e && OldAttrList[i].Index == Idx) {
Attrs =
- Attributes::get(C, Attributes::Builder(Attrs).
+ Attributes::get(C, AttrBuilder(Attrs).
addAttributes(OldAttrList[i].Attrs));
++i;
}
@@ -541,9 +579,9 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
if (AttrList == 0) return AttrListPtr();
Attributes OldAttrs = getAttributes(Idx);
- Attributes::Builder NewAttrs =
- Attributes::Builder(OldAttrs).removeAttributes(Attrs);
- if (NewAttrs == Attributes::Builder(OldAttrs))
+ AttrBuilder NewAttrs =
+ AttrBuilder(OldAttrs).removeAttributes(Attrs);
+ if (NewAttrs == AttrBuilder(OldAttrs))
return *this;
SmallVector<AttributeWithIndex, 8> NewAttrList;
@@ -556,7 +594,7 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
// If there are attributes already at this index, merge them in.
assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
- Attrs = Attributes::get(C, Attributes::Builder(OldAttrList[i].Attrs).
+ Attrs = Attributes::get(C, AttrBuilder(OldAttrList[i].Attrs).
removeAttributes(Attrs));
++i;
if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 9eb7e10840..847bc134dd 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1381,7 +1381,7 @@ void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes();
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
const AttrListPtr PALnew =
PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex,
Attributes::get(Func->getContext(), B));
@@ -1391,7 +1391,7 @@ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes();
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
const AttrListPtr PALnew =
PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex,
Attributes::get(Func->getContext(), B));
@@ -1465,13 +1465,13 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
A->addAttr(Attributes::get(A->getContext(), B));
}
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
A->removeAttr(Attributes::get(A->getContext(), B));
}
@@ -1484,7 +1484,7 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
- Attributes::Builder B;
+ AttrBuilder B;
B.addAlignmentAttr(align);
unwrap<Argument>(Arg)->addAttr(Attributes::
get(unwrap<Argument>(Arg)->getContext(), B));
@@ -1676,7 +1676,7 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().addAttr(Call->getContext(), index,
Attributes::get(Call->getContext(), B)));
@@ -1685,7 +1685,7 @@ void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B(PA);
+ AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().removeAttr(Call->getContext(), index,
Attributes::get(Call->getContext(), B)));
@@ -1694,7 +1694,7 @@ void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
unsigned align) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
- Attributes::Builder B;
+ AttrBuilder B;
B.addAlignmentAttr(align);
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
Attributes::get(Call->getContext(), B)));
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index da1a452d3e..fd629b485a 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -567,7 +567,7 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty,
Attrs.hasAttribute(Attributes::AlwaysInline)), "Attributes "
"'noinline and alwaysinline' are incompatible!", V);
- Assert1(!Attributes::Builder(Attrs).
+ Assert1(!AttrBuilder(Attrs).
hasAttributes(Attributes::typeIncompatible(Ty)),
"Wrong types for attribute: " +
Attributes::typeIncompatible(Ty).getAsString(), V);
@@ -615,7 +615,7 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
}
Attributes FAttrs = Attrs.getFnAttributes();
- Attributes::Builder NotFn(FAttrs);
+ AttrBuilder NotFn(FAttrs);
NotFn.removeFunctionOnlyAttrs();
Assert1(!NotFn.hasAttributes(), "Attributes '" +
Attributes::get(V->getContext(), NotFn).getAsString() +