[clang] [llvm] [DirectX][SPIRV] Consolidate the use of resource pointers across backends (PR #205433)
Finn Plummer via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 09:24:02 PDT 2026
================
@@ -0,0 +1,70 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -passes=gvn -passes=instnamer -S %s | FileCheck %s
+
+; This test ensures that given spv.resource.counterhandlefrombinding is marked
+; convergent, the GVN pass is prevented from sinking these intrinsics out of
+; branches which would create phi nodes on the returned counter handle.
+;
+; It models the following HLSL:
+;
+; RWStructuredBuffer<int> Out[4] : register(u0);
+;
+; [numthreads(4,1,1)]
+; void main(uint GI : SV_GroupIndex) {
+; for (int i = 0; i < GI; i++)
+; Out[NonUniformResourceIndex(GI)].IncrementCounter();
+;
+; Out[NonUniformResourceIndex(GI)][0] = Out[NonUniformResourceIndex(GI)].IncrementCounter();
+; }
+
+target datalayout = "e-ve-i64:64-n8:16:32:64-G10"
+target triple = "spirv1.6-unknown-vulkan1.3-compute"
+
+ at Out.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1
+ at cond = external hidden local_unnamed_addr addrspace(2) global i32, align 4
+
+define void @main() local_unnamed_addr {
+; CHECK-LABEL: define void @main() local_unnamed_addr {
----------------
inbelic wrote:
IIUC, when adding a test that is meant to test that no changes are made in a pass to the IR we should test that the same ir is output. This way if any changes are made the test fails and the change must ensure this is expected.
We could add a test that has a CHECK-NOT on the specific phi node that would be prevented, but this might not catch another form of problematic phi node introduced.
I can update the test description to make that more explicit though
https://github.com/llvm/llvm-project/pull/205433
More information about the cfe-commits
mailing list