Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / clang-offload-bundler-zlib.c
blobc46c32a4a0537b4047b77d0e61db65cadcfac162
1 // REQUIRES: zlib
2 // REQUIRES: x86-registered-target
3 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
5 //
6 // Generate the host binary to be bundled.
7 //
8 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc
11 // Generate an empty file to help with the checks of empty files.
13 // RUN: touch %t.empty
16 // Generate device binaries to be bundled.
18 // RUN: echo 'Content of device file 1' > %t.tgt1
19 // RUN: echo 'Content of device file 2' > %t.tgt2
22 // Check compression/decompression of offload bundle.
24 // RUN: env OFFLOAD_BUNDLER_COMPRESS=1 OFFLOAD_BUNDLER_VERBOSE=1 \
25 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
26 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 | \
27 // RUN: FileCheck -check-prefix=COMPRESS %s
28 // RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s
29 // RUN: env OFFLOAD_BUNDLER_VERBOSE=1 \
30 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
31 // RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 2>&1 | \
32 // RUN: FileCheck -check-prefix=DECOMPRESS %s
33 // RUN: diff %t.tgt1 %t.res.tgt1
34 // RUN: diff %t.tgt2 %t.res.tgt2
37 // COMPRESS: Compression method used:
38 // DECOMPRESS: Decompression method:
39 // NOHOST-NOT: host-
40 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx900
41 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx906
45 // Check -bundle-align option.
48 // 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
49 // 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
50 // RUN: diff %t.bc %t.res.bc
51 // RUN: diff %t.tgt1 %t.res.tgt1
52 // RUN: diff %t.tgt2 %t.res.tgt2
55 // Check unbundling archive.
57 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
58 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%T/hip_bundle1.bc -compress
59 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
60 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%T/hip_bundle2.bc -compress
61 // RUN: llvm-ar cr %T/hip_archive.a %T/hip_bundle1.bc %T/hip_bundle2.bc
62 // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
63 // RUN: -output=%T/hip_900.a -output=%T/hip_906.a -input=%T/hip_archive.a
64 // RUN: llvm-ar t %T/hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s
65 // RUN: llvm-ar t %T/hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s
66 // HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900
67 // HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900
68 // HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906
69 // HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906
71 // Some code so that we can create a binary out of this file.
72 int A = 0;
73 void test_func(void) {
74 ++A;