xref: /llvm-project/clang/test/Frontend/embed-bitcode.ll (revision 9acb533c38be833ec1d8daa06e127a9de8f0a5ef)
1; REQUIRES: arm-registered-target
2; REQUIRES: aarch64-registered-target
3; check .ll input
4; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
5; RUN:    -fembed-bitcode=all -x ir %s -o - \
6; RUN:    | FileCheck %s
7; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
8; RUN:    -fembed-bitcode=marker -x ir %s -o - \
9; RUN:    | FileCheck %s -check-prefix=CHECK-MARKER
10; RUN: %clang_cc1 -triple aarch64 -emit-llvm \
11; RUN:    -fembed-bitcode=all -x ir %s -o - \
12; RUN:    | FileCheck %s -check-prefix=CHECK-ELF
13; RUN: %clang_cc1 -triple spirv64-amd-amdhsa -emit-llvm \
14; RUN:    -fembed-bitcode=all -x ir %s -o - \
15; RUN:    | FileCheck %s -check-prefix=CHECK-ELF
16
17; check .bc input
18; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
19; RUN:    -x ir %s -o %t.bc
20; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
21; RUN:    -fembed-bitcode=all -x ir %t.bc -o - \
22; RUN:    | FileCheck %s
23; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
24; RUN:    -fembed-bitcode=bitcode -x ir %t.bc -o - \
25; RUN:    | FileCheck %s -check-prefix=CHECK-ONLY-BITCODE
26; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
27; RUN:    -fembed-bitcode=marker -x ir %t.bc -o - \
28; RUN:    | FileCheck %s -check-prefix=CHECK-MARKER
29
30; run through -fembed-bitcode twice and make sure it doesn't crash
31; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
32; RUN:    -fembed-bitcode=all -x ir %s -o - \
33; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
34; RUN:    -fembed-bitcode=all -x ir - -o /dev/null
35
36; check the magic number of bitcode at the beginning of the string
37; CHECK: @llvm.embedded.module = private constant
38; CHECK: c"\DE\C0\17\0B
39; CHECK: section "__LLVM,__bitcode"
40; CHECK: @llvm.cmdline = private constant
41; CHECK: section "__LLVM,__cmdline"
42
43; check warning options are not embedded
44; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
45; RUN:    -fembed-bitcode=all -x ir %s -o - -Wall -Wundef-prefix=TEST \
46; RUN:    | FileCheck %s -check-prefix=CHECK-WARNING
47
48; CHECK-ELF: @llvm.embedded.module
49; CHECK-ELF-SAME: section ".llvmbc", align 1
50; CHECK-ELF: @llvm.cmdline
51; CHECK-ELF-SAME: section ".llvmcmd", align 1
52
53; CHECK-ONLY-BITCODE: @llvm.embedded.module = private constant
54; CHECK-ONLY-BITCODE: c"\DE\C0\17\0B
55; CHECK-ONLY-BITCODE: section "__LLVM,__bitcode"
56; CHECK-ONLY-BITCODE-NOT: @llvm.cmdline = private constant
57; CHECK-ONLY-BITCODE-NOT: section "__LLVM,__cmdline"
58
59; CHECK-MARKER: @llvm.embedded.module
60; CHECK-MARKER: constant [0 x i8] zeroinitializer
61; CHECK-MARKER: section "__LLVM,__bitcode"
62; CHECK-MARKER: @llvm.cmdline
63; CHECK-MARKER: section "__LLVM,__cmdline"
64
65; CHECK-WARNING-NOT: Wall
66; CHECK-WARNING-NOT: Wundef-prefix
67
68define i32 @f0() {
69  ret i32 0
70}
71