[clang] [HLSL] Array by-value assignment (PR #109323)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 23 13:42:39 PDT 2024


================
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope
+
+// CHECK-LABEL: define void {{.*}}arr_assign1
+// CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4
+// CHECK: [[Arr2:%.*]] = alloca [2 x i32], align 4
+// CHECK: [[Tmp:%.*]] = alloca [2 x i32], align 4
+// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Arr]], ptr align 4 {{@.*}}, i32 8, i1 false)
+// CHECK: call void @llvm.memset.p0.i32(ptr align 4 [[Arr2]], i8 0, i32 8, i1 false)
+// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Arr]], ptr align 4 [[Arr2]], i32 8, i1 false)
+// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[Arr]], i32 8, i1 false)
----------------
bogner wrote:

The result of a builtin assignment operator is in fact an lvalue. This is described in [basic.lval](https://timsong-cpp.github.io/cppwp/n4659/basic.lval) and [expr.ass])https://timsong-cpp.github.io/cppwp/n4659/expr.ass) but is more clearly summarized on [cppreference's value category page](https://en.cppreference.com/w/cpp/language/value_category). When an assignment operator is used in an rvalue context it goes through [lvalue-to-rvalue conversion](https://timsong-cpp.github.io/cppwp/n4659/conv.lval)



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


More information about the cfe-commits mailing list