From 74f2c06ca51d405a664524adfc30b9f47f3f9b17 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 d720e394c30..7e4043de6c6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index a5ffe2bc4bb..738166aab52 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -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),