1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -disable-llvm-passes -o - -std=hlsl202x %s | FileCheck %s
\r
7 Pair Another = {5, 10};
\r
15 void operator=(Pair P) {
\r
20 [numthreads(1, 1, 1)]
\r
23 Vals.First = Vals.getFirst();
\r
24 Vals.Second = Vals.getSecond();
\r
27 // This test makes a probably safe assumption that HLSL 202x includes operator overloading for assignment operators.
\r
28 // CHECK: define linkonce_odr noundef i32 @"?getFirst@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
\r
29 // CHECK-NEXT:entry:
\r
30 // CHECK-NEXT:%this.addr = alloca ptr, align 4
\r
31 // CHECK-NEXT:%Another = alloca %struct.Pair, align 4
\r
32 // CHECK-NEXT:%agg.tmp = alloca %struct.Pair, align 4
\r
33 // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4
\r
34 // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4
\r
35 // CHECK-NEXT:%First = getelementptr inbounds %struct.Pair, ptr %Another, i32 0, i32 0
\r
36 // CHECK-NEXT:store i32 5, ptr %First, align 4
\r
37 // CHECK-NEXT:%Second = getelementptr inbounds %struct.Pair, ptr %Another, i32 0, i32 1
\r
38 // CHECK-NEXT:store i32 10, ptr %Second, align 4
\r
39 // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %agg.tmp, ptr align 4 %Another, i32 8, i1 false)
\r
40 // CHECK-NEXT:call void @"??4Pair@@QAAXU0@@Z"(ptr noundef nonnull align 4 dereferenceable(8) %this1, ptr noundef byval(%struct.Pair) align 4 %agg.tmp)
\r
41 // CHECK-NEXT:%First2 = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 0
\r
42 // CHECK-NEXT:%0 = load i32, ptr %First2, align 4
\r
43 // CHECK-NEXT:ret i32 %0
\r
45 // CHECK: define linkonce_odr noundef i32 @"?getSecond@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 {
\r
46 // CHECK-NEXT:entry:
\r
47 // CHECK-NEXT:%this.addr = alloca ptr, align 4
\r
48 // CHECK-NEXT:%agg.tmp = alloca %struct.Pair, align 4
\r
49 // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4
\r
50 // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4
\r
51 // CHECK-NEXT:call void @llvm.memset.p0.i32(ptr align 4 %agg.tmp, i8 0, i32 8, i1 false)
\r
52 // CHECK-NEXT:call void @"??4Pair@@QAAXU0@@Z"(ptr noundef nonnull align 4 dereferenceable(8) %this1, ptr noundef byval(%struct.Pair) align 4 %agg.tmp)
\r
53 // CHECK-NEXT:%Second = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 1
\r
54 // CHECK-NEXT:%0 = load i32, ptr %Second, align 4
\r
55 // CHECK-NEXT:ret i32 %0
\r