https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/205905
>From ab34698579ed76617f8d17d5e557385f4fb885e3 Mon Sep 17 00:00:00 2001 From: erichkeane <[email protected]> Date: Thu, 25 Jun 2026 13:14:57 -0700 Subject: [PATCH] [CIR] Fix return type of __cxa_atexit The return type should be 'int', not 'void'. We even have a comment above the code that generates this that it should be an int. This patch changes it and updates all the affectd tests. --- clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp | 3 ++- clang/test/CIR/CodeGen/global-array-dtor.cpp | 4 ++-- clang/test/CIR/CodeGen/global-decomp-decls.cpp | 2 +- .../test/CIR/CodeGen/global-dtor-union-narrowed.cpp | 2 +- clang/test/CIR/CodeGen/global-init.cpp | 12 ++++++------ clang/test/CIR/CodeGen/global-temp-dtor.cpp | 9 ++++----- clang/test/CIR/CodeGen/global-tls-dyn-init.cpp | 12 ++++++------ clang/test/CIR/CodeGen/global-tls-templates.cpp | 4 ++-- clang/test/CIR/CodeGen/static-local.cpp | 4 ++-- clang/test/CIR/CodeGen/static-members.cpp | 6 +++--- clang/test/CIR/CodeGen/thread-local-in-func.cpp | 12 ++++++------ clang/test/CIR/CodeGenCXX/global-refs.cpp | 2 +- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp index 7d698881ff07c..e50830cffa742 100644 --- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp @@ -359,8 +359,9 @@ struct LoweringPreparePass cir::PointerType voidPtrTy = builder.getVoidPtrTy(); cir::PointerType voidFnPtrTy = builder.getVoidFnPtrTy({voidPtrTy}); cir::PointerType handlePtrTy = builder.getPointerTo(handle.getSymType()); + IntType intTy = builder.getSIntNTy(32); auto fnAtExitType = - builder.getVoidFnTy({voidFnPtrTy, voidPtrTy, handlePtrTy}); + cir::FuncType::get({voidFnPtrTy, voidPtrTy, handlePtrTy}, intTy); llvm::StringLiteral nameAtExit = "__cxa_atexit"; if (tls) diff --git a/clang/test/CIR/CodeGen/global-array-dtor.cpp b/clang/test/CIR/CodeGen/global-array-dtor.cpp index b751f202a783b..5492e789b6356 100644 --- a/clang/test/CIR/CodeGen/global-array-dtor.cpp +++ b/clang/test/CIR/CodeGen/global-array-dtor.cpp @@ -53,7 +53,7 @@ ArrayDtor arrDtor[16]; // CIR: %[[DTOR_CAST:.*]] = cir.cast bitcast %[[DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!void>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[ARR_CAST:.*]] = cir.cast bitcast %[[ARR]] : !cir.ptr<!cir.array<!rec_ArrayDtor x 16>> -> !cir.ptr<!void> // CIR: %[[HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[ARR_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[ARR_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_array_dtor(ptr noundef %[[ARR_ARG:.*]]) { // LLVM: %[[BEGIN:.*]] = getelementptr %struct.ArrayDtor, ptr %[[ARR_ARG]], i32 0 @@ -76,7 +76,7 @@ ArrayDtor arrDtor[16]; // LLVM: } // // LLVM: define internal void @__cxx_global_var_init() { -// LLVM: call void @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @arrDtor, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @arrDtor, ptr @__dso_handle) // Note: OGCG defines these functions in reverse order of CIR->LLVM. // Note also: OGCG doesn't pass the address of the array to the destructor function. diff --git a/clang/test/CIR/CodeGen/global-decomp-decls.cpp b/clang/test/CIR/CodeGen/global-decomp-decls.cpp index 74c7ad1f2d80e..a877c9b95ecb0 100644 --- a/clang/test/CIR/CodeGen/global-decomp-decls.cpp +++ b/clang/test/CIR/CodeGen/global-decomp-decls.cpp @@ -60,7 +60,7 @@ auto [dt1, dt2, dt3] = dt; // CIR: %[[DTOR_PTR_CAST:.*]] = cir.cast bitcast %[[DTOR_PTR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_DtorType>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[SB_VOIDPTR:.*]] = cir.cast bitcast %[[SB]] : !cir.ptr<!rec_DtorType> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_PTR_CAST]], %[[SB_VOIDPTR]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_PTR_CAST]], %[[SB_VOIDPTR]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_var_init{{.*}}() // LLVM: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}@_ZDC3dt13dt23dt3E, ptr {{.*}}@dt, i64 12, i1 false) diff --git a/clang/test/CIR/CodeGen/global-dtor-union-narrowed.cpp b/clang/test/CIR/CodeGen/global-dtor-union-narrowed.cpp index b9fc11e1dfde7..f251adbc0eabb 100644 --- a/clang/test/CIR/CodeGen/global-dtor-union-narrowed.cpp +++ b/clang/test/CIR/CodeGen/global-dtor-union-narrowed.cpp @@ -34,7 +34,7 @@ S g; // LLVM: define internal void @__cxx_global_array_dtor(ptr noundef %[[A0:.*]]) // LLVM: call void @_ZN1SD2Ev(ptr %[[A0]]) // LLVM: define internal void @__cxx_global_var_init() -// LLVM: call void @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @g, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @g, ptr @__dso_handle) // OGCG: @g = global { { { [16 x i8] } } } zeroinitializer // OGCG: define internal void @__cxx_global_var_init() diff --git a/clang/test/CIR/CodeGen/global-init.cpp b/clang/test/CIR/CodeGen/global-init.cpp index eabee8972e5d4..7abb70e42d608 100644 --- a/clang/test/CIR/CodeGen/global-init.cpp +++ b/clang/test/CIR/CodeGen/global-init.cpp @@ -64,10 +64,10 @@ NeedsDtor 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>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[OBJ_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_var_init.1() { -// LLVM: call void @__cxa_atexit(ptr @_ZN9NeedsDtorD1Ev, ptr @needsDtor, ptr @__dso_handle) +// LLVM: call i32 @__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) @@ -95,11 +95,11 @@ NeedsCtorDtor 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>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[OBJ_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_var_init.2() { // LLVM: call void @_ZN13NeedsCtorDtorC1Ev(ptr noundef nonnull align 1 dereferenceable(1) @needsCtorDtor) -// LLVM: call void @__cxa_atexit(ptr @_ZN13NeedsCtorDtorD1Ev, ptr @needsCtorDtor, ptr @__dso_handle) +// LLVM: call i32 @__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) @@ -214,7 +214,7 @@ ArrayDtor arrDtor[16]; // CIR: %[[DTOR_CAST:.*]] = cir.cast bitcast %[[DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!void>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[ARR_CAST:.*]] = cir.cast bitcast %[[ARR]] : !cir.ptr<!cir.array<!rec_ArrayDtor x 16>> -> !cir.ptr<!void> // CIR: %[[HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[ARR_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[ARR_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_array_dtor(ptr noundef %[[ARR_ARG:.*]]) { // LLVM: %[[BEGIN:.*]] = getelementptr %struct.ArrayDtor, ptr %[[ARR_ARG]], i32 0 @@ -237,7 +237,7 @@ ArrayDtor arrDtor[16]; // LLVM: } // // LLVM: define internal void @__cxx_global_var_init.5() { -// LLVM: call void @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @arrDtor, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @arrDtor, ptr @__dso_handle) // Note: OGCG defines these functions in reverse order of CIR->LLVM. // Note also: OGCG doesn't pass the address of the array to the destructor function. diff --git a/clang/test/CIR/CodeGen/global-temp-dtor.cpp b/clang/test/CIR/CodeGen/global-temp-dtor.cpp index ca13c8db2fca3..a59f7d8e72c40 100644 --- a/clang/test/CIR/CodeGen/global-temp-dtor.cpp +++ b/clang/test/CIR/CodeGen/global-temp-dtor.cpp @@ -160,8 +160,7 @@ thread_local const NonTrivialArr &thread_arr_ref = NonTrivialArr{}; // LLVM-LABEL: define internal void @__cxx_global_var_init() // LLVM: call void @_ZN10NonTrivialC1Ev(ptr {{.*}} @_ZGR10static_ref_) // LLVMCIR: store ptr @_ZGR10static_ref_, ptr @static_ref -// LLVMCIR: call void @__cxa_atexit(ptr @_ZN10NonTrivialD1Ev, ptr @_ZGR10static_ref_, ptr @__dso_handle) -// OGCG: call i32 @__cxa_atexit(ptr @_ZN10NonTrivialD1Ev, ptr @_ZGR10static_ref_, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @_ZN10NonTrivialD1Ev, ptr @_ZGR10static_ref_, ptr @__dso_handle) // OGCG: store ptr @_ZGR10static_ref_, ptr @static_ref // Thread, non-array. @@ -170,7 +169,7 @@ thread_local const NonTrivialArr &thread_arr_ref = NonTrivialArr{}; // LLVMCIR: %[[TLS_ADDR:.*]] = call {{.*}}ptr @llvm.threadlocal.address.p0(ptr {{.*}}@thread_ref) // LLVMCIR: call void @_ZN10NonTrivialC1Ev(ptr {{.*}} @_ZGR10thread_ref_) // LLVMCIR: store ptr @_ZGR10thread_ref_, ptr %[[TLS_ADDR]] -// LLVMCIR: call void @__cxa_thread_atexit(ptr @_ZN10NonTrivialD1Ev, ptr @_ZGR10thread_ref_, ptr @__dso_handle) +// LLVMCIR: call i32 @__cxa_thread_atexit(ptr @_ZN10NonTrivialD1Ev, ptr @_ZGR10thread_ref_, ptr @__dso_handle) // OGCG-LABEL: define internal void @__cxx_global_var_init.1() // OGCG: call void @_ZN10NonTrivialC1Ev(ptr {{.*}} @_ZGR10thread_ref_) @@ -198,7 +197,7 @@ thread_local const NonTrivialArr &thread_arr_ref = NonTrivialArr{}; // LLVMCIR: br label %[[LOOP_CONDITION_BLOCK]] // LLVMCIR: [[LOOP_EXIT_BLOCK]]: // LLVMCIR: store ptr @_ZGR14static_arr_ref_, ptr @static_arr_ref -// LLVMCIR: call void @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @_ZGR14static_arr_ref_, ptr @__dso_handle) +// LLVMCIR: call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr @_ZGR14static_arr_ref_, ptr @__dso_handle) // OGCG-LABEL: define internal void @__cxx_global_var_init.2() // OGCG: [[ENTRY:.*]]: @@ -241,7 +240,7 @@ thread_local const NonTrivialArr &thread_arr_ref = NonTrivialArr{}; // LLVMCIR: br label %[[LOOP_CONDITION_BLOCK]] // LLVMCIR: [[LOOP_EXIT_BLOCK]]: // LLVMCIR: store ptr @_ZGR14thread_arr_ref_, ptr %[[THREAD_ARR_REF]] -// LLVMCIR: call void @__cxa_thread_atexit(ptr @__cxx_global_array_dtor.1, ptr @_ZGR14thread_arr_ref_, ptr @__dso_handle) +// LLVMCIR: call i32 @__cxa_thread_atexit(ptr @__cxx_global_array_dtor.1, ptr @_ZGR14thread_arr_ref_, ptr @__dso_handle) // OGCG-LABEL: define internal void @__cxx_global_var_init.3() // OGCG: [[ENTRY:.*]]: diff --git a/clang/test/CIR/CodeGen/global-tls-dyn-init.cpp b/clang/test/CIR/CodeGen/global-tls-dyn-init.cpp index 1359ac84b3cc3..68973223eb303 100644 --- a/clang/test/CIR/CodeGen/global-tls-dyn-init.cpp +++ b/clang/test/CIR/CodeGen/global-tls-dyn-init.cpp @@ -111,13 +111,13 @@ thread_local CtorDtor tls_cd = 5; // CIR: %[[DTOR_DECAY:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[GLOB_DECAY:.*]] = cir.cast bitcast %[[GET_GLOB]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSOHANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: cir.return // // LLVM: define internal void @[[TLS_CD_INIT]]() { // OGCG: define internal void @[[TLS_CD_INIT:.*]]() {{.*}}{ // LLVM: %[[GET_GLOB:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @tls_cd) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @tls_cd, ptr @__dso_handle) // LLVM-BOTH: ret void @@ -140,7 +140,7 @@ thread_local CtorDtor tls_cd_dyn = get_i(); // CIR: %[[DTOR_DECAY:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[GLOB_DECAY:.*]] = cir.cast bitcast %[[GET_GLOB]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSOHANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: cir.return // // LLVM: define internal void @[[TLS_CD_DYN_INIT]]() { @@ -150,7 +150,7 @@ thread_local CtorDtor tls_cd_dyn = get_i(); // LLVM: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}%[[GET_GLOB]], i32 {{.*}}%[[CALL]]) // OGCG: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}@tls_cd_dyn, i32 {{.*}}%[[CALL]]) // LLVM: %[[GET_GLOB:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @tls_cd_dyn) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @tls_cd_dyn, ptr @__dso_handle) // LLVM-BOTH: ret void @@ -200,7 +200,7 @@ thread_local CtorDtor tls_cd_dyn_not_used = get_i(); // CIR: %[[DTOR_DECAY:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[GLOB_DECAY:.*]] = cir.cast bitcast %[[GET_GLOB]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSOHANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_DECAY]], %[[GLOB_DECAY]], %[[DSOHANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: cir.return // // LLVM: define internal void @[[TLS_CD_DYN_NOT_USED_INIT]]() { @@ -210,7 +210,7 @@ thread_local CtorDtor tls_cd_dyn_not_used = get_i(); // LLVM: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}%[[GET_GLOB]], i32 {{.*}}%[[CALL]]) // OGCG: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}@tls_cd_dyn_not_used, i32 {{.*}}%[[CALL]]) // LLVM: %[[GET_GLOB:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @tls_cd_dyn_not_used) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @tls_cd_dyn_not_used, ptr @__dso_handle) // LLVM-BOTH: ret void diff --git a/clang/test/CIR/CodeGen/global-tls-templates.cpp b/clang/test/CIR/CodeGen/global-tls-templates.cpp index d6af8e90d2229..81bb2e54334a6 100644 --- a/clang/test/CIR/CodeGen/global-tls-templates.cpp +++ b/clang/test/CIR/CodeGen/global-tls-templates.cpp @@ -94,7 +94,7 @@ thread_local T tls_templ = {get_i()}; // CIR: %[[DTOR_FPTR:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[GLOB_DECAY:.*]] = cir.cast bitcast %[[GET_GLOB:.*]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_FPTR]], %[[GLOB_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DTOR_FPTR]], %[[GLOB_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: } // CIR: cir.return // CIR: } @@ -179,7 +179,7 @@ thread_local T tls_templ = {get_i()}; // OGCG: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}@_Z9tls_templI8CtorDtorE, i32 {{.*}}%[[CALL]]) // // LLVM: %[[GET_GLOB:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @_Z9tls_templI8CtorDtorE) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_GLOB]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @_Z9tls_templI8CtorDtorE, ptr @__dso_handle) // CIR-BEFORE-LPP-LABEL: cir.func{{.*}}@_Z4usesv diff --git a/clang/test/CIR/CodeGen/static-local.cpp b/clang/test/CIR/CodeGen/static-local.cpp index 3279560df3d35..e0bfa30256994 100644 --- a/clang/test/CIR/CodeGen/static-local.cpp +++ b/clang/test/CIR/CodeGen/static-local.cpp @@ -543,7 +543,7 @@ void test_dtor() { // CIR: %[[DTOR_DECAY:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_HasDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[MS_DECAY:.*]] = cir.cast bitcast %[[GET_MS_DEL]] : !cir.ptr<!rec_HasDtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_DECAY]], %[[MS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_DECAY]], %[[MS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: cir.call @__cxa_guard_release(%[[GET_GUARD]]) : (!cir.ptr<!s64i>) -> () // CIR: } @@ -602,7 +602,7 @@ void test_ctor_dtor() { // CIR: %[[DTOR_DECAY:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_HasCtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[MS_DECAY:.*]] = cir.cast bitcast %[[GET_MS_DEL]] : !cir.ptr<!rec_HasCtorDtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_DECAY]], %[[MS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_DECAY]], %[[MS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: cir.call @__cxa_guard_release(%[[GET_GUARD]]) : (!cir.ptr<!s64i>) -> () // CIR: } // CIR: } diff --git a/clang/test/CIR/CodeGen/static-members.cpp b/clang/test/CIR/CodeGen/static-members.cpp index 40e4201946094..af48af00f36aa 100644 --- a/clang/test/CIR/CodeGen/static-members.cpp +++ b/clang/test/CIR/CodeGen/static-members.cpp @@ -27,7 +27,7 @@ struct S { // LLVM: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_static_members.cpp, ptr null }] // LLVM: define internal void @__cxx_global_var_init() -// LLVM: call void @__cxa_atexit(ptr @_ZN7HasDtorD1Ev, ptr @_ZN1S2hdE, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @_ZN7HasDtorD1Ev, ptr @_ZN1S2hdE, ptr @__dso_handle) // FIXME(cir): OGCG has a guard variable for this case that we don't generate in CIR. // This is needed because the variable linkonce_odr linkage. @@ -67,10 +67,10 @@ struct Outer { // CIR: %[[DTOR_CAST:.*]] = cir.cast bitcast %[[DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_HasDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[HD_CAST:.*]] = cir.cast bitcast %[[HD]] : !cir.ptr<!rec_HasDtor> -> !cir.ptr<!void> // CIR: %[[HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[HD_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_atexit(%[[DTOR_CAST]], %[[HD_CAST]], %[[HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // LLVM: define internal void @__cxx_global_var_init.1() -// LLVM: call void @__cxa_atexit(ptr @_ZN7HasDtorD1Ev, ptr @_ZN5Outer5Inner2hdE, ptr @__dso_handle) +// LLVM: call i32 @__cxa_atexit(ptr @_ZN7HasDtorD1Ev, ptr @_ZN5Outer5Inner2hdE, ptr @__dso_handle) // OGCG: define internal void @__cxx_global_var_init.1() {{.*}} section ".text.startup" comdat($_ZN5Outer5Inner2hdE) { // OGCG: %[[GUARD:.*]] = load atomic i8, ptr @_ZGVN5Outer5Inner2hdE acquire diff --git a/clang/test/CIR/CodeGen/thread-local-in-func.cpp b/clang/test/CIR/CodeGen/thread-local-in-func.cpp index 7a1d5c517be57..0d8466ab41471 100644 --- a/clang/test/CIR/CodeGen/thread-local-in-func.cpp +++ b/clang/test/CIR/CodeGen/thread-local-in-func.cpp @@ -214,7 +214,7 @@ void test_dtor(int param) { // CIR: %[[DEL_FUNC_DECAY:.*]] = cir.cast bitcast %[[GET_DEL_FUNC]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_Dtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[TLS_DECAY:.*]] = cir.cast bitcast %[[GET_TLS_DEL]] : !cir.ptr<!rec_Dtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s8i // CIR: cir.store %[[ONE]], %[[GUARD]] : !s8i, !cir.ptr<!s8i> // CIR: } @@ -229,7 +229,7 @@ void test_dtor(int param) { // LLVM-BOTH: br i1 %[[IS_UNINIT]] // // LLVM: %[[GET_TLS_DEL:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @_ZZ9test_dtoriE10const_init) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN4DtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN4DtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN4DtorD1Ev, ptr @_ZZ9test_dtoriE10const_init, ptr @__dso_handle) // LLVM: store i8 1, ptr %[[GUARD_ADDR]] // OGCG:store i8 1, ptr @_ZGVZ9test_dtoriE10const_init @@ -273,7 +273,7 @@ void test_ctordtor(int param) { // CIR: %[[DEL_FUNC_DECAY:.*]] = cir.cast bitcast %[[GET_DEL_FUNC]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[TLS_DECAY:.*]] = cir.cast bitcast %[[GET_CONST_TLS_DEL]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s8i // CIR: cir.store %[[ONE]], %[[GUARD]] : !s8i, !cir.ptr<!s8i> // CIR: } @@ -311,7 +311,7 @@ void test_ctordtor(int param) { // CIR: %[[DEL_FUNC_DECAY:.*]] = cir.cast bitcast %[[GET_DEL_FUNC]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_CtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR: %[[TLS_DECAY:.*]] = cir.cast bitcast %[[GET_TLS_DEL]] : !cir.ptr<!rec_CtorDtor> -> !cir.ptr<!void> // CIR: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> () +// CIR: cir.call @__cxa_thread_atexit(%[[DEL_FUNC_DECAY]], %[[TLS_DECAY]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>) -> !s32i // CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s8i // CIR: cir.store %[[ONE]], %[[GUARD]] : !s8i, !cir.ptr<!s8i> // CIR: } @@ -329,7 +329,7 @@ void test_ctordtor(int param) { // LLVM: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}%[[GET_TLS_INIT]], i32 noundef 5) // OGCG: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}@_ZZ13test_ctordtoriE10const_init, i32 noundef 5) // LLVM: %[[GET_TLS_DEL:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @_ZZ13test_ctordtoriE10const_init) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @_ZZ13test_ctordtoriE10const_init, ptr @__dso_handle) // LLVM: store i8 1, ptr %[[GUARD_ADDR]] // OGCG: store i8 1, ptr @_ZGVZ13test_ctordtoriE10const_init @@ -351,7 +351,7 @@ void test_ctordtor(int param) { // OGCG: call void @_ZN8CtorDtorC1Ei(ptr {{.*}}@_ZZ13test_ctordtoriE4init, i32 noundef %[[ADD2]]) // // LLVM: %[[GET_TLS_DEL:.*]] = call ptr @llvm.threadlocal.address.p0(ptr @_ZZ13test_ctordtoriE4init) -// LLVM: call void @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) +// LLVM: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr %[[GET_TLS_DEL]], ptr @__dso_handle) // OGCG: call i32 @__cxa_thread_atexit(ptr @_ZN8CtorDtorD1Ev, ptr @_ZZ13test_ctordtoriE4init, ptr @__dso_handle) // LLVM: store i8 1, ptr %[[GUARD_ADDR]] // OGCG: store i8 1, ptr @_ZGVZ13test_ctordtoriE4init diff --git a/clang/test/CIR/CodeGenCXX/global-refs.cpp b/clang/test/CIR/CodeGenCXX/global-refs.cpp index a9e38edff2749..93a342ec19caf 100644 --- a/clang/test/CIR/CodeGenCXX/global-refs.cpp +++ b/clang/test/CIR/CodeGenCXX/global-refs.cpp @@ -115,7 +115,7 @@ WithCtorDtor withCtorDtor{}; // CIR-AFTER-NEXT: %[[VOID_FN_PTR:.*]] = cir.cast bitcast %[[GET_DTOR]] : !cir.ptr<!cir.func<(!cir.ptr<!rec_WithCtorDtor>)>> -> !cir.ptr<!cir.func<(!cir.ptr<!void>)>> // CIR-AFTER-NEXT: %[[GLOB_TO_VOID:.*]] = cir.cast bitcast %[[GET_GLOB]] : !cir.ptr<!rec_WithCtorDtor> -> !cir.ptr<!void> // CIR-AFTER-NEXT: %[[DSO_HANDLE:.*]] = cir.get_global @__dso_handle : !cir.ptr<i8> -// CIR-AFTER-NEXT: cir.call @__cxa_atexit(%[[VOID_FN_PTR]], %[[GLOB_TO_VOID]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>{{.*}}) -> () +// CIR-AFTER-NEXT: cir.call @__cxa_atexit(%[[VOID_FN_PTR]], %[[GLOB_TO_VOID]], %[[DSO_HANDLE]]) : (!cir.ptr<!cir.func<(!cir.ptr<!void>)>>, !cir.ptr<!void>, !cir.ptr<i8>{{.*}}) -> !s32i // CIR-AFTER-NEXT: cir.return // CIR-AFTER-NEXT: } // LLVM: @withCtorDtor = global %struct.WithCtorDtor zeroinitializer, align 1 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
