[PATCH] D82295: [IR] Short-circuit comparison with itself for Attributes
Danila Malyutin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 06:26:19 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38909f31bd08: [IR] Short-circuit comparison with itself for Attributes (authored by danilaml).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82295/new/
https://reviews.llvm.org/D82295
Files:
llvm/lib/IR/Attributes.cpp
llvm/unittests/IR/AttributesTest.cpp
Index: llvm/unittests/IR/AttributesTest.cpp
===================================================================
--- llvm/unittests/IR/AttributesTest.cpp
+++ llvm/unittests/IR/AttributesTest.cpp
@@ -44,6 +44,7 @@
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)};
Index: llvm/lib/IR/Attributes.cpp
===================================================================
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -597,6 +597,8 @@
}
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()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82295.275380.patch
Type: text/x-patch
Size: 1010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200703/e55385ee/attachment.bin>
More information about the llvm-commits
mailing list