[llvm] r261155 - Fix warning on build without asserts

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 13:35:52 PST 2016


You could just write this as:

PtrsTy->getElementType()->getPointerElementType() ==
             DataTy->getElementType()

in the assert directly, without needing the extra local/ifdef, etc.

But the other thing to note is that pointer element types will be going
away eventually (that being the point of the typeless pointer work I've
been doing (I know it's been a bit quiet on that front of late - will be
getting back to it)). So if at all possible, it'd be great if you could
minimize the use of pointer element types wherever possible. Obviously some
places need it, to decide if/where to insert bitcasts, etc, or to check
that the type checks haven't been violated.

On Wed, Feb 17, 2016 at 1:17 PM, Tim Northover via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: tnorthover
> Date: Wed Feb 17 15:16:59 2016
> New Revision: 261155
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261155&view=rev
> Log:
> Fix warning on build without asserts
>
> Modified:
>     llvm/trunk/lib/IR/IRBuilder.cpp
>
> Modified: llvm/trunk/lib/IR/IRBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/IRBuilder.cpp?rev=261155&r1=261154&r2=261155&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/IRBuilder.cpp (original)
> +++ llvm/trunk/lib/IR/IRBuilder.cpp Wed Feb 17 15:16:59 2016
> @@ -284,13 +284,14 @@ CallInst *IRBuilderBase::CreateMaskedSca
>                                               unsigned Align, Value *Mask)
> {
>    auto PtrsTy = cast<VectorType>(Ptrs->getType());
>    auto DataTy = cast<VectorType>(Data->getType());
> -
> -  auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
>    unsigned NumElts = PtrsTy->getVectorNumElements();
>
> +#ifndef NDEBUG
> +  auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
>    assert(NumElts == DataTy->getVectorNumElements() &&
> -         PtrTy->getElementType() ==  DataTy->getElementType() &&
> -        "Incompatible pointer and data types");
> +         PtrTy->getElementType() == DataTy->getElementType() &&
> +         "Incompatible pointer and data types");
> +#endif
>
>    if (!Mask)
>      Mask =
> Constant::getAllOnesValue(VectorType::get(Type::getInt1Ty(Context),
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160217/6a48d5f8/attachment.html>


More information about the llvm-commits mailing list