xref: /llvm-project/compiler-rt/test/orc/TestCases/Generic/lazy-link.ll (revision 8daf4f16fa08b5d876e98108721dd1743a360326)
1; Check that files passed with the -lazy option aren't linked unless they're
2; needed. The foo-ret-42.ll file, which contains only code, should not be
3; needed in this -noexec case, whereas x.o, which contains a global variable
4; referenced by main, should be linked (despite being passed with -lazy).
5;
6; RUN: rm -rf %t && mkdir -p %t
7; RUN: %clang -c -o %t/foo.o %S/Inputs/foo-ret-42.ll
8; RUN: %clang -c -o %t/x.o %S/Inputs/var-x-42.ll
9; RUN: %clang -c -o %t/main.o %s
10; RUN: %llvm_jitlink -noexec -show-linked-files %t/main.o -lazy %t/foo.o \
11; RUN:     -lazy %t/x.o | FileCheck %s
12;
13; UNSUPPORTED: system-windows
14; REQUIRES: target={{(arm|aarch|x86_)64.*}}
15;
16; CHECK: Linking {{.*}}main.o
17; CHECK-DAG: Linking <indirect stubs graph #1>
18; CHECK-DAG: Linking {{.*}}x.o
19; CHECK-NOT: Linking {{.*}}foo.o
20
21declare i32 @foo()
22@x = external global i32
23
24define i32 @main(i32 %argc, ptr %argv) {
25entry:
26  %foo_result = call i32 @foo()
27  %x_val = load i32, ptr @x
28  %result = add nsw i32 %foo_result, %x_val
29  ret i32 %result
30}
31