1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
4 // C guarantees that brace-init with fewer initializers than members in the
5 // aggregate will initialize the rest of the aggregate as-if it were static
6 // initialization. In turn static initialization guarantees that padding is
7 // initialized to zero bits.
9 // CHECK: @__const.partial_init.s = private unnamed_addr constant { i8, [7 x i8], i64 } { i8 42, [7 x i8] zeroinitializer, i64 0 }, align 8
11 // Technically, we could initialize this padding to non-zero because all of the
12 // struct's members have initializers.
14 // CHECK: @__const.init_all.s = private unnamed_addr constant { i8, [7 x i8], i64 } { i8 42, [7 x i8] zeroinitializer, i64 -2401053089374216531 }, align 8
23 // CHECK-LABEL: @empty_braces(
25 // CHECK-NEXT: call void @llvm.memset{{.*}}(ptr align 8 %s, i8 0,
26 // CHECK-NEXT: call void @use(ptr noundef %s)
27 void empty_braces(void) {
32 // CHECK-LABEL: @partial_init(
34 // CHECK-NEXT: call void @llvm.memcpy{{.*}}(ptr align 8 %s, {{.*}}@__const.partial_init.s
35 // CHECK-NEXT: call void @use(ptr noundef %s)
36 void partial_init(void) {
37 struct S s
= { .c
= 42 };
41 // CHECK-LABEL: @init_all(
43 // CHECK-NEXT: call void @llvm.memcpy{{.*}}(ptr align 8 %s, {{.*}}@__const.init_all.s
44 // CHECK-NEXT: call void @use(ptr noundef %s)
46 struct S s
= { .c
= 42, .l
= 0xdeadbeefc0fedead };