draw: (trivial) fix out-of-bounds vector initialization
authorRoland Scheidegger <sroland@vmware.com>
Wed, 6 May 2015 13:56:17 +0000 (15:56 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Wed, 6 May 2015 14:51:09 +0000 (16:51 +0200)
Was off-by-one. llvm says inserting an element with an index higher than the
number of elements yields undefined results. Previously such inserts were
ignored but as of llvm revision 235854 the vector gets replaced with undef,
causing failures.
This fixes piglit gl-3.2-layered-rendering-gl-layer, as mentioned in
https://llvm.org/bugs/show_bug.cgi?id=23424.

Reviewed-by: Brian Paul <brianp@vmware.com>
Cc: mesa-stable@lists.freedesktop.org
src/gallium/auxiliary/draw/draw_llvm.c

index 71506114dc3c11ac81c357c0974071398e89a2cd..b9e55af42c76c77ff6946b1c4cf91f1441f8daa6 100644 (file)
@@ -2048,7 +2048,7 @@ generate_mask_value(struct draw_gs_llvm_variant *variant,
 
    num_prims = lp_build_broadcast(gallivm, lp_build_vec_type(gallivm, mask_type),
                                   variant->num_prims);
-   for (i = 0; i <= gs_type.length; i++) {
+   for (i = 0; i < gs_type.length; i++) {
       LLVMValueRef idx = lp_build_const_int32(gallivm, i);
       mask_val = LLVMBuildInsertElement(builder, mask_val, idx, idx, "");
    }