| 1 |
// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -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 -x c++ -emit-llvm \ |
| 5 |
// RUN: -fno-use-cxa-atexit < %s | \ |
| 6 |
// RUN: FileCheck --check-prefix=NO-REGISTER %s |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -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 -x c++ -emit-llvm \ |
| 12 |
// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \ |
| 13 |
// RUN: FileCheck --check-prefix=REGISTER %s |
| 14 |
|
| 15 |
struct test { |
| 16 |
test(); |
| 17 |
~test(); |
| 18 |
} t; |
| 19 |
|
| 20 |
int bar() __attribute__((destructor(100))); |
| 21 |
int bar2() __attribute__((destructor(65535))); |
| 22 |
int bar3(int) __attribute__((destructor(65535))); |
| 23 |
|
| 24 |
int bar() { |
| 25 |
return 1; |
| 26 |
} |
| 27 |
|
| 28 |
int bar2() { |
| 29 |
return 2; |
| 30 |
} |
| 31 |
|
| 32 |
int bar3(int a) { |
| 33 |
return a; |
| 34 |
} |
| 35 |
|
| 36 |
// NO-REGISTER: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }] |
| 37 |
// NO-REGISTER: @llvm.global_dtors = appending global [4 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 100, ptr @_Z3barv, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_Z4bar2v, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_Z4bar3i, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__D_a, ptr null }] |
| 38 |
|
| 39 |
// REGISTER: @llvm.global_ctors = appending global [3 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }, { i32, ptr, ptr } { i32 100, ptr @__GLOBAL_init_100, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__GLOBAL_init_65535, ptr null }] |
| 40 |
// REGISTER: @llvm.global_dtors = appending global [3 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__D_a, ptr null }, { i32, ptr, ptr } { i32 100, ptr @__GLOBAL_cleanup_100, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__GLOBAL_cleanup_65535, ptr null }] |
| 41 |
|
| 42 |
// REGISTER: define internal void @__GLOBAL_init_100() [[ATTR:#[0-9]+]] { |
| 43 |
// REGISTER: entry: |
| 44 |
// REGISTER: %0 = call i32 @atexit(ptr @_Z3barv) |
| 45 |
// REGISTER: ret void |
| 46 |
// REGISTER: } |
| 47 |
|
| 48 |
// REGISTER: define internal void @__GLOBAL_init_65535() [[ATTR:#[0-9]+]] { |
| 49 |
// REGISTER: entry: |
| 50 |
// REGISTER: %0 = call i32 @atexit(ptr @_Z4bar2v) |
| 51 |
// REGISTER: %1 = call i32 @atexit(ptr @_Z4bar3i) |
| 52 |
// REGISTER: ret void |
| 53 |
// REGISTER: } |
| 54 |
|
| 55 |
// REGISTER: define internal void @__GLOBAL_cleanup_100() [[ATTR:#[0-9]+]] { |
| 56 |
// REGISTER: entry: |
| 57 |
// REGISTER: %0 = call i32 @unatexit(ptr @_Z3barv) |
| 58 |
// REGISTER: %needs_destruct = icmp eq i32 %0, 0 |
| 59 |
// REGISTER: br i1 %needs_destruct, label %destruct.call, label %destruct.end |
| 60 |
|
| 61 |
// REGISTER: destruct.call: |
| 62 |
// REGISTER: call void @_Z3barv() |
| 63 |
// REGISTER: br label %destruct.end |
| 64 |
|
| 65 |
// REGISTER: destruct.end: |
| 66 |
// REGISTER: ret void |
| 67 |
// REGISTER: } |
| 68 |
|
| 69 |
// REGISTER: define internal void @__GLOBAL_cleanup_65535() [[ATTR:#[0-9]+]] { |
| 70 |
// REGISTER: entry: |
| 71 |
// REGISTER: %0 = call i32 @unatexit(ptr @_Z4bar3i) |
| 72 |
// REGISTER: %needs_destruct = icmp eq i32 %0, 0 |
| 73 |
// REGISTER: br i1 %needs_destruct, label %destruct.call, label %unatexit.call |
| 74 |
|
| 75 |
// REGISTER: destruct.call: |
| 76 |
// REGISTER: call void @_Z4bar3i() |
| 77 |
// REGISTER: br label %unatexit.call |
| 78 |
|
| 79 |
// REGISTER: unatexit.call: |
| 80 |
// REGISTER: %1 = call i32 @unatexit(ptr @_Z4bar2v) |
| 81 |
// REGISTER: %needs_destruct1 = icmp eq i32 %1, 0 |
| 82 |
// REGISTER: br i1 %needs_destruct1, label %destruct.call2, label %destruct.end |
| 83 |
|
| 84 |
// REGISTER: destruct.call2: |
| 85 |
// REGISTER: call void @_Z4bar2v() |
| 86 |
// REGISTER: br label %destruct.end |
| 87 |
|
| 88 |
// REGISTER: destruct.end: |
| 89 |
// REGISTER: ret void |
| 90 |
// REGISTER: } |