File: static-initializers-in-objectfiles.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (28 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
; RUN: rm -rf %t
; RUN: mkdir -p %t
; RUN: lli -jit-kind=orc-lazy -enable-cache-manager -object-cache-dir=%t %s
; RUN: lli -jit-kind=orc-lazy -enable-cache-manager -object-cache-dir=%t %s
;
; Verify that LLJIT Platforms respect static initializers in cached objects.
; This IR file contains a static initializer that must execute for main to exit
; with value zero. The first execution will populate an object cache for the
; second. The initializer in the cached objects must also be successfully run
; for the test to pass.

@HasError = global i8 1, align 1
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @resetHasError, ptr null }]

define void @resetHasError() {
entry:
  store i8 0, ptr @HasError, align 1
  ret void
}

define i32 @main(i32 %argc, ptr %argv) #2 {
entry:
  %0 = load i8, ptr @HasError, align 1
  %tobool = trunc i8 %0 to i1
  %conv = zext i1 %tobool to i32
  ret i32 %conv
}