diff options
Diffstat (limited to 'clang/test/CIR/CodeGen')
-rw-r--r-- | clang/test/CIR/CodeGen/cast.cpp | 33 | ||||
-rw-r--r-- | clang/test/CIR/CodeGen/dtors.cpp | 118 | ||||
-rw-r--r-- | clang/test/CIR/CodeGen/dynamic-cast.cpp | 28 | ||||
-rw-r--r-- | clang/test/CIR/CodeGen/global-init.cpp | 103 | ||||
-rw-r--r-- | clang/test/CIR/CodeGen/record-zero-init-padding.c | 90 |
5 files changed, 368 insertions, 4 deletions
diff --git a/clang/test/CIR/CodeGen/cast.cpp b/clang/test/CIR/CodeGen/cast.cpp index 7afa955..844d4df 100644 --- a/clang/test/CIR/CodeGen/cast.cpp +++ b/clang/test/CIR/CodeGen/cast.cpp @@ -131,3 +131,36 @@ void bitcast() { // LLVM: %[[D_VEC:.*]] = load <2 x double>, ptr {{.*}}, align 16 // LLVM: %[[I_VEC:.*]] = bitcast <2 x double> %[[D_VEC]] to <4 x i32> + +void f(long int start) { + void *p = (void*)start; +} +// CIR: %[[L:.*]] = cir.load {{.*}} : !cir.ptr<!s64i>, !s64i +// CIR: %[[MID:.*]] = cir.cast integral %[[L]] : !s64i -> !u64i +// CIR: cir.cast int_to_ptr %[[MID]] : !u64i -> !cir.ptr<!void> + +// LLVM-LABEL: define{{.*}} void @_Z1fl(i64 %0) +// LLVM: %[[ADDR:.*]] = alloca i64, i64 1, align 8 +// LLVM: %[[PADDR:.*]] = alloca ptr, i64 1, align 8 +// LLVM: store i64 %0, ptr %[[ADDR]], align 8 +// LLVM: %[[L:.*]] = load i64, ptr %[[ADDR]], align 8 +// LLVM: %[[PTR:.*]] = inttoptr i64 %[[L]] to ptr +// LLVM: store ptr %[[PTR]], ptr %[[PADDR]], align 8 +// LLVM: ret void + +struct A { int x; }; + +void int_cast(long ptr) { + ((A *)ptr)->x = 0; +} +// CIR: cir.cast int_to_ptr {{.*}} : !u64i -> !cir.ptr<!rec_A> +// LLVM: inttoptr {{.*}} to ptr + +void null_cast(long) { + *(int *)0 = 0; + ((A *)0)->x = 0; +} +// CIR: %[[NULLPTR:.*]] = cir.const #cir.ptr<null> : !cir.ptr<!s32i> +// CIR: cir.store{{.*}} %{{.*}}, %[[NULLPTR]] : !s32i, !cir.ptr<!s32i> +// CIR: %[[NULLPTR_A:.*]] = cir.const #cir.ptr<null> : !cir.ptr<!rec_A> +// CIR: %[[A_X:.*]] = cir.get_member %[[NULLPTR_A]][0] {name = "x"} : !cir.ptr<!rec_A> -> !cir.ptr<!s32i> diff --git a/clang/test/CIR/CodeGen/dtors.cpp b/clang/test/CIR/CodeGen/dtors.cpp index 66554b7..7fb0975 100644 --- a/clang/test/CIR/CodeGen/dtors.cpp +++ b/clang/test/CIR/CodeGen/dtors.cpp @@ -171,3 +171,121 @@ bool test_temp_and() { return make_temp(1) && make_temp(2); } // OGCG: br label %[[CLEANUP_DONE]] // OGCG: [[CLEANUP_DONE]]: // OGCG: call void @_ZN1BD2Ev(ptr {{.*}} %[[REF_TMP0]]) + +struct C { + ~C(); +}; + +struct D { + int n; + C c; + ~D() {} +}; + +// CIR: cir.func {{.*}} @_ZN1DD2Ev +// CIR: %[[C:.*]] = cir.get_member %{{.*}}[1] {name = "c"} +// CIR: cir.call @_ZN1CD1Ev(%[[C]]) + +// LLVM: define {{.*}} void @_ZN1DD2Ev +// LLVM: %[[C:.*]] = getelementptr %struct.D, ptr %{{.*}}, i32 0, i32 1 +// LLVM: call void @_ZN1CD1Ev(ptr %[[C]]) + +// This destructor is defined after the calling function in OGCG. + +void test_nested_dtor() { + D d; +} + +// CIR: cir.func{{.*}} @_Z16test_nested_dtorv() +// CIR: cir.call @_ZN1DD2Ev(%{{.*}}) + +// LLVM: define {{.*}} void @_Z16test_nested_dtorv() +// LLVM: call void @_ZN1DD2Ev(ptr %{{.*}}) + +// OGCG: define {{.*}} void @_Z16test_nested_dtorv() +// OGCG: call void @_ZN1DD2Ev(ptr {{.*}} %{{.*}}) + +// OGCG: define {{.*}} void @_ZN1DD2Ev +// OGCG: %[[C:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i64 4 +// OGCG: call void @_ZN1CD1Ev(ptr {{.*}} %[[C]]) + +struct E { + ~E(); +}; + +struct F : public E { + int n; + ~F() {} +}; + +// CIR: cir.func {{.*}} @_ZN1FD2Ev +// CIR: %[[BASE_E:.*]] = cir.base_class_addr %{{.*}} : !cir.ptr<!rec_F> nonnull [0] -> !cir.ptr<!rec_E> +// CIR: cir.call @_ZN1ED2Ev(%[[BASE_E]]) nothrow : (!cir.ptr<!rec_E>) -> () + +// Because E is at offset 0 in F, there is no getelementptr needed. + +// LLVM: define {{.*}} void @_ZN1FD2Ev +// LLVM: call void @_ZN1ED2Ev(ptr %{{.*}}) + +// This destructor is defined after the calling function in OGCG. + +void test_base_dtor_call() { + F f; +} + +// CIR: cir.func {{.*}} @_Z19test_base_dtor_callv() +// cir.call @_ZN1FD2Ev(%{{.*}}) nothrow : (!cir.ptr<!rec_F>) -> () + +// LLVM: define {{.*}} void @_Z19test_base_dtor_callv() +// LLVM: call void @_ZN1FD2Ev(ptr %{{.*}}) + +// OGCG: define {{.*}} void @_Z19test_base_dtor_callv() +// OGCG: call void @_ZN1FD2Ev(ptr {{.*}} %{{.*}}) + +// OGCG: define {{.*}} void @_ZN1FD2Ev +// OGCG: call void @_ZN1ED2Ev(ptr {{.*}} %{{.*}}) + +struct VirtualBase { + ~VirtualBase(); +}; + +struct Derived : virtual VirtualBase { + ~Derived() {} +}; + +void test_base_dtor_call_virtual_base() { + Derived d; +} + +// Derived D2 (base) destructor -- does not call VirtualBase destructor + +// CIR: cir.func {{.*}} @_ZN7DerivedD2Ev +// CIR-NOT: cir.call{{.*}} @_ZN11VirtualBaseD2Ev +// CIR: cir.return + +// LLVM: define {{.*}} void @_ZN7DerivedD2Ev +// LLVM-NOT: call{{.*}} @_ZN11VirtualBaseD2Ev +// LLVM: ret + +// Derived D1 (complete) destructor -- does call VirtualBase destructor + +// CIR: cir.func {{.*}} @_ZN7DerivedD1Ev +// CIR: %[[THIS:.*]] = cir.load %{{.*}} +// CIR: %[[VTT:.*]] = cir.vtt.address_point @_ZTT7Derived, offset = 0 -> !cir.ptr<!cir.ptr<!void>> +// CIR: cir.call @_ZN7DerivedD2Ev(%[[THIS]], %[[VTT]]) +// CIR: %[[VIRTUAL_BASE:.*]] = cir.base_class_addr %[[THIS]] : !cir.ptr<!rec_Derived> nonnull [0] -> !cir.ptr<!rec_VirtualBase> +// CIR: cir.call @_ZN11VirtualBaseD2Ev(%[[VIRTUAL_BASE]]) + +// LLVM: define {{.*}} void @_ZN7DerivedD1Ev +// LLVM: call void @_ZN7DerivedD2Ev(ptr %{{.*}}, ptr @_ZTT7Derived) +// LLVM: call void @_ZN11VirtualBaseD2Ev(ptr %{{.*}}) + +// OGCG emits these destructors in reverse order + +// OGCG: define {{.*}} void @_ZN7DerivedD1Ev +// OGCG: call void @_ZN7DerivedD2Ev(ptr {{.*}} %{{.*}}, ptr {{.*}} @_ZTT7Derived) +// OGCG: call void @_ZN11VirtualBaseD2Ev(ptr {{.*}} %{{.*}}) + +// OGCG: define {{.*}} void @_ZN7DerivedD2Ev +// OGCG-NOT: call{{.*}} @_ZN11VirtualBaseD2Ev +// OGCG: ret diff --git a/clang/test/CIR/CodeGen/dynamic-cast.cpp b/clang/test/CIR/CodeGen/dynamic-cast.cpp new file mode 100644 index 0000000..e5244b2 --- /dev/null +++ b/clang/test/CIR/CodeGen/dynamic-cast.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare %s -o %t.cir 2> %t.before.log +// RUN: FileCheck %s --input-file=%t.before.log -check-prefix=CIR-BEFORE + +struct Base { + virtual ~Base(); +}; + +struct Derived : Base {}; + +// CIR-BEFORE-DAG: !rec_Base = !cir.record +// CIR-BEFORE-DAG: !rec_Derived = !cir.record +// CIR-BEFORE-DAG: #dyn_cast_info__ZTI4Base__ZTI7Derived = #cir.dyn_cast_info<src_rtti = #cir.global_view<@_ZTI4Base> : !cir.ptr<!u8i>, dest_rtti = #cir.global_view<@_ZTI7Derived> : !cir.ptr<!u8i>, runtime_func = @__dynamic_cast, bad_cast_func = @__cxa_bad_cast, offset_hint = #cir.int<0> : !s64i> + +Derived *ptr_cast(Base *b) { + return dynamic_cast<Derived *>(b); +} + +// CIR-BEFORE: cir.func dso_local @_Z8ptr_castP4Base +// CIR-BEFORE: %{{.+}} = cir.dyn_cast ptr %{{.+}} : !cir.ptr<!rec_Base> -> !cir.ptr<!rec_Derived> #dyn_cast_info__ZTI4Base__ZTI7Derived +// CIR-BEFORE: } + +Derived &ref_cast(Base &b) { + return dynamic_cast<Derived &>(b); +} + +// CIR-BEFORE: cir.func dso_local @_Z8ref_castR4Base +// CIR-BEFORE: %{{.+}} = cir.dyn_cast ref %{{.+}} : !cir.ptr<!rec_Base> -> !cir.ptr<!rec_Derived> #dyn_cast_info__ZTI4Base__ZTI7Derived +// CIR-BEFORE: } diff --git a/clang/test/CIR/CodeGen/global-init.cpp b/clang/test/CIR/CodeGen/global-init.cpp index 0c19e68..0aab695 100644 --- a/clang/test/CIR/CodeGen/global-init.cpp +++ b/clang/test/CIR/CodeGen/global-init.cpp @@ -1,9 +1,27 @@ // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare %s -o %t.cir 2> %t-before.cir // RUN: FileCheck --input-file=%t-before.cir %s --check-prefix=CIR-BEFORE-LPP // RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll +// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll +// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG -// Note: The LoweringPrepare work isn't yet complete. We still need to create -// the global ctor list attribute. +// Declarations that appear before global-specific definitions + +// CIR: module @{{.*}} attributes { +// CIR-SAME: cir.global_ctors = [#cir.global_ctor<"_GLOBAL__sub_I_[[FILENAME:.*]]", 65535>] + +// LLVM: @__dso_handle = external hidden global i8 +// LLVM: @needsCtor = global %struct.NeedsCtor zeroinitializer, align 1 +// LLVM: @needsDtor = global %struct.NeedsDtor zeroinitializer, align 1 +// LLVM: @needsCtorDtor = global %struct.NeedsCtorDtor zeroinitializer, align 1 +// LLVM: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_[[FILENAME:.*]], ptr null }] + +// OGCG: @needsCtor = global %struct.NeedsCtor zeroinitializer, align 1 +// OGCG: @needsDtor = global %struct.NeedsDtor zeroinitializer, align 1 +// OGCG: @__dso_handle = external hidden global i8 +// OGCG: @needsCtorDtor = global %struct.NeedsCtorDtor zeroinitializer, align 1 +// OGCG: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_[[FILENAME:.*]], ptr null }] struct NeedsCtor { NeedsCtor(); @@ -20,7 +38,84 @@ NeedsCtor needsCtor; // CIR: %0 = cir.get_global @needsCtor : !cir.ptr<!rec_NeedsCtor> // CIR: cir.call @_ZN9NeedsCtorC1Ev(%0) : (!cir.ptr<!rec_NeedsCtor>) -> () +// LLVM: define internal void @__cxx_global_var_init() +// LLVM: call void @_ZN9NeedsCtorC1Ev(ptr @needsCtor) + +// OGCG: define internal void @__cxx_global_var_init() {{.*}} section ".text.startup" { +// OGCG: call void @_ZN9NeedsCtorC1Ev(ptr noundef nonnull align 1 dereferenceable(1) @needsCtor) + + +struct NeedsDtor { + ~NeedsDtor(); +}; + +NeedsDtor needsDtor; + +// CIR-BEFORE-LPP: cir.global external @needsDtor = #cir.zero : !rec_NeedsDtor dtor { +// CIR-BEFORE-LPP: %[[THIS:.*]] = cir.get_global @needsDtor : !cir.ptr<!rec_NeedsDtor> +// CIR-BEFORE-LPP: cir.call @_ZN9NeedsDtorD1Ev(%[[THIS]]) : (!cir.ptr<!rec_NeedsDtor>) -> () + +// CIR: cir.global external @needsDtor = #cir.zero : !rec_NeedsDtor +// CIR: cir.func internal private @__cxx_global_var_init.1() { +// CIR: %[[OBJ:.*]] = cir.get_global @needsDtor : !cir.ptr<!rec_NeedsDtor> +// CIR: %[[DTOR:.*]] = cir.get_global @_ZN9NeedsDtorD1Ev : !cir.ptr<!cir.func<(!cir.ptr<!rec_NeedsDtor>)>> +// CIR: %[[DTOR_CAST:.*]] = cir.cast bitcast %[[DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_NeedsDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> +// CIR: %[[OBJ_CAST:.*]] = cir.cast bitcast %[[OBJ]] : !cir.ptr<!rec_NeedsDtor> -> !cir.ptr<!void> +// CIR: %[[HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[OBJ_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () + +// LLVM: define internal void @__cxx_global_var_init.1() { +// LLVM: call void @__cxa_atexit(ptr @_ZN9NeedsDtorD1Ev, ptr @needsDtor, ptr @__dso_handle) + +// OGCG: define internal void @__cxx_global_var_init.1() {{.*}} section ".text.startup" { +// OGCG: %{{.*}} = call i32 @__cxa_atexit(ptr @_ZN9NeedsDtorD1Ev, ptr @needsDtor, ptr @__dso_handle) + +struct NeedsCtorDtor { + NeedsCtorDtor(); + ~NeedsCtorDtor(); +}; + +NeedsCtorDtor needsCtorDtor; + +// CIR-BEFORE-LPP: cir.global external @needsCtorDtor = ctor : !rec_NeedsCtorDtor { +// CIR-BEFORE-LPP: %[[THIS:.*]] = cir.get_global @needsCtorDtor : !cir.ptr<!rec_NeedsCtorDtor> +// CIR-BEFORE-LPP: cir.call @_ZN13NeedsCtorDtorC1Ev(%[[THIS]]) : (!cir.ptr<!rec_NeedsCtorDtor>) -> () +// CIR-BEFORE-LPP: } dtor { +// CIR-BEFORE-LPP: %[[THIS:.*]] = cir.get_global @needsCtorDtor : !cir.ptr<!rec_NeedsCtorDtor> +// CIR-BEFORE-LPP: cir.call @_ZN13NeedsCtorDtorD1Ev(%[[THIS]]) : (!cir.ptr<!rec_NeedsCtorDtor>) -> () + +// CIR: cir.global external @needsCtorDtor = #cir.zero : !rec_NeedsCtorDtor +// CIR: cir.func internal private @__cxx_global_var_init.2() { +// CIR: %[[OBJ:.*]] = cir.get_global @needsCtorDtor : !cir.ptr<!rec_NeedsCtorDtor> +// CIR: cir.call @_ZN13NeedsCtorDtorC1Ev(%[[OBJ]]) : (!cir.ptr<!rec_NeedsCtorDtor>) -> () +// CIR: %[[OBJ:.*]] = cir.get_global @needsCtorDtor : !cir.ptr<!rec_NeedsCtorDtor> +// CIR: %[[DTOR:.*]] = cir.get_global @_ZN13NeedsCtorDtorD1Ev : !cir.ptr<!cir.func<(!cir.ptr<!rec_NeedsCtorDtor>)>> +// CIR: %[[DTOR_CAST:.*]] = cir.cast bitcast %[[DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_NeedsCtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> +// CIR: %[[OBJ_CAST:.*]] = cir.cast bitcast %[[OBJ]] : !cir.ptr<!rec_NeedsCtorDtor> -> !cir.ptr<!void> +// CIR: %[[HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[OBJ_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () + +// LLVM: define internal void @__cxx_global_var_init.2() { +// LLVM: call void @_ZN13NeedsCtorDtorC1Ev(ptr @needsCtorDtor) +// LLVM: call void @__cxa_atexit(ptr @_ZN13NeedsCtorDtorD1Ev, ptr @needsCtorDtor, ptr @__dso_handle) + +// OGCG: define internal void @__cxx_global_var_init.2() {{.*}} section ".text.startup" { +// OGCG: call void @_ZN13NeedsCtorDtorC1Ev(ptr noundef nonnull align 1 dereferenceable(1) @needsCtorDtor) +// OGCG: %{{.*}} = call i32 @__cxa_atexit(ptr @_ZN13NeedsCtorDtorD1Ev, ptr @needsCtorDtor, ptr @__dso_handle) + +// Common init function for all globals with default priority + // CIR: cir.func private @_GLOBAL__sub_I_[[FILENAME:.*]]() { // CIR: cir.call @__cxx_global_var_init() : () -> () -// CIR: cir.return -// CIR: } +// CIR: cir.call @__cxx_global_var_init.1() : () -> () +// CIR: cir.call @__cxx_global_var_init.2() : () -> () + +// LLVM: define void @_GLOBAL__sub_I_[[FILENAME]]() +// LLVM: call void @__cxx_global_var_init() +// LLVM: call void @__cxx_global_var_init.1() +// LLVM: call void @__cxx_global_var_init.2() + +// OGCG: define internal void @_GLOBAL__sub_I_[[FILENAME]]() {{.*}} section ".text.startup" { +// OGCG: call void @__cxx_global_var_init() +// OGCG: call void @__cxx_global_var_init.1() +// OGCG: call void @__cxx_global_var_init.2() diff --git a/clang/test/CIR/CodeGen/record-zero-init-padding.c b/clang/test/CIR/CodeGen/record-zero-init-padding.c new file mode 100644 index 0000000..f131c9b --- /dev/null +++ b/clang/test/CIR/CodeGen/record-zero-init-padding.c @@ -0,0 +1,90 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll +// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG + +struct padding_after_field { + char c; + int i; +}; + +struct bitfield_with_padding { + unsigned int a : 3; + unsigned int b : 5; + int c; +}; + +struct tail_padding { + int a; + char b; +}; + +struct multiple_padding { + char a; + short b; + long long c; +}; + +void test_zero_init_padding(void) { + static const struct padding_after_field paf = {1, 42}; + static const struct bitfield_with_padding bfp = {1, 2, 99}; + static const struct tail_padding tp = {10, 20}; + static const struct multiple_padding mp = {5, 10, 100}; +} + +// Type definitions for anonymous structs with padding +// CIR-DAG: !rec_anon_struct = !cir.record<struct {!s8i, !u8i, !s16i, !cir.array<!u8i x 4>, !s64i}> +// CIR-DAG: !rec_anon_struct1 = !cir.record<struct {!s32i, !s8i, !cir.array<!u8i x 3>}> +// CIR-DAG: !rec_anon_struct2 = !cir.record<struct {!u8i, !cir.array<!u8i x 3>, !s32i}> +// CIR-DAG: !rec_anon_struct3 = !cir.record<struct {!s8i, !cir.array<!u8i x 3>, !s32i}> + +// paf: char + 3 bytes padding + int -> uses !rec_anon_struct3 +// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.paf = #cir.const_record<{ +// CIR-DAG-SAME: #cir.int<1> : !s8i, +// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>, +// CIR-DAG-SAME: #cir.int<42> : !s32i +// CIR-DAG-SAME: }> : !rec_anon_struct3 + +// bfp: unsigned bitfield byte + 3 bytes padding + int -> uses !rec_anon_struct2 +// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.bfp = #cir.const_record<{ +// CIR-DAG-SAME: #cir.int<17> : !u8i, +// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>, +// CIR-DAG-SAME: #cir.int<99> : !s32i +// CIR-DAG-SAME: }> : !rec_anon_struct2 + +// tp: int + char + 3 bytes tail padding -> uses !rec_anon_struct1 +// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.tp = #cir.const_record<{ +// CIR-DAG-SAME: #cir.int<10> : !s32i, +// CIR-DAG-SAME: #cir.int<20> : !s8i, +// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3> +// CIR-DAG-SAME: }> : !rec_anon_struct1 + +// mp: char + 1 byte padding + short + 4 bytes padding + long long -> uses !rec_anon_struct +// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.mp = #cir.const_record<{ +// CIR-DAG-SAME: #cir.int<5> : !s8i, +// CIR-DAG-SAME: #cir.zero : !u8i, +// CIR-DAG-SAME: #cir.int<10> : !s16i, +// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 4>, +// CIR-DAG-SAME: #cir.int<100> : !s64i +// CIR-DAG-SAME: }> : !rec_anon_struct + +// CIR-LABEL: cir.func {{.*}}@test_zero_init_padding +// CIR: cir.return + +// LLVM-DAG: @test_zero_init_padding.paf = internal global { i8, [3 x i8], i32 } { i8 1, [3 x i8] zeroinitializer, i32 42 } +// LLVM-DAG: @test_zero_init_padding.bfp = internal global { i8, [3 x i8], i32 } { i8 17, [3 x i8] zeroinitializer, i32 99 } +// LLVM-DAG: @test_zero_init_padding.tp = internal global { i32, i8, [3 x i8] } { i32 10, i8 20, [3 x i8] zeroinitializer } +// LLVM-DAG: @test_zero_init_padding.mp = internal global { i8, i8, i16, [4 x i8], i64 } { i8 5, i8 0, i16 10, [4 x i8] zeroinitializer, i64 100 } + +// LLVM-LABEL: define{{.*}} void @test_zero_init_padding +// LLVM: ret void + +// OGCG-DAG: @test_zero_init_padding.paf = internal constant { i8, [3 x i8], i32 } { i8 1, [3 x i8] zeroinitializer, i32 42 } +// OGCG-DAG: @test_zero_init_padding.bfp = internal constant { i8, [3 x i8], i32 } { i8 17, [3 x i8] zeroinitializer, i32 99 } +// OGCG-DAG: @test_zero_init_padding.tp = internal constant { i32, i8, [3 x i8] } { i32 10, i8 20, [3 x i8] zeroinitializer } +// OGCG-DAG: @test_zero_init_padding.mp = internal constant { i8, i8, i16, [4 x i8], i64 } { i8 5, i8 0, i16 10, [4 x i8] zeroinitializer, i64 100 } + +// OGCG-LABEL: define{{.*}} void @test_zero_init_padding +// OGCG: ret void |