[llvm] r224751 - Fix UBSan bootstrap: don't bind reference to nullptr.

David Blaikie dblaikie at gmail.com
Mon Dec 22 23:56:12 PST 2014


On Mon, Dec 22, 2014 at 8:15 PM, Alexey Samsonov <vonosmas at gmail.com> wrote:

> Author: samsonov
> Date: Mon Dec 22 22:15:47 2014
> New Revision: 224751
>
> URL: http://llvm.org/viewvc/llvm-project?rev=224751&view=rev
> Log:
> Fix UBSan bootstrap: don't bind reference to nullptr.
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h?rev=224751&r1=224750&r2=224751&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h Mon Dec 22 22:15:47 2014
> @@ -192,8 +192,10 @@ public:
>      : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
>        OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg),
>        AllowedRegs(Other.AllowedRegs) {
> -    std::copy(&Other.OptUnsafeEdges[0], &Other.OptUnsafeEdges[NumOpts],
> -              &OptUnsafeEdges[0]);
> +    if (NumOpts > 0) {
> +      std::copy(&Other.OptUnsafeEdges[0], &Other.OptUnsafeEdges[NumOpts],
> +                &OptUnsafeEdges[0]);
> +    }
>

(+Lang in case he wants to fix this some other way)

We could avoid adding the conditional/branch by using pointer arithmetic
instead, perhaps? (assuming OptUnsafeEdges is just a raw array)

If it's not a raw pointer to sequence, then std::begin/std::end would be
anotehr option, etc.


>    }
>
>    // FIXME: Re-implementing default behavior to work around MSVC. Remove
> once
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141222/833a73e5/attachment.html>


More information about the llvm-commits mailing list