[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / link-bitcode-file.c
blob58fee64a951385b8e5afb82087bdb1f71975b7e1
1 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s
2 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE2 -emit-llvm-bc -o %t-2.bc %s
3 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc \
4 // RUN: -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s
5 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -O3 -emit-llvm -o - \
6 // RUN: -mlink-bitcode-file %t.bc -mlink-bitcode-file %t-2.bc %s \
7 // RUN: | FileCheck -check-prefix=CHECK-NO-BC -check-prefix=CHECK-NO-BC2 %s
8 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -O3 -emit-llvm -o - \
9 // RUN: -mlink-bitcode-file %t.bc %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s
10 // Make sure we deal with failure to load the file.
11 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file no-such-file.bc \
12 // RUN: -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FILE %s
14 // Make sure we can perform the same options if the input is LLVM-IR
15 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm-bc -o %t-in.bc %s
16 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc \
17 // RUN: -O3 -emit-llvm -o - %t-in.bc | FileCheck -check-prefix=CHECK-NO-BC %s
18 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -O3 -emit-llvm -o - \
19 // RUN: -mlink-bitcode-file %t.bc -mlink-bitcode-file %t-2.bc %t-in.bc \
20 // RUN: | FileCheck -check-prefix=CHECK-NO-BC -check-prefix=CHECK-NO-BC2 %s
22 int f(void);
24 #ifdef BITCODE
26 extern int f2(void);
27 // CHECK-BC: fatal error: cannot link module {{.*}}'f': symbol multiply defined
28 int f(void) {
29 f2();
30 return 42;
33 #elif BITCODE2
34 int f2(void) { return 43; }
35 #else
37 // CHECK-NO-BC-LABEL: define{{.*}} i32 @g
38 // CHECK-NO-BC: ret i32 42
39 int g(void) {
40 return f();
43 // CHECK-NO-BC-LABEL: define{{.*}} i32 @f
44 // CHECK-NO-BC2-LABEL: define{{.*}} i32 @f2
46 #endif
48 // CHECK-NO-FILE: fatal error: cannot open file 'no-such-file.bc'