1// Test that the runtime correctly interposes atexit.
2//
3// REQUIRES: disabled
4// This test is disabled until a proper atexit interpose can be implemented:
5// the current one assumes that atexit is defined in the dylib that calls it,
6// which is not true in general. See
7// https://github.com/llvm/llvm-project/issues/74641
8//
9// RUN: %clang -c -o %t %s
10// RUN: %llvm_jitlink %t
11
12 .text
13// OnExit destructor resets the test result override to zero.
14 .globl on_exit
15 .p2align 2
16 .type on_exit,@function
17on_exit:
18
19 move $a0, $zero
20 b %plt(llvm_jitlink_setTestResultOverride)
21.Lfunc_end0:
22 .size on_exit, .Lfunc_end0-on_exit
23
24// main registers the atexit and sets the test result to one.
25 .globl main
26 .p2align 2
27 .type main,@function
28main:
29
30 addi.d $sp, $sp, -16
31 st.d $ra, $sp, 8 # 8-byte Folded Spill
32 pcalau12i $a0, %pc_hi20(on_exit)
33 addi.d $a0, $a0, %pc_lo12(on_exit)
34 bl %plt(atexit)
35 ori $a0, $zero, 1
36 bl %plt(llvm_jitlink_setTestResultOverride)
37 move $a0, $zero
38 ld.d $ra, $sp, 8 # 8-byte Folded Reload
39 addi.d $sp, $sp, 16
40 ret
41.Lfunc_end1:
42 .size main, .Lfunc_end1-main
43

source code of compiler-rt/test/orc/TestCases/Linux/loongarch64/trivial-atexit.S