[PATCH] D82295: [IR] Short-circuit comparison with itself for Attributes
Danila Malyutin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 04:45:10 PDT 2020
danilaml updated this revision to Diff 272677.
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.272677.patch
Type: text/x-patch
Size: 1010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200623/9a7d8f3d/attachment-0001.bin>
More information about the llvm-commits
mailing list