1 | // Test that the runtime correctly interposes ___cxa_atexit. |
2 | // |
3 | // RUN: %clang -c -o %t %s |
4 | // RUN: %llvm_jitlink %t |
5 | |
6 | .text |
7 | // Destructor resets the test result override to zero. |
8 | .globl on_exit |
9 | .p2align 2 |
10 | .type on_exit,@function |
11 | on_exit: |
12 | |
13 | move $a0, $zero |
14 | b %plt(llvm_jitlink_setTestResultOverride) |
15 | .Lfunc_end0: |
16 | .size on_exit, .Lfunc_end0-on_exit |
17 | |
18 | // main registers the atexit and sets the test result to one. |
19 | .globl main |
20 | .p2align 2 |
21 | .type main,@function |
22 | main: |
23 | |
24 | addi.d $sp, $sp, -16 |
25 | st.d $ra, $sp, 8 # 8-byte Folded Spill |
26 | pcalau12i $a0, %got_pc_hi20(__dso_handle) |
27 | ld.d $a0, $a0, %got_pc_lo12(__dso_handle) |
28 | ld.d $a2, $a0, 0 |
29 | pcalau12i $a0, %pc_hi20(on_exit) |
30 | addi.d $a0, $a0, %pc_lo12(on_exit) |
31 | move $a1, $zero |
32 | bl %plt(__cxa_atexit) |
33 | ori $a0, $zero, 1 |
34 | bl %plt(llvm_jitlink_setTestResultOverride) |
35 | move $a0, $zero |
36 | ld.d $ra, $sp, 8 # 8-byte Folded Reload |
37 | addi.d $sp, $sp, 16 |
38 | ret |
39 | .Lfunc_end1: |
40 | .size main, .Lfunc_end1-main |
41 | |