[PATCH] Bug 15391: Fix rejecting valid int / ptr vector attributes

Eli Friedman eli.friedman at gmail.com
Wed Sep 4 13:57:33 PDT 2013


On Wed, Sep 4, 2013 at 1:37 PM, Matt Arsenault <Matthew.Arsenault at amd.com>wrote:

>   Don't accept sret or nest for vectors of pointers. Update LangRef to
> mention vectors.
>
>   I'm not sure about nest, and I'm not sure about noalias. Are the
> pointers within the vector allowed to alias another in the vector?
>

Nest shouldn't allow vectors of pointers.

As for noalias, I'd suggest posting to llvmdev.

-Eli


>
> http://llvm-reviews.chandlerc.com/D1561
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D1561?vs=3933&id=4043#toc
>
> Files:
>   docs/LangRef.rst
>   lib/IR/Attributes.cpp
>   test/Verifier/vector-type-attributes.ll
>
> Index: docs/LangRef.rst
> ===================================================================
> --- docs/LangRef.rst
> +++ docs/LangRef.rst
> @@ -661,14 +661,16 @@
>
>  ``zeroext``
>      This indicates to the code generator that the parameter or return
> -    value should be zero-extended to the extent required by the target's
> -    ABI (which is usually 32-bits, but is 8-bits for a i1 on x86-64) by
> -    the caller (for a parameter) or the callee (for a return value).
> +    value should be zero-extended to the extent required by the
> +    target's ABI (which is usually 32-bits, but is 8-bits for a i1 on
> +    x86-64) by the caller (for a parameter) or the callee (for a
> +    return value). When applied to a vector, this is per-component.
>  ``signext``
>      This indicates to the code generator that the parameter or return
>      value should be sign-extended to the extent required by the target's
>      ABI (which is usually 32-bits) by the caller (for a parameter) or
> -    the callee (for a return value).
> +    the callee (for a return value). When applied to a vector, this is
> +    per-component.
>  ``inreg``
>      This indicates that this parameter or return value should be treated
>      in a special target-dependent fashion during while emitting code for
> @@ -701,7 +703,7 @@
>      loads and stores to the structure may be assumed by the callee
>      not to trap and to be properly aligned. This may only be applied to
>      the first parameter. This is not a valid attribute for return
> -    values.
> +    values, or for vectors of pointers.
>  ``noalias``
>      This indicates that pointer values :ref:`based <pointeraliasing>` on
>      the argument or return value do not alias pointer values which are
> @@ -722,15 +724,17 @@
>      while LLVM's ``noalias`` is.
>  ``nocapture``
>      This indicates that the callee does not make any copies of the
> -    pointer that outlive the callee itself. This is not a valid
> -    attribute for return values.
> +    pointer (or pointers in the case of a vector of pointers) that
> +    outlive the callee itself. This is not a valid attribute for
> +    return values.
>
>  .. _nest:
>
>  ``nest``
>      This indicates that the pointer parameter can be excised using the
>      :ref:`trampoline intrinsics <int_trampoline>`. This is not a valid
> -    attribute for return values and can only be applied to one parameter.
> +    attribute for return values and can only be applied to one
> +    parameter that is not a vector.
>
>  ``returned``
>      This indicates that the function always returns the argument as its
> return
> Index: lib/IR/Attributes.cpp
> ===================================================================
> --- lib/IR/Attributes.cpp
> +++ lib/IR/Attributes.cpp
> @@ -1157,20 +1157,26 @@
>  AttributeSet AttributeFuncs::typeIncompatible(Type *Ty, uint64_t Index) {
>    AttrBuilder Incompatible;
>
> -  if (!Ty->isIntegerTy())
> -    // Attribute that only apply to integers.
> +  if (!Ty->isIntOrIntVectorTy()) {
> +    // Attributes that only apply to integers.
>      Incompatible.addAttribute(Attribute::SExt)
>        .addAttribute(Attribute::ZExt);
> +  }
>
> -  if (!Ty->isPointerTy())
> -    // Attribute that only apply to pointers.
> +  if (!Ty->isPtrOrPtrVectorTy()) {
> +    // Attributes that only apply to pointers.
>      Incompatible.addAttribute(Attribute::ByVal)
> -      .addAttribute(Attribute::Nest)
>        .addAttribute(Attribute::NoAlias)
>        .addAttribute(Attribute::NoCapture)
>        .addAttribute(Attribute::ReadNone)
> -      .addAttribute(Attribute::ReadOnly)
> -      .addAttribute(Attribute::StructRet);
> +      .addAttribute(Attribute::ReadOnly);
> +
> +    if (Ty->isVectorTy()) {
> +      // Attributes that don't make sense for a vector of pointers
> +      Incompatible.addAttribute(Attribute::Nest)
> +        .addAttribute(Attribute::StructRet);
> +    }
> +  }
>
>    return AttributeSet::get(Ty->getContext(), Index, Incompatible);
>  }
> Index: test/Verifier/vector-type-attributes.ll
> ===================================================================
> --- /dev/null
> +++ test/Verifier/vector-type-attributes.ll
> @@ -0,0 +1,14 @@
> +; RUN: llvm-as -disable-output %s
> +; Bug 15391: valid signext attribute rejected for integer vector
> +
> +define <4 x i32> @sext_vector_param(<4 x i1> signext %mask, <4 x float>
> %a, <4 x float> %b) {
> +  ret <4 x i32> undef
> +}
> +
> +define <4 x i32> @zext_vector_param(<4 x i1> zeroext %mask) {
> +  ret <4 x i32> undef
> +}
> +
> +define <4 x i8*> @noalias_vector_param(<4 x i8*> noalias %mask) {
> +  ret <4 x i8*> undef
> +}
> \ No newline at end of file
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130904/15df749a/attachment.html>


More information about the llvm-commits mailing list