diff options
author | Reid Kleckner <rnk@google.com> | 2016-04-04 23:06:05 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-04-04 23:06:05 +0000 |
commit | 7de6761561012aa726c6fd495ab55bc1a67d5e9a (patch) | |
tree | d334d6f36362fe114da06d39fe9792e655d6fb18 /llvm/unittests/IR/AttributesTest.cpp | |
parent | e77c7de45956194d4f68296e92d88d6e99f783ba (diff) | |
download | bcm5719-llvm-7de6761561012aa726c6fd495ab55bc1a67d5e9a.tar.gz bcm5719-llvm-7de6761561012aa726c6fd495ab55bc1a67d5e9a.zip |
Fix non-determinism in order of LLVM attributes
We were using array_pod_sort on an array of type 'Attribute', which
wraps a pointer to AttributeImpl. For the most part this didn't matter
because the printing code prints enum attributes in a defined order, but
integer attributes such as 'align' and 'dereferenceable' were not
ordered.
Furthermore, AttributeImpl::operator< was broken for integer attributes.
An integer attribute is a kind and an integer value, and both pieces
need to be compared.
By fixing the comparison operator, we can go back to std::sort, and
things look good now. This should fix clang arm-swiftcall.c test
failures on Windows.
llvm-svn: 265361
Diffstat (limited to 'llvm/unittests/IR/AttributesTest.cpp')
-rw-r--r-- | llvm/unittests/IR/AttributesTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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) |