1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[IR] Short-circuit comparison with itself for Attributes

Differential Revision: https://reviews.llvm.org/D82295
This commit is contained in:
Danila Malyutin 2020-06-23 14:43:02 +03:00
parent 946c375671
commit 7b9fb1bdf8
2 changed files with 3 additions and 0 deletions

View File

@ -597,6 +597,8 @@ Type *AttributeImpl::getValueAsType() const {
}
bool AttributeImpl::operator<(const AttributeImpl &AI) const {
if (this == &AI)
return false;
// This sorts the attributes with Attribute::AttrKinds coming first (sorted
// relative to their enum value) and then strings.
if (isEnumAttribute()) {

View File

@ -44,6 +44,7 @@ TEST(Attributes, Ordering) {
Attribute ByVal = Attribute::get(C, Attribute::ByVal, Type::getInt32Ty(C));
EXPECT_FALSE(ByVal < Attribute::get(C, Attribute::ZExt));
EXPECT_TRUE(ByVal < Align4);
EXPECT_FALSE(ByVal < ByVal);
AttributeList ASs[] = {AttributeList::get(C, 2, Attribute::ZExt),
AttributeList::get(C, 1, Attribute::SExt)};