|
| 1 | +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -disable-llvm-passes -emit-llvm -finclude-default-header -o - %s | FileCheck %s |
| 2 | + |
| 3 | +typedef int Foo[2]; |
| 4 | + |
| 5 | +// CHECK-LABEL: define void {{.*}}boop{{.*}}(ptr dead_on_unwind noalias writable sret([2 x i32]) align 4 %agg.result) |
| 6 | +// CHECK: [[G:%.*]] = alloca [2 x i32], align 4 |
| 7 | +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[G]], ptr align 4 {{.*}}, i32 8, i1 false) |
| 8 | +// CHECK-NEXT: [[AIB:%.*]] = getelementptr inbounds [2 x i32], ptr %agg.result, i32 0, i32 0 |
| 9 | +// CHECK-NEXT: br label %arrayinit.body |
| 10 | +// CHECK: arrayinit.body: |
| 11 | +// CHECK-NEXT: [[AII:%.*]] = phi i32 [ 0, %entry ], [ %arrayinit.next, %arrayinit.body ] |
| 12 | +// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds i32, ptr [[AIB]], i32 [[AII]] |
| 13 | +// CHECK-NEXT: [[AI:%.*]] = getelementptr inbounds nuw [2 x i32], ptr [[G]], i32 0, i32 [[AII]] |
| 14 | +// CHECK-NEXT: [[Y:%.*]] = load i32, ptr [[AI]], align 4 |
| 15 | +// CHECK-NEXT: store i32 [[Y]], ptr [[X]], align 4 |
| 16 | +// CHECK-NEXT: [[AIN:%.*]] = add nuw i32 [[AII]], 1 |
| 17 | +// CHECK-NEXT: [[AID:%.*]] = icmp eq i32 [[AIN]], 2 |
| 18 | +// CHECK-NEXT: br i1 [[AID]], label %arrayinit.end, label %arrayinit.body |
| 19 | +// CHECK: arrayinit.end: |
| 20 | +// CHECK-NEXT: ret void |
| 21 | +export Foo boop() { |
| 22 | + Foo G = {1,2}; |
| 23 | + return G; |
| 24 | +} |
| 25 | + |
| 26 | +// CHECK-LABEL: define void {{.*}}foo{{.*}}(ptr dead_on_unwind noalias writable sret([2 x i32]) align 4 %agg.result) |
| 27 | +// CHECK: store i32 1, ptr %agg.result, align 4 |
| 28 | +// CHECK-NEXT: [[E:%.*]] = getelementptr inbounds i32, ptr %agg.result, i32 1 |
| 29 | +// CHECK-NEXT: store i32 2, ptr [[E]], align 4 |
| 30 | +// CHECK-NEXT: ret void |
| 31 | +export int foo()[2] { |
| 32 | + return {1,2}; |
| 33 | +} |
0 commit comments