From 7c0b97be73849ecf5c7894c1b79ba7ae87c9904d Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sun, 15 Feb 2026 00:22:11 -0800 Subject: [PATCH] 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 b0397b967d9ca826e34745cebd26bfa82f1b3252) Part-of: --- .pick_status.json | 2 +- src/virtio/vulkan/vn_device.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index a1f7fca4254..ee9624adec0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index 35796c6b398..438f539f1b4 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -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),