[Mesa-dev] [PATCH] Fix strict-aliasing violations in GLSL shader list implementation

Davin McCall davmac at davmac.org
Wed Jun 24 14:05:11 PDT 2015

Hi - I'm new here.

I've recently started poking the Mesa codebase for little reason other 
than personal interest. In the "help wanted" section of the website it 
mentions aliasing violations as a target for newcomers to fix, so with 
that in mind I've attached a patch (against git head) which resolves a 
few of them, by targeting the linked list implementation (list.h) used 
in the GLSL compiler/optimizers. This change slightly increases the 
storage requirements for a list (adds one word) but resolves the blatant 
aliasing violation that was caused by the trick used to conserve that 
word in the first place.

(I toyed with another approach - using a single sentinel node for both 
the head and tail of a list - but this was much more invasive, and meant 
that you could no longer check whether a particular node was a sentinel 
node unless you had a reference to the list, so I gave up and went with 
this simpler approach).

The most essential change is in the 'exec_list' structure. Three fields 
'head', 'tail' and 'tail_pred' are removed, and two separate sentinel 
nodes are inserted in their place. The old 'head' is replaced by 
'head_sentinel.next', 'tail_pred' by 'tail_sentinel.prev', and tail 
(always NULL) by 'head_sentinel.prev' and 'tail_sentinel.next' (both 
always NULL).

With this patch, I can build a working (though perhaps not 100% 
bug-free) Mesa without using -fno-strict-aliasing during compilation. 
Before the patch, applications using Mesa would hang at runtime.

I don't really know the process you have in place so if I need to do 
anything else to get this patch into the codebase please let me know. 
Any comments and criticisms welcome.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesapatch-glsl-lists-git.patch
Type: text/x-patch
Size: 32695 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150624/c19ce3dd/attachment-0001.bin>

More information about the mesa-dev mailing list