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

Alexey Samsonov vonosmas at gmail.com
Mon Dec 22 20:15:47 PST 2014


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]);
+    }
   }
 
   // FIXME: Re-implementing default behavior to work around MSVC. Remove once





More information about the llvm-commits mailing list