[Mesa-dev] [PATCH v3] glsl: fix some strict aliasing issues in exec_list
Neil Roberts
neil at linux.intel.com
Wed Jul 1 09:08:53 PDT 2015
Hi,
If we wanted to avoid growing the size of exec_list to four pointers
instead of three, maybe we could store it in a union like below:
struct exec_list {
union {
struct {
struct exec_node head_sentinel;
struct exec_node *dummy_pointer_a;
};
struct {
struct exec_node *dummy_pointer_b;
struct exec_node tail_sentinel;
};
};
/* ... */
};
This is using anonymous structs and unions so that you wouldn't have to
otherwise modify the patch. However we might have to avoid anonymous
structs and unions on MSVC. If that's the case then it shouldn't be too
much effort to just name them and modify all of the code that is
accessing them.
You could even put a static assert somewhere to make sure it works like
this:
STATIC_ASSERT(offsetof(struct exec_list, tail_sentinel.next) ==
offsetof(struct exec_list, head_sentinel.prev));
It looks like this might also require removing the constructor for
exec_node because you can't have objects with constructors in a union
apparently. If the constructor is just a safety net anyway then maybe
this won't cause any trouble. I don't know.
Also just to note, your patch doesn't apply with git-am. Have you
cut-and-paste the patch file into an email? It looks like something has
done some word wrapping which has corrupted it. Eg:
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index cfe0df3..f5efcc5 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -842,8 +842,9 @@ ir_validate::visit_enter(ir_call *ir)
abort();
}
- const exec_node *formal_param_node = callee->parameters.head;
- const exec_node *actual_param_node = ir->actual_parameters.head;
+ const exec_node *formal_param_node =
callee->parameters.head_sentinel.next;
This isn't a valid patch because all of the lines have to begin with
either +, - or a space. If you can't use git-send-email for whatever
reason, maybe you can find a way to disable the word wrapping?
Regards,
- Neil
More information about the mesa-dev
mailing list