gpu_group_references: check for overlapping writes again after merge
commitdd14438997a4707466ac9db7ec152c9b7f59506a
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 14 Feb 2017 15:32:42 +0000 (14 16:32 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 15 Feb 2017 09:03:01 +0000 (15 10:03 +0100)
tree697ab239ed60fa7a3b371c7d86d05f38292548d6
parent60d0d36e005c3d000c1567212e60ec2dfaf71083
gpu_group_references: check for overlapping writes again after merge

gpu_group_references calls group_writes (twice) for merging
reference groups that overlap, where two groups are considered
to overlap if they access the same elements and if at least one
of the two involves a write.  However, the merged reference group
replaces one of the two groups and is only compared against groups
that this original group has not been compared against yet.
If, say, a read is first compared against another read and then
against a write, then it is combined with the write, but not with
the read, while this second read may very well overlap with the write,
resulting in incorrect code.
To avoid this problem, check for overlaps again as soon as
any other group was merged into the current group.

It is tricky to construct a test case that would fail without this fix
because the writes usually appear first in the list of references.
Reads can be moved ahead of writes to fill a hole left when merging
two other groups, but if this happens inside group_overlapping_writes,
then the read will likely still get merged in inside
group_depth_overlapping_writes.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
gpu_group.c