diff options
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 8 | ||||
-rw-r--r-- | llvm/unittests/IR/AttributesTest.cpp | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index b8c03def70e..19664f77eae 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -389,7 +389,11 @@ bool AttributeImpl::operator<(const AttributeImpl &AI) const { if (isIntAttribute()) { if (AI.isEnumAttribute()) return false; - if (AI.isIntAttribute()) return getValueAsInt() < AI.getValueAsInt(); + if (AI.isIntAttribute()) { + if (getKindAsEnum() == AI.getKindAsEnum()) + return getValueAsInt() < AI.getValueAsInt(); + return getKindAsEnum() < AI.getKindAsEnum(); + } if (AI.isStringAttribute()) return true; } @@ -482,7 +486,7 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C, FoldingSetNodeID ID; SmallVector<Attribute, 8> SortedAttrs(Attrs.begin(), Attrs.end()); - array_pod_sort(SortedAttrs.begin(), SortedAttrs.end()); + std::sort(SortedAttrs.begin(), SortedAttrs.end()); for (Attribute Attr : SortedAttrs) Attr.Profile(ID); diff --git a/llvm/unittests/IR/AttributesTest.cpp b/llvm/unittests/IR/AttributesTest.cpp index ebcb772bc37..9f8013ff181 100644 --- a/llvm/unittests/IR/AttributesTest.cpp +++ b/llvm/unittests/IR/AttributesTest.cpp @@ -34,6 +34,15 @@ TEST(Attributes, Uniquing) { TEST(Attributes, Ordering) { LLVMContext C; + Attribute Align4 = Attribute::get(C, Attribute::Alignment, 4); + Attribute Align5 = Attribute::get(C, Attribute::Alignment, 5); + Attribute Deref4 = Attribute::get(C, Attribute::Dereferenceable, 4); + Attribute Deref5 = Attribute::get(C, Attribute::Dereferenceable, 5); + EXPECT_TRUE(Align4 < Align5); + EXPECT_TRUE(Align4 < Deref4); + EXPECT_TRUE(Align4 < Deref5); + EXPECT_TRUE(Align5 < Deref4); + AttributeSet ASs[] = { AttributeSet::get(C, 2, Attribute::ZExt), AttributeSet::get(C, 1, Attribute::SExt) |