68 lines · plain
1; Test that global constructors and destructors are run:2;3; RUN: lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module %s \4; RUN: %S/Inputs/noop-main.ll | FileCheck %s5;6; Test that this is true for global constructors and destructors in other7; JITDylibs.8; RUN: lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout \9; RUN: -jd extra -extra-module %s -jd main %S/Inputs/noop-main.ll | FileCheck %s10;11; CHECK: Hello from constructor12; CHECK: Hello13; CHECK: [ {{.*}}main{{.*}} ]14; CHECK: Goodbye from atexit15; CHECK: Goodbye from __cxa_atexit16; CHECK: Goodbye from destructor17 18%class.Foo = type { i8 }19 20@f = global %class.Foo zeroinitializer, align 121@__dso_handle = external global i822@llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_hello.cpp, ptr null }, { i32, ptr, ptr } { i32 1024, ptr @constructor, ptr null }]23@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @printf_wrapper, ptr null }]24@str = private unnamed_addr constant [6 x i8] c"Hello\00"25@str2 = private unnamed_addr constant [23 x i8] c"Hello from constructor\00"26@str3 = private unnamed_addr constant [24 x i8] c"Goodbye from destructor\00"27@str4 = global [26 x i8] c"Goodbye from __cxa_atexit\00"28@str5 = global [20 x i8] c"Goodbye from atexit\00"29 30 31define linkonce_odr void @_ZN3FooD1Ev(ptr nocapture readnone %this) unnamed_addr align 2 {32entry:33 %puts.i = tail call i32 @puts(ptr @str4)34 ret void35}36 37define void @atexit_handler() {38entry:39 %puts.i = tail call i32 @puts(ptr @str5)40 ret void41}42 43declare i32 @__cxa_atexit(ptr, ptr, ptr)44 45declare i32 @atexit(ptr)46 47define internal void @_GLOBAL__sub_I_hello.cpp() {48entry:49 %puts.i.i.i = tail call i32 @puts(ptr @str)50 %0 = tail call i32 @__cxa_atexit(ptr @_ZN3FooD1Ev, ptr @f, ptr @__dso_handle)51 %1 = tail call i32 @atexit(ptr @atexit_handler)52 ret void53}54 55define void @printf_wrapper() {56entry:57 %0 = tail call i32 @puts(ptr @str3)58 ret void59}60 61declare i32 @puts(ptr nocapture readonly)62 63define void @constructor() {64entry:65 %0 = tail call i32 @puts(ptr @str2)66 ret void67}68