[clang] [HLSL] Allow a groupshared struct to be passed as an implicit parameter (PR #229939)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 14:46:03 PDT 2026


================
@@ -133,3 +133,105 @@ void case6(S s) {
   // derived to base conversion in argument passing
   useP(s);
 }
+
+// disabled otherwise the IR will be generated in the wrong order.
+// UTC_ARGS: --disable
+
+struct G {
+  int X;
+  void f() {}
+  void setX(int val) { this.X = val; }
+  int getX() const { return X; }
+};
+
+groupshared G g;
+
+// CHECK-LABEL: define hidden void @_Z5case7v(
+// CHECK-SAME: ) #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[TMP:%.*]] = alloca [[STRUCT_G:%.*]], align 1
+// CHECK-NEXT:    [[TMP1:%.*]] = alloca [[STRUCT_G]], align 1
+// CHECK-NEXT:    call void @llvm.memcpy.p0.p3.i32(ptr align 1 [[TMP]], ptr addrspace(3) align 1 @g, i32 4, i1 false)
+// CHECK-NEXT:    call void @_ZN1G1fEv(ptr noundef nonnull align 1 dereferenceable(4) [[TMP]]) #[[ATTR3]] [ "convergencectrl"(token [[TMP0]]) ]
+// CHECK-NEXT:    call void @llvm.memcpy.p3.p0.i32(ptr addrspace(3) align 1 @g, ptr align 1 [[TMP]], i32 4, i1 false)
+// CHECK-NEXT:    call void @llvm.memcpy.p0.p3.i32(ptr align 1 [[TMP1]], ptr addrspace(3) align 1 @g, i32 4, i1 false)
----------------
hekota wrote:

Is there a way to not generate this extra `memcpy` here? It looks like it is a remnant of the value assignment after the call, but it would be better if it is not there.

https://github.com/llvm/llvm-project/pull/229939


More information about the cfe-commits mailing list