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/40092>
This commit is contained in:
Yiwei Zhang 2026-02-15 00:22:11 -08:00 committed by Eric Engestrom
parent 6fb7a07c79
commit 7c0b97be73
2 changed files with 5 additions and 1 deletions

View file

@ -4244,7 +4244,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

@ -98,6 +98,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),