annotate llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 0572611fdcc8
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
1 ; Test that global constructors and destructors are run:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
2 ;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
3 ; RUN: lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module %s \
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
4 ; RUN: %S/Inputs/noop-main.ll | FileCheck %s
150
anatofuz
parents:
diff changeset
5 ;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
6 ; Test that this is true for global constructors and destructors in other
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
7 ; JITDylibs.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
8 ; RUN: lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout \
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 ; RUN: -jd extra -extra-module %s -jd main %S/Inputs/noop-main.ll | FileCheck %s
150
anatofuz
parents:
diff changeset
10 ;
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
11 ; CHECK: Hello from constructor
150
anatofuz
parents:
diff changeset
12 ; CHECK: Hello
anatofuz
parents:
diff changeset
13 ; CHECK: [ {{.*}}main{{.*}} ]
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
14 ; CHECK: Goodbye from atexit
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
15 ; CHECK: Goodbye from __cxa_atexit
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
16 ; CHECK: Goodbye from destructor
150
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 %class.Foo = type { i8 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 @f = global %class.Foo zeroinitializer, align 1
anatofuz
parents:
diff changeset
21 @__dso_handle = external global i8
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
22 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_hello.cpp, i8* null }, { i32, void ()*, i8* } { i32 1024, void ()* @constructor, i8* null }]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
23 @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @printf_wrapper, i8* null }]
150
anatofuz
parents:
diff changeset
24 @str = private unnamed_addr constant [6 x i8] c"Hello\00"
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
25 @str2 = private unnamed_addr constant [23 x i8] c"Hello from constructor\00"
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
26 @str3 = private unnamed_addr constant [24 x i8] c"Goodbye from destructor\00"
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
27 @str4 = global [26 x i8] c"Goodbye from __cxa_atexit\00"
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
28 @str5 = global [20 x i8] c"Goodbye from atexit\00"
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
29
150
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 define linkonce_odr void @_ZN3FooD1Ev(%class.Foo* nocapture readnone %this) unnamed_addr align 2 {
anatofuz
parents:
diff changeset
32 entry:
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
33 %puts.i = tail call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str4, i64 0, i64 0))
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
34 ret void
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
35 }
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
36
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
37 define void @atexit_handler() {
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
38 entry:
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
39 %puts.i = tail call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str5, i64 0, i64 0))
150
anatofuz
parents:
diff changeset
40 ret void
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*)
anatofuz
parents:
diff changeset
44
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
45 declare i32 @atexit(void ()*)
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
46
150
anatofuz
parents:
diff changeset
47 define internal void @_GLOBAL__sub_I_hello.cpp() {
anatofuz
parents:
diff changeset
48 entry:
anatofuz
parents:
diff changeset
49 %puts.i.i.i = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
anatofuz
parents:
diff changeset
50 %0 = tail call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @f, i64 0, i32 0), i8* @__dso_handle)
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
51 %1 = tail call i32 @atexit(void ()* @atexit_handler)
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
52 ret void
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
53 }
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
54
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
55 define void @printf_wrapper() {
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
56 entry:
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
57 %0 = tail call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str3, i64 0, i64 0))
150
anatofuz
parents:
diff changeset
58 ret void
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 declare i32 @puts(i8* nocapture readonly)
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
62
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
63 define void @constructor() {
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
64 entry:
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
65 %0 = tail call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str2, i64 0, i64 0))
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
66 ret void
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
67 }