[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / PowerPC / aix-destructor-attribute.c
blobcfb1fd7b0171a416d721df648c6ef021ab3f7ae1
1 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm \
2 // RUN: -fno-use-cxa-atexit < %s | \
3 // RUN: FileCheck --check-prefix=NO-REGISTER %s
4 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm \
5 // RUN: -fno-use-cxa-atexit < %s | \
6 // RUN: FileCheck --check-prefix=NO-REGISTER %s
8 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm \
9 // RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
10 // RUN: FileCheck --check-prefix=REGISTER %s
11 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm \
12 // RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
13 // RUN: FileCheck --check-prefix=REGISTER %s
15 int bar(void) __attribute__((destructor(100)));
16 int bar2(void) __attribute__((destructor(65535)));
17 int bar3(int) __attribute__((destructor(65535)));
19 int bar(void) {
20 return 1;
23 int bar2(void) {
24 return 2;
27 int bar3(int a) {
28 return a;
31 // NO-REGISTER: @llvm.global_dtors = appending global [3 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 100, ptr @bar, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @bar2, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @bar3, ptr null }]
33 // REGISTER: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 100, ptr @__GLOBAL_init_100, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__GLOBAL_init_65535, ptr null }]
34 // REGISTER: @llvm.global_dtors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 100, ptr @__GLOBAL_cleanup_100, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__GLOBAL_cleanup_65535, ptr null }]
36 // REGISTER: define internal void @__GLOBAL_init_100() [[ATTR:#[0-9]+]] {
37 // REGISTER: entry:
38 // REGISTER: %0 = call i32 @atexit(ptr @bar)
39 // REGISTER: ret void
40 // REGISTER: }
42 // REGISTER: define internal void @__GLOBAL_init_65535() [[ATTR:#[0-9]+]] {
43 // REGISTER: entry:
44 // REGISTER: %0 = call i32 @atexit(ptr @bar2)
45 // REGISTER: %1 = call i32 @atexit(ptr @bar3)
46 // REGISTER: ret void
47 // REGISTER: }
49 // REGISTER: define internal void @__GLOBAL_cleanup_100() [[ATTR:#[0-9]+]] {
50 // REGISTER: entry:
51 // REGISTER: %0 = call i32 @unatexit(ptr @bar)
52 // REGISTER: %needs_destruct = icmp eq i32 %0, 0
53 // REGISTER: br i1 %needs_destruct, label %destruct.call, label %destruct.end
55 // REGISTER: destruct.call:
56 // REGISTER: call void @bar()
57 // REGISTER: br label %destruct.end
59 // REGISTER: destruct.end:
60 // REGISTER: ret void
61 // REGISTER: }
63 // REGISTER: define internal void @__GLOBAL_cleanup_65535() [[ATTR:#[0-9]+]] {
64 // REGISTER: entry:
65 // REGISTER: %0 = call i32 @unatexit(ptr @bar3)
66 // REGISTER: %needs_destruct = icmp eq i32 %0, 0
67 // REGISTER: br i1 %needs_destruct, label %destruct.call, label %unatexit.call
69 // REGISTER: destruct.call:
70 // REGISTER: call void @bar3()
71 // REGISTER: br label %unatexit.call
73 // REGISTER: unatexit.call:
74 // REGISTER: %1 = call i32 @unatexit(ptr @bar2)
75 // REGISTER: %needs_destruct1 = icmp eq i32 %1, 0
76 // REGISTER: br i1 %needs_destruct1, label %destruct.call2, label %destruct.end
78 // REGISTER: destruct.call2:
79 // REGISTER: call void @bar2()
80 // REGISTER: br label %destruct.end
82 // REGISTER: destruct.end:
83 // REGISTER: ret void
84 // REGISTER: }