[llvm] r175684 - Add and remove the attribute from the correct slot.

Joey Gouly joey.gouly at arm.com
Thu Feb 21 09:56:08 PST 2013


See down for some comments.
> Author: void
> Date: Wed Feb 20 17:04:11 2013
> New Revision: 175684
>
> URL: http://llvm.org/viewvc/llvm-project?rev=175684&view=rev
> Log:
> Add and remove the attribute from the correct slot.
>
> The slot that we're adding/removing the attribute from may not be the same
as
> the attribute coming in. Make sure that they match up before we try to
> add/remove them.
> PR15313
>
> Modified:
>    llvm/trunk/lib/IR/Function.cpp
>
> Modified: llvm/trunk/lib/IR/Function.cpp
> URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=17568
4&r1=175683&r2=175684&view=diff
>
============================================================================
==
> --- llvm/trunk/lib/IR/Function.cpp (original)
> +++ llvm/trunk/lib/IR/Function.cpp Wed Feb 20 17:04:11 2013
> @@ -125,12 +125,22 @@ bool Argument::hasStructRetAttr() const
> 
>  /// addAttr - Add attributes to an argument.
>  void Argument::addAttr(AttributeSet AS) {
> -  getParent()->addAttributes(getArgNo() + 1, AS);
> +  assert(AS.getNumSlots() == 1 &&
> +         "Trying to add more than one attribute set to an argument!");

I think this assert is wrong, it should be 0 or 1. Now it fails for
Arguments with no attributes.

> +  AttrBuilder B(AS, AS.getSlotIndex(0));
> +  getParent()->addAttributes(getArgNo() + 1,
> +                             AttributeSet::get(Parent->getContext(),
> +                                               getArgNo() + 1, B));
>  }
> 
>  /// removeAttr - Remove attributes from an argument.> 
>  void Argument::removeAttr(AttributeSet AS) {
> -  getParent()->removeAttributes(getArgNo() + 1, AS);
> +  assert(AS.getNumSlots() == 1 &&
> +         "Trying to remove more than one attribute set from an
argument!");

Possible the same here.

> +  AttrBuilder B(AS, AS.getSlotIndex(0));> 
> +  getParent()->removeAttributes(getArgNo() + 1,
> +                                AttributeSet::get(Parent->getContext(),
> +                                                  getArgNo() + 1, B));
>  }
> 
>
//===----------------------------------------------------------------------=
==//







More information about the llvm-commits mailing list