Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / static-destructor.cpp
blobeea5a2e176553558320ed9b61d3cca5767e63d05
1 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
2 // RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
3 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=ARM %s
5 // Test that destructors are not passed directly to __cxa_atexit when their
6 // signatures do not match the type of its first argument.
7 // e.g. ARM and WebAssembly have destructors that return this instead of void.
10 class Foo {
11 public:
12 ~Foo() {
16 Foo global;
18 // X86 destructors have void return, and are registered directly with __cxa_atexit.
19 // X86: define internal void @__cxx_global_var_init()
20 // X86: call i32 @__cxa_atexit(ptr @_ZN3FooD1Ev, ptr @global, ptr @__dso_handle)
22 // ARM destructors return this, but can be registered directly with __cxa_atexit
23 // because the calling conventions tolerate the mismatch.
24 // ARM: define internal void @__cxx_global_var_init()
25 // ARM: call i32 @__cxa_atexit(ptr @_ZN3FooD1Ev, ptr @global, ptr @__dso_handle)
27 // Wasm destructors return this, and use a wrapper function, which is registered
28 // with __cxa_atexit.
29 // WASM: define internal void @__cxx_global_var_init()
30 // WASM: call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr null, ptr @__dso_handle)
32 // WASM: define internal void @__cxx_global_array_dtor(ptr noundef %0)
33 // WASM: %call = call noundef ptr @_ZN3FooD1Ev(ptr {{[^,]*}} @global)