OSDN Git Service

Fix non-determinism in order of LLVM attributes
authorReid Kleckner <rnk@google.com>
Mon, 4 Apr 2016 23:06:05 +0000 (23:06 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 4 Apr 2016 23:06:05 +0000 (23:06 +0000)
commit3918651b8971ba234600e5bfe6cb0e1d0f1c8116
tree72cf9093faafb0b1ad8cea07058b712743ce5483
parent287028499fb4d9f54648bc80b8331e9ad3febf90
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265361 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/Attributes.cpp
unittests/IR/AttributesTest.cpp