[Attributes] Fix crash when attempting to remove alignment from an attribute list/set
authorDaniel Neilson <dneilson@azul.com>
Wed, 17 Jan 2018 19:15:21 +0000 (19:15 +0000)
committerDaniel Neilson <dneilson@azul.com>
Wed, 17 Jan 2018 19:15:21 +0000 (19:15 +0000)
commit88dddb89483e8d21b13b6557f67ec5420ffaa7ef
treec9e4a4c4583be5113d376b6fa249648853310d44
parent8c87a2e7bd2ec23b63310b58c4b55c01105f261e
[Attributes] Fix crash when attempting to remove alignment from an attribute list/set

Summary:
 Discovered while working on a patch to move alignment in
@llvm.memcpy/move/set from an arg into parameter attributes.

 The current implementations of AttributeSet::removeAttribute() and
AttributeList::removeAttribute crash when attempting to remove the
alignment attribute. Currently, these implementations add the
to-be-removed attributes to an AttrBuilder and then remove
the builder from the list/set. Alignment is special in that it
must be added to a builder with an integer value for the alignment;
attempts to add alignment to a builder without a value is an error.

 This change fixes the removeAttribute implementations for AttributeSet and
AttributeList to make them able to remove the alignment, and other similar,
attributes.

Reviewers: rnk, chandlerc, pete, javed.absar, reames

Reviewed By: rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41951

llvm-svn: 322735
llvm/lib/IR/Attributes.cpp
llvm/unittests/IR/AttributesTest.cpp