venus: workaround a gcc-15 dead store elimination (DSE) bug

No issue with clang or gcc-14.x (or earlier versions). The issue only
shows up since gcc-15.1. The compiler somehow fails to consider those
cs helpers dereferencing the pointer from the pNext chain for reads,
and thus has falsely optimized away the pNext store. This change works
around this with a no-op memory clobber.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13242
Cc: mesa-stable
(cherry picked from commit b0397b967d)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39969>
This commit is contained in:
Yiwei Zhang 2026-02-15 00:22:11 -08:00 committed by Dylan Baker
parent 82e1222bbb
commit 74f2c06ca5
2 changed files with 5 additions and 1 deletions

View file

@ -934,7 +934,7 @@
"description": "venus: workaround a gcc-15 dead store elimination (DSE) bug",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -79,6 +79,10 @@ vn_queue_init(struct vn_device *dev,
.queueFamilyIndex = queue_info->queueFamilyIndex,
.queueIndex = queue_index,
};
#if DETECT_CC_GCC && (DETECT_CC_GCC_VERSION >= 1501)
/* Workaround GCC-15 aggressive Dead Store Elimination (DSE). */
__asm__ volatile("" : : "g"(device_queue_info.pNext) : "memory");
#endif
VkQueue queue_handle = vn_queue_to_handle(queue);
vn_async_vkGetDeviceQueue2(dev->primary_ring, vn_device_to_handle(dev),