[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Driver / clang-offload-bundler-zlib.c
blob7e5857296756cb76862a48c2a4663890ef00367b
1 // REQUIRES: zlib && !zstd
2 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, target={{.*}}-zos{{.*}}
4 //
5 // Generate the host binary to be bundled.
6 //
7 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc
9 //
10 // Generate an empty file to help with the checks of empty files.
12 // RUN: touch %t.empty
15 // Generate device binaries to be bundled.
17 // RUN: echo 'Content of device file 1' > %t.tgt1
18 // RUN: echo 'Content of device file 2' > %t.tgt2
21 // Check compression/decompression of offload bundle.
23 // RUN: env OFFLOAD_BUNDLER_COMPRESS=1 OFFLOAD_BUNDLER_VERBOSE=1 \
24 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
25 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 | \
26 // RUN: FileCheck -check-prefix=COMPRESS %s
27 // RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s
28 // RUN: env OFFLOAD_BUNDLER_VERBOSE=1 \
29 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
30 // RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 2>&1 | \
31 // RUN: FileCheck -check-prefix=DECOMPRESS %s
32 // RUN: diff %t.tgt1 %t.res.tgt1
33 // RUN: diff %t.tgt2 %t.res.tgt2
36 // COMPRESS: Compression method used: zlib
37 // COMPRESS: Compression level: 6
38 // DECOMPRESS: Decompression method: zlib
39 // DECOMPRESS: Hashes match: Yes
40 // NOHOST-NOT: host-
41 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx900
42 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx906
45 // Check -compression-level= option
47 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
48 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc -compress -verbose -compression-level=9 2>&1 | \
49 // RUN: FileCheck -check-prefix=LEVEL %s
50 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
51 // RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle
52 // RUN: diff %t.tgt1 %t.res.tgt1
53 // RUN: diff %t.tgt2 %t.res.tgt2
55 // LEVEL: Compression method used: zlib
56 // LEVEL: Compression level: 9
59 // Check -bundle-align option.
62 // RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc -compress
63 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle
64 // RUN: diff %t.bc %t.res.bc
65 // RUN: diff %t.tgt1 %t.res.tgt1
66 // RUN: diff %t.tgt2 %t.res.tgt2
69 // Check unbundling archive.
71 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
72 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle1.bc -compress
73 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
74 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle2.bc -compress
75 // RUN: rm -f %t.hip_archive.a
76 // RUN: llvm-ar cr %t.hip_archive.a %t.hip_bundle1.bc %t.hip_bundle2.bc
77 // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
78 // RUN: -output=%t.hip_900.a -output=%t.hip_906.a -input=%t.hip_archive.a
79 // RUN: llvm-ar t %t.hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s
80 // RUN: llvm-ar t %t.hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s
81 // HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900
82 // HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900
83 // HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906
84 // HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906
86 // Some code so that we can create a binary out of this file.
87 int A = 0;
88 void test_func(void) {
89 ++A;