[clang] [HLSL] Array by-value assignment (PR #109323)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 23 11:17:49 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:
Why are there 3 allocas here instead of 2? It looks to me like these memcpy/memsets are doing:
1. Copy the constant `{0, 1}` array into `Arr`
2. Zero initialize `Arr2`
3. Copy `Arr2` into `Arr`
4. Copy `Arr` into some other array?
I'm not sure why (4) is happening but it looks suspicious.
https://github.com/llvm/llvm-project/pull/109323
More information about the cfe-commits
mailing list