xref: /llvm-project/compiler-rt/test/orc/TestCases/FreeBSD/x86-64/lljit-initialize-deinitialize.ll (revision 1aa71f8679e439db651c06e8e68ef21e6deffa93)
1; RUN: %lli_orc_jitlink %s | FileCheck %s
2
3; CHECK: constructor
4; CHECK-NEXT: main
5; CHECK-NEXT: destructor
6
7@__dso_handle = external hidden global i8
8@.str = private unnamed_addr constant [5 x i8] c"main\00", align 1
9@.str.1 = private unnamed_addr constant [12 x i8] c"constructor\00", align 1
10@.str.2 = private unnamed_addr constant [11 x i8] c"destructor\00", align 1
11@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @constructor, i8* null }]
12
13define dso_local void @destructor(i8* %0) {
14  %2 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
15  ret void
16}
17
18declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*)
19
20; Function Attrs: nofree norecurse nounwind uwtable
21define dso_local i32 @main(i32 %0, i8** nocapture readnone %1) local_unnamed_addr #2 {
22  %3 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
23  ret i32 0
24}
25
26declare i32 @puts(i8* nocapture readonly)
27
28define internal void @constructor() {
29  %1 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0)) #5
30  %2 = tail call i32 @__cxa_atexit(void (i8*)* @destructor, i8* null, i8* nonnull @__dso_handle) #5
31  ret void
32}
33