Mesa (llvm-context): gallivm/llvmpipe: call LLVMInvalidateStructLayout() when creating struct types

Brian Paul brianp at kemper.freedesktop.org
Mon Nov 1 21:08:43 UTC 2010


Module: Mesa
Branch: llvm-context
Commit: 5379235ec7be3f5f61f94d43f70309977c24245f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5379235ec7be3f5f61f94d43f70309977c24245f

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Nov  1 15:05:34 2010 -0600

gallivm/llvmpipe: call LLVMInvalidateStructLayout() when creating struct types

This fixes intermittent assertion failures in the LP_CHECK_MEMBER_OFFSET and
LP_CHECK_STRUCT_SIZE checkers.  This would happen sometimes after we freed
all the LLVM data structures and were recreating our structure types.

---

 src/gallium/auxiliary/draw/draw_llvm.c |   11 +++++++++++
 src/gallium/drivers/llvmpipe/lp_jit.c  |    4 ++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 2eae237..3e16b22 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -122,6 +122,11 @@ create_jit_texture_type(struct gallivm_state *gallivm)
    texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                           Elements(elem_types), 0);
 
+   /* Make sure the target's struct layout cache doesn't return
+    * stale/invalid data.
+    */
+   LLVMInvalidateStructLayout(gallivm->target, texture_type);
+
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
                           target, texture_type,
                           DRAW_JIT_TEXTURE_WIDTH);
@@ -184,6 +189,8 @@ create_jit_context_type(struct gallivm_state *gallivm,
    context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                           Elements(elem_types), 0);
 
+   LLVMInvalidateStructLayout(gallivm->target, context_type);
+
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
                           target, context_type, 0);
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, gs_constants,
@@ -218,6 +225,8 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
    vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                      Elements(elem_types), 0);
 
+   LLVMInvalidateStructLayout(gallivm->target, vb_type);
+
    LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
                           target, vb_type, 0);
    LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer_offset,
@@ -249,6 +258,8 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
    vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
                                            Elements(elem_types), 0);
 
+   LLVMInvalidateStructLayout(gallivm->target, vertex_header);
+
    /* these are bit-fields and we can't take address of them
       LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
       target, vertex_header,
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index 08a19fe..a775990 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -72,6 +72,8 @@ lp_jit_create_types(struct llvmpipe_context *lp)
       texture_type = LLVMStructTypeInContext(lc, elem_types,
                                              Elements(elem_types), 0);
 
+      LLVMInvalidateStructLayout(gallivm->target, texture_type);
+
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
                              gallivm->target, texture_type,
                              LP_JIT_TEXTURE_WIDTH);
@@ -128,6 +130,8 @@ lp_jit_create_types(struct llvmpipe_context *lp)
       context_type = LLVMStructTypeInContext(lc, elem_types,
                                              Elements(elem_types), 0);
 
+      LLVMInvalidateStructLayout(gallivm->target, context_type);
+
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
                              gallivm->target, context_type,
                              LP_JIT_CTX_CONSTANTS);




More information about the mesa-commit mailing list